RPM can now be used to build packages for the Intel i386, the Digital
Alpha running Linux, and the Sparc. It has been reported to work
on SGI's and HP workstations as well. There are several features that
make building packages on all platforms easy. The first of these is
the ``optflags'' directive in the /etc/rpmrc
. It can be used to
set flags used when building software to architecture specific values.
Another feature is the ``arch'' macros in the spec file. They can be used
to do different things depending on the architecture you are building on.
Another feature is the ``Exclude'' directive in the header.
The following is the spec file for the ``zoneinfo'' package. It is setup to build on both the Alpha and the Intel.
Description: Time zone utilities and data
Name: zoneinfo
Version: 95e
Release: 2
Copyright: Distributable
Group: Utilities/System
Source0: elsie.nci.nih.gov:/pub/tzcode95e.tar.gz
Source1: elsie.nci.nih.gov:/pub/tzdata95i.tar.gz
Patch0: zoneinfo-95e-make.patch
Patch1: zoneinfo-95e-64bit.patch
%prep
%setup -c -a 1
%patch0 -p1
%ifarch axp
%patch1 -p1
%endif
%build
make RPM_OPT_FLAGS="${RPM_OPT_FLAGS}"
%install
rm -rf /usr/lib/zoneinfo
make install
rm -f /usr/lib/zoneinfo/localtime /usr/lib/zoneinfo/posixrules /usr/lib/zoneinfo/posixtime
ln -sf ../../../etc/localtime /usr/lib/zoneinfo/localtime
ln -sf localtime /usr/lib/zoneinfo/posixrules
ln -sf localtime /usr/lib/zoneinfo/posixtime
strip /usr/sbin/zic /usr/sbin/zdump
%files
%doc README Theory
/usr/lib/zoneinfo
/usr/lib/libz.a
/usr/sbin/zic
/usr/sbin/zdump
/usr/man/man3/newctime.3
/usr/man/man3/newtzset.3
/usr/man/man5/tzfile.5
/usr/man/man8/zdump.8
/usr/man/man8/zic.8
In this example, you see how the ``optflags'' directive is used from
the /etc/rpmrc
. Depending on which architecture you are building
on, the proper value is given to RPM_OPT_FLAGS
. You must patch
the Makefile for your package to use this variable in place of the
normal directives you might use (like -m486
and -O2
). You can
get a better feel for what needs to be done by installing this
source package and then unpacking the source and examine the Makefile.
Then look at the patch for the Makefile and see what changes must be
made.
The %ifarch
macro is very important to all of this. Most times you
will need to make a patch or two that is specific to one architecture
only. In this case, RPM will allow you to apply that patch to just
one architecture only.
In the above example, zoneinfo has a patch for 64 bit machines. Obviously,
this should only be applied on the Alpha at the moment. So, we add
an %ifarch
macro around the 64 bit patch like so:
%ifarch axp
%patch1 -p1
%endif
This will insure that the patch is not applied on any architecture
except the alpha.
So that you can maintain source RPMs in one directory for all platforms, we have implemented the ability to ``exclude'' packages from being built on certain architectures. This is so you can still do things like
rpm --rebuild /usr/src/SRPMS/*.rpm
and have the right packages build. If you haven't yet ported an application
to a certain platform, all you have to do is add a line like:
Exclude: axp
to the header of the spec file of the source package. Then rebuild the package
on the platform that it does build on. You'll then have a source package
that builds on an Intel and can easily be skipped on an Alpha.
Using RPM to make multi-architectural packages is usually easier to do than getting the package itself to build both places. As more of the hard packages get built this is getting much easier, however. As always, the best help when you get stuck building an RPM is to look a similar source package.
Next Chapter, Previous Chapter
Table of contents of this chapter, General table of contents
Top of the document, Beginning of this Chapter