PDA

View Full Version : Creating an RPM


savagehobo
21st April 2010, 08:05 AM
Hello,

I have been trying to create a custom RPM package to be used in a custom live cd I've been creating for a school project. I have almost completed the Live CD, but am trying to add a custom background. With some googling it looks like creating an RPM package to add the background file to the /usr/share/backgrounds folder and then using a gconftool-2 command to set the default background is the way to go.

I have been reading through the http://fedoraproject.org/wiki/PackageMaintainers/CreatingPackageHowTo information page and have started to create a .spec file for the package. I am running this on an Inspiron 6400 Laptop running F12. I installed the "Developer Tools", rpmdevtools, and ran the rpmdev-setuptree
command in the home directory.


The background file is called 1280-wide.png and I have put it in my ~/rpmbuild/SOURCES directory. My spec file is shown below:

Name: chd-backgrounds
Version: 1.0
Release: 1%{?dist}
Summary: Package contains background files to be used in CHD Linux Live USB/CD distrobution.

Group: User Interface/Desktops
License: GPLv2+
URL: -------------- I REMOVED THIS-----------------------
Source0: -------------------- I REMOVED THIS----------------------
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

#BuildRequires:
#Requires:

%description
Package contains background files to be used in CHD Linux Live USB/CD distrobution

%prep
%setup -q


%build
%configure
%make %{?_smp_mflags}


%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
cp -p 1280-wide.png /usr/share/backgrounds

%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root,-)
%doc
%/usr/share/backgrounds/1280-wide.png


%changelog


When I try to run "rpmbuild -ba SPECS/chd-backgrounds.spec" I get...


Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.9xSn5s
+ umask 022
+ cd /home/user/rpmbuild/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd /home/user/rpmbuild/BUILD
+ rm -rf chd-backgrounds-1.0
+ /bin/tar -xf /home/user/rpmbuild/SOURCES/1280-wide.png
/bin/tar: This does not look like a tar archive
/bin/tar: Skipping to next header
/bin/tar: Exiting with failure status due to previous errors
error: Bad exit status from /var/tmp/rpm-tmp.9xSn5s (%prep)


RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.9xSn5s (%prep)





The info from the file specified is:

.....
cd '/home/user/rpmbuild/BUILD'
rm -rf 'chd-backgrounds-1.0'
/bin/tar -xf /home/user/rpmbuild/SOURCES/1280-wide.png
cd 'chd-backgrounds-1.0'
/bin/chmod -Rf a+rX,u+w,g-w,o-w .

It looks like it's trying to cd into a directory that was just removed but I'm not really sure.... Anyone have some suggestions?

Hlingler
21st April 2010, 08:08 AM
Moved to "Packaging".

Good Luck,
V

ultra magnus
21st April 2010, 10:20 AM
If I were you, I'd try this:

cd rpmbuild/SOURCES
mkdir -p /usr/share/backgrounds

and then put all the wallpapers I wanted to package inside that dir, then make a tar.gz of it (chd-backgrounds.tar.gz)

then put the created tar.gz inside rpmbuild/SOURCES
and edit your specfile like:

Source0: %{name}.tar.gz
you can remove %build, %configure, %make and %install completely, as there is nothing to build.
If that goes well, rpmbuild will complain about unpackaged files, and if that's the case, then you're almost done.
I think this should get you started. Right now it fails @ %setup because there is no source to unpack.

I reserve the right be completely wrong though. :p

savagehobo
21st April 2010, 05:57 PM
Thanks for the response.

I was confused about this section...


cd rpmbuild/SOURCES
mkdir -p /usr/share/backgrounds


Since the /usr/share/backgrounds directory already exists on my system I figured you meant


cd rpmbuild/SOURCES
mkdir -p usr/share/backgrounds


I created that directory, added 1280-wide.png file to the backgrounds folder and created a tar.gz archive of the usr directory in the SOURCES folder.

Here is the spec file again...



Name: chd-backgrounds
Version: 1.0
Release: 1%{?dist}
Summary: Package contains background files to be used in CHD Linux Live USB/CD distrobution.

Group: User Interface/Desktops
License: GPLv2+
URL: ----------------------------REMOVED-----------------------------------
Source0: %{name}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

#BuildRequires:
#Requires:

%description
Package contains background files to be used in CHD Linux Live USB/CD distrobution

%files
%defattr(-,root,root,-)

%changelog



I ran the rpmbuild command and it created a 1.7 KB rpm file... which when installed doesn't contain the 1.2 MB 1280-wide image file.... I tried experimenting with adding cp/mkdir lines in %install but no luck.... I'm not really sure how to move the files over... any other suggestions?

PabloEsc
21st April 2010, 06:36 PM
I believe you need to add :
%files -n name
/usr/share/backgrounds/*.png

PabloTwo
21st April 2010, 06:37 PM
Of course it doesn't contain anything, you didn't install anything.
Don't end your Summary text with a period "."
Don't bother to .tar.gz up anything. Just put the single 1280-wide.png in the SOURCES directory.
Fill in the %changelog entry with proper format.
Name: chd-backgrounds
Version: 1.0
Release: 1%{?dist}
Summary: Package contains background files to be used in CHD Linux Live USB/CD distrobution

Group: User Interface/Desktops
License: GPLv2+
URL: ----------------------------REMOVED-----------------------------------
Source0: 1280-wide.png
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

#BuildRequires:
#Requires:

%description
Package contains background files to be used in CHD Linux Live USB/CD distrobution

%install
rm -rf $RPM_BUILD_ROOT

mkdir -p $RPM_BUILD_ROOT%{_datadir}/backgrounds
install -m 644 %{SOURCE0} $RPM_BUILD_ROOT%{_datadir}/backgrounds

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root,-)
%{_datadir}/backgrounds/1208-wide.png

%changelog

Edit: Forgot to add the %clean section in. It's there now.

ultra magnus
21st April 2010, 06:39 PM
I think something like that should work.

PabloTwo
21st April 2010, 06:49 PM
yum install rpmlint
And then before you try building the package, run: rpmlint chd-backgrounds.spec
You'll probably be amazed at the Warning and/or Error messages thrown back at you.
The goal is to get an rpmlint inspection that is Warning and Error free. You can't always get rid of all the warnings, but you absolutely need to fix any Error messages. You can also run rpmlint on an rpm package or on an installed package.
BASH:~/-> rpmlint mousepad
mousepad.i686: W: name-repeated-in-summary C Mousepad
mousepad.i686: W: spelling-error %description -l en_US selecton -> selection, selector, select on
mousepad.i686: W: spelling-error %description -l en_US codesets -> code sets, code-sets, codes
mousepad.i686: W: spelling-error %description -l en_US codeset -> code set, code-set, code's
1 packages and 0 specfiles checked; 0 errors, 4 warnings.

Partizanske - Nanao Instagram Photos - Qir Moav Photos on Instagram