Mandrake RPM HOWTO Bernhard Rosenkraenzer v0.1.1, 31 March 1999 ______________________________________________________________________ 1. Introduction This HOWTO describes how to build an RPM package for the Mandrake Linux distribution (http://www.linux-mandrake.com/). It is intended for people already familiar with building RPMs; if you don't know how to build an RPM, have a look at the RPM HOWTO (most distributions have this in /usr/doc/HOWTO/RPM-HOWTO). The instructions here are for Mandrake 6.0 or higher. 2. Adapting a RPM from a different distribution to Mandrake If you already have a Source RPM from a different distribution, such as Red Hat, you can build a Mandrake RPM with a few minor modifications: 2.1. BuildRoot Some old RPMs are not using a "BuildRoot:" field in the .spec file; in this case, the package will be installed in your root filesystem during installation. This is a bad thing, because it makes it almost impossible to verify the functionality of the RPM, and it messes up the system the RPM is being built on. If your RPM doesn't have a BuildRoot, add it. 2.2. Release number To let users know the RPM has been designed for use with Mandrake, add "mdk" to the Release number ("Release: " field in the .spec file) The "mdk" should go after the release number (i.e. Release: 1mdk). 2.3. bzip2 man/info pages To save both diskspace and download time, Mandrake uses bzip2 to compress man- and info-pages. The easiest way to achieve this is to add find $RPM_BUILD_ROOT/usr/man -type f -exec bzip2 -9f {} \; find $RPM_BUILD_ROOT/usr/info -type f -exec bzip2 -9f {} \; at the end of the %install section of the .spec file. If the RPM you're trying to convert is using gzip'ed man- and info-pages, you might have to add find $RPM_BUILD_ROOT/usr/man -name "*.gz" -exec gunzip {} \; find $RPM_BUILD_ROOT/usr/info -name "*.gz" -exec gunzip {} \; prior to the other find commands. You might need to adapt the %files section, and the %post and %postun sections. 2.4. Optimization Since Mandrake comes in several different versions with optimizations for different CPUs, it is important that your RPM handles the RPM_OPT_FLAGS variable by passing it to the C compiler. (Many RPMs from other distributions already do this, some RPMs ignore the variable, though). For autoconf'ed packages, the best way to do this is to replace ./configure --something with CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" ./configure --something For packages using xmkmf, replace make with make CDEBUGFLAGS="$RPM_OPT_FLAGS" CXXDEBUGFLAGS="$RPM_OPT_FLAGS" For other packages, you should have a look at the Makefile to see how you can do it - in many (but not all) cases, make CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" is a solution. If you want to provide a binary package along with your source RPM, please use pgcc 1.1.2 as compiler, with the following RPM_OPT_FLAGS settings: For the generic (386+) version: -O2 -fomit-frame-pointer -fno-exceptions -fno-rtti -pipe -s -mcpu=i486 For the Pentium version: -O2 -fomit-frame-pointer -fno-exceptions -fno-rtti -pipe -s -mcpu=pentium -march=pentium -ffast-math -mieee-fp -fexpensive-optimizations -malign-loops=2 -malign-jumps=2 -malign-functions=2 For the Pentium Pro/Pentium 2/Pentium 3 version: -O2 -fomit-frame-pointer -fno-exceptions -fno-rtti -pipe -s -mcpu=pentiumpro -march=pentiumpro -ffast-math -mieee-fp -fexpensive-optimizations For the K6 version: -O2 -fomit-frame-pointer -fno-exceptions -fno-rtti -pipe -s -mcpu=amdk6 -march=amdk6 -ffast-math -mieee-fp -fexpensive-optimizations For the Cyrix 6x86MX version: -O2 -fomit-frame-pointer -fno-exceptions -fno-rtti -pipe -s -mcpu=cyrix6x86 -march=pentiumpro -ffast-math -mieee-fp -fexpensive-optimizations We are providing a build script that automatically takes care of compiling with these optimizations (it will automatically generate RPMs for every version we're supporting). It can be downloaded at ftp://ftp.mandrakesoft.com/pub/bero/build 2.5. Recompress the sources (optional) We prefer having the source files and patches bzip2'ed - this doesn't affect the generated binary RPMs, but makes the SRPM shorter, saving download time. 2.6. Paths Textmode applications should go to /usr, textmode games to /usr/games. X11 stuff should go to /usr/X11R6, with the exception being KDE and GNOME stuff, which goes to /usr. (We are aware of the fact that this violates all standards and is a stupid idea, but we want to be 100% backwards compatible with Red Hat, so we have to take over their directory structure.) Configuration files should go to /etc - for some autoconf'ed applications, ./configure --sysconfdir=/etc takes care of this - other applications might require Makefile changes and/or source hacking. 2.7. Upload it! You can upload your RPMs to ftp.linux-mandrake.com/incoming when you've finished them. 3. Location of this HOWTO / Comments / Feedback The most current version of this HOWTO can be found at ftp://ftp.mandrakesoft.com/pub/bero/Mandrake-RPM-HOWTO.bz2 You can read it in your favorite editor after decompressing it using bunzip2 Mandrake-RPM-HOWTO.bz2 If you have any comments/suggestions for this HOWTO, you can contact me at bero@linux-mandrake.com.