Выбрать главу

The menu categories under which this entry will appear

Encoding

The character encoding used for this entry

Exec

The name of the command to be executed when this menu entry is selected

Icon

The name of the icon file

StartupNotify

Whether this icon supports the xdg startup notification protocol , which is used to manage a visual indication that the application is in the process of starting up

Terminal

Whether the application should be run in an terminal window (for nongraphical programs)

Type

Indicates that the program is a standalone application

The extended %install section looks like this:

%install

rm -rf %{buildroot}

%makeinstall

mkdir -p %{buildroot}%{_datadir}/icons

install -m 744 critter.png %{buildroot}%{_datadir}/icons/critter.png

mkdir -p %{buildroot}%{_datadir}/applications

echo "[Desktop Entry]

Name= Critical Mass

Comment= Shoot-em-up Game

Categories=Application; Game

Encoding=UTF-8

Exec =critter

Icon =critter.png

StartupNotify= true

Terminal= False

Type=Application" > %{buildroot}%{_datadir}/applications/CriticalMass.desktop

It is also necessary to modify the %files section to include the icon and .desktop file:

%files

%defattr(-, root, root)

%doc COPYING TODO

%{_bindir}/*

%{_datadir}/Critical_Mass

%{_mandir}/man?/*

%{_datadir}/applications/*

%{_datadir}/icons/*

5.7.3.2. ...running a script when a package is installed or removed?

This can be done by specifying a %pre , %post , %preun , or %postun section. The difference between these sections is in when they designate the script to run: before installation ( %pre ), after installation ( %post ), before removal ( %preun ), or after removal ( %postun ).

As a simple example, if your script contains shared object libraries ( .so files), you should run ldconfig after installation and after removaclass="underline"

%post

/sbin/ldconfig

%postun

/bin/ldconfig

In this case, you should add a Requires tag to the preamble:

Requires: /sbin/ldconfig

5.7.3.3. ...including an icon to identify the package?

A package icon can be included; graphical installation tools can pick up this icon and display it instead of a generic package icon. Place the icon in the same directory as the tarball, and create an Icon tag in the preamble:

Icon: CriticalMass.xpm

The icon should be in XPM format. You can use convert to make an XPM file from a file in another format:

$ convert critter.png critter.xpm

5.7.3.4. ...viewing the source code and the spec file for an existing package?

This is an excellent way to learn about writing advanced spec files. You don't even need root privileges to open and view the files!

After downloading the source RPM for a package ( .src.rpm file), install it in the normal way:

$ rpm -ivh ImageMagick-6.2.2.0-2.src.rpm

1:ImageMagick ########################################### [100%]

The files will be installed into ~/rpm/ name in this case, ~/rpm/ImageMagick :

$ ls ~/rpm/ ImageMagick

ImageMagick-5.5.6-mask.patch

ImageMagick-6.2.0-compress.patch

ImageMagick-6.2.1-fixed.patch

ImageMagick-6.2.1-hp2xx.patch

ImageMagick-6.2.1-local_doc.patch

ImageMagick-6.2.1-pkgconfig.patch

ImageMagick-6.2.2-0.tar.bz2

ImageMagick.spec

magick_small.png

5.7.4. Where Can I Learn More?

 The Fedora RPM guide: http://fedora.redhat.com/docs/drafts/rpm-guide-en/ (that's a draft version; the final version is expected to be posted at http://fedora.redhat.com/docs/rpm-guide-en/ )

Maximum RPM : http://www.rpm.org/max-rpm-snapshot/

The Fight , an RPM guide by Matthias Saou: http://freshrpms.net/docs/fight/

 IBM DeveloperWorks article on creating RPM packages: http://www-128.ibm.com/developerworks/library/l-rpm1/

5.8. Rebuilding an RPM Package for a Different Architecture

Sometimes you'll find an RPM has been prepared that would be perfect for your systemexcept that the RPM was built for a machine of a different architecture. This can be frustrating, but if you can obtain the source RPM, it's a fairly simple matter to make a binary RPM that is tuned to your system.

5.8.1. How Do I Do That?

Assuming that you have set up your ~/.rpmmacros file (see Lab 5.7, "Making Your Own RPM Packages "), simply obtain a source RPM file, and then execute rpmbuild with the --rebuild option:

$ rpmbuild --rebuild

$ rpmbuild --rebuild ImageMagick*.src.rpm

Installing ImageMagick-6.2.2.0-2.src.rpm

Executing(%prep): /bin/sh -e /home/chris/rpm/tmp/rpm-tmp.32955

+ umask 022

+ cd /home/chris/rpm/tmp

...(Lines snipped)...

Executing(--clean): /bin/sh -e /home/chris/rpm/tmp/rpm-tmp.88067

+ umask 022

+ cd /home/chris/rpm/tmp

+ rm -rf ImageMagick-6.2.2

+ exit 0

The new RPM packages will be found in ~/rpm/RPMS/ .