3. Preliminary tasks

3.1. Create required folders

To build packages, rpm needs a special tree in your home directory. This tree can be created with the following command: mkdir -p ~/rpm/{BUILD,RPMS/$ARCH,RPMS/noarch,SOURCES,SRPMS,SPECS,tmp}. Replace $ARPH with the architecture(s) you plan to build packages for, basically this can be i586 but also sparc/alpha/ppc.

Warning

Building RPM's as root is dangerous, because the binary files are installed on the system before being packaged, thus you must always build as normal user so you won't accidentally pollute your system.

Make sure that the tree is of the form :

~/rpm/BUILD

The directory where the building of sources is done.

~/rpm/RPMS

The binary packages after building, sorted by target architecture.

~/rpm/RPMS/i586

The directory where i586.rpm packages will be stored.

~/rpm/RPMS/noarch

Idem for noarch packages.

~/rpm/SOURCES

The source files (mypackage.tar.bz2 for example).

~/rpm/SPECS

The spec files we will have to construct.

~/rpm/SRPMS

The source rpm after building.

~/rmp/tmp

For temporary stuff that rpm will create when building your packages.

Note

The architecture directories under /RPMS are necessary to rpm. If they are not present, you'll get an error message.

3.2. Add configuration files

In order to build packages for Mandrake Linux, you will need to add two configuration files in your home directory:

.rpmrc

buildarchtranslate: i386: i586
buildarchtranslate: i486: i586
buildarchtranslate: i586: i586
buildarchtranslate: i686: i586


.rpmmacros

%_topdir               YOUR_HOME_DIR/rpm
%_tmppath              YOUR_HOME_DIR/rpm/tmp

%_signature            gpg
%_gpg_name             Mandrake Linux
%_gpg_path             ~/.gnupg
%distribution          Mandrake Linux
%vendor                MandrakeSoft

which you will have to edit to fit your name and directory.

Warning, don't set %optflags, as one is already provided for you in the system-wide /usr/lib/rpm/rpmrc.

In the same way, don't set %packager, so that rebuilding other people's packages won't put yourself in the Packager: field of the RPM, possibly in a public release which would direct bug reports to you instead of maintainer.

Your rpm program is then setup to build packages.

3.3. Subscribe to mailing lists

Mandrake's lists (Consult Mailing list pages on Mandrake Linux pages):