create rpm packages on a debian machine

This gave me a bit of an headache ... Why on earth rpmbuild does not simply respect environment variables nor have a command line option to specify the TEMPDIR used to build the package or simply look for a simple configuration file in the local directory ? From command line you can only specify --buildroot . For everything else you must specify a global file called .rpmmacros (not .rpmrc !) and write the new defaults there. This must be either in your home, or in /etc (other other rpm specific paths). Anyway ... enough for this rant. This is the hack to create a local build environment :

#!/bin/bash

RPMBUILD=`pwd`/rpmbuild
RPMMACROS="$HOME/.rpmmacros"

if [ -f $RPMMACROS ] ; then
  cp $RPMMACROS $RPMMACROS~
fi

echo "%_topdir  $RPMBUILD" > $RPMMACROS
echo "%_tmppath $RPMBUILD/tmp" >> $RPMMACROS
echo "%_rpmdir `pwd`/RPMS" >> $RPMMACROS
echo "%mkrel(c:) %(echo mdv20010)" >> $RPMMACROS

mkdir -p rpmbuild/{SRPMS,BUILD,RPMS,SPECS,tmp}

The mkrel part is something else that is needed if you want to build a package that resemble a mandriva package ... The rpm package in debian does not include this macro by default.

I'm using the rpmbuild part of the rpm package on debian sid (RPM version 4.7.2).

Average: 1.2 (13 votes)

Comments

Fixes to the code: echo

Fixes to the code:

 echo "%_rpmdir `pwd`/RPMS" >> $RPMMACROS
should be
 echo "%_rpmdir $RPMBUILD/RPMS" >> $RPMMACROS
SRPM gets built with only the spec file and no files from the BUILDROOT

RPM gets built correctly

Sometimes we get an error like:

 error: Couldn't exec /usr/lib/rpm/fontconfig.prov: No such file or directory
 Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Yet the rpm gets compiled correctly.

Everytime we get: unknown, 0: Warning: using regular magic file `/etc/magic'.