3 Oct 2008 richdawe   » (Journeyer)

Knowing what rpms you've just built

One idiom I've found myself repeating in various projects is a build-all script that builds multiple rpm packages in a certain order. This isn't very sophisticated -- each time I've ordered the packages being built manually.

But how do you know what rpms you will get, when you run rpmbuild? You need to know this, so you can install the rpms. Here is a solution:

specfile=project.spec

RPMDIR=$(rpm --eval '%{_rpmdir}')

# What format does rpm use for built binary rpms?
# %{ARCH}/%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}.rpm
BUILD_NAME_FMT=`rpm --eval '%{_build_name_fmt}'`

rpms=$(rpm -q --specfile $specfile --queryformat "$BUILD_NAME_FMT ")

pushd $RPMDIR
rpm -ivh $rpms
popd

This works as follows: get the rpm root directory into $RPMDIR; find the format rpmbuild uses for built binary rpms; query the rpm specfile for packages and format the results using the build rpm filename format; finally, go into the rpm root and install all the binary rpms.

Syndicated 2008-10-03 08:45:23 from richdawe

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!