create rpm packages on a debian machine

Date Tags rpm

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).


generate hdlist/sysnthesis files on a debian system

Date Tags perl / rpm

Imagine you want to create hdlist/sysnthesis files from a bunch of rpms on a debian system. If you know what you need it is not actually that difficult. The mandriva svn contains the tool genhdlist2. To use it on a debian machine we need to download and install two perl modules that are contained in the same directory as above, namely, perl-URPMI and MDV-Packdrakeng. The tool we want to use is in the rpmtools directory. You can svn checkout everything from http://svn.mandriva.com/svn/soft/rpm .

Once downloaded everything you would either need to install these perl libraries system-wide (bad idea…) or locally and to fiddle a bit with the genhdlist2 script in order to specify the location of these two libraries. Personally I added these two lines at the beginning of the file :

use lib '/tmp/perl-URPM/trunk/blib/lib';
use lib '/tmp/MDV-Packdrakeng/trunk/lib';

Make also sure that you compile the URPMI.so component of the perl library and copy it to the lib directory.

Now you are ready to generate your hdlist/systhesis files just by giving a directory with all the rpms to the tool as in perl genhdlist2 rpms

et voila.

Update

I’ve committed the script and supporting modules here if you are interested. To access the forge you need a username/password: you can use mancoosi/mancoosi if you want anonymous access.