2008-11-25 00:20:51 +00:00
|
|
|
# This function builds an RPM from a source tarball that contains a
|
|
|
|
# RPM spec file (i.e., one that can be built using `rpmbuild -ta').
|
|
|
|
|
2009-03-02 13:45:48 +00:00
|
|
|
{ name ? "rpm-build"
|
|
|
|
, diskImage
|
|
|
|
, src, vmTools
|
|
|
|
, ... } @ args:
|
2008-11-25 00:20:51 +00:00
|
|
|
|
|
|
|
vmTools.buildRPM (
|
|
|
|
|
2009-03-02 13:45:48 +00:00
|
|
|
removeAttrs args ["vmTools"] //
|
2008-11-25 00:20:51 +00:00
|
|
|
|
|
|
|
{
|
2009-03-02 14:33:33 +00:00
|
|
|
name = name + "-" + diskImage.name + (if src ? version then "-" + src.version else "");
|
2009-03-02 13:45:48 +00:00
|
|
|
|
2008-11-25 00:20:51 +00:00
|
|
|
preBuild = ''
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $out/nix-support
|
2008-11-25 00:20:51 +00:00
|
|
|
cat "$diskImage"/nix-support/full-name > $out/nix-support/full-name
|
|
|
|
|
|
|
|
# If `src' is the result of a call to `makeSourceTarball', then it
|
|
|
|
# has a subdirectory containing the actual tarball(s). If there are
|
|
|
|
# multiple tarballs, just pick the first one.
|
|
|
|
if test -d $src/tarballs; then
|
|
|
|
src=$(ls $src/tarballs/*.tar.bz2 $src/tarballs/*.tar.gz | sort | head -1)
|
|
|
|
fi
|
|
|
|
''; # */
|
|
|
|
|
|
|
|
postInstall = ''
|
2012-05-31 13:50:47 +00:00
|
|
|
declare -a rpms rpmNames
|
2008-11-25 00:20:51 +00:00
|
|
|
for i in $out/rpms/*/*.rpm; do
|
2009-10-23 13:41:11 +00:00
|
|
|
if echo $i | grep -vq "\.src\.rpm$"; then
|
2009-10-21 13:34:17 +00:00
|
|
|
echo "file rpm $i" >> $out/nix-support/hydra-build-products
|
2012-05-31 13:50:47 +00:00
|
|
|
rpms+=($i)
|
|
|
|
rpmNames+=("$(rpm -qp "$i")")
|
2012-05-01 20:31:01 +00:00
|
|
|
fi
|
|
|
|
done
|
2012-03-19 13:40:57 +00:00
|
|
|
|
2012-05-31 13:50:47 +00:00
|
|
|
echo "installing ''${rpms[*]}..."
|
|
|
|
rpm -ip ''${rpms[*]} --excludepath /nix/store
|
|
|
|
|
2012-05-01 20:31:01 +00:00
|
|
|
eval "$postRPMInstall"
|
|
|
|
|
2012-05-31 13:50:47 +00:00
|
|
|
echo "uninstalling ''${rpmNames[*]}..."
|
|
|
|
rpm -e ''${rpmNames[*]}
|
2012-05-01 20:31:01 +00:00
|
|
|
|
2009-10-21 13:34:17 +00:00
|
|
|
for i in $out/rpms/*/*.src.rpm; do
|
|
|
|
echo "file srpm $i" >> $out/nix-support/hydra-build-products
|
2008-11-25 00:20:51 +00:00
|
|
|
done
|
2012-03-19 13:40:57 +00:00
|
|
|
|
2009-10-01 19:25:08 +00:00
|
|
|
for rpmdir in $extraRPMs ; do
|
2009-10-02 09:49:53 +00:00
|
|
|
echo "file rpm-extra $(ls $rpmdir/rpms/*/*.rpm | grep -v 'src\.rpm' | sort | head -1)" >> $out/nix-support/hydra-build-products
|
2009-10-01 19:25:08 +00:00
|
|
|
done
|
2008-11-25 00:20:51 +00:00
|
|
|
''; # */
|
|
|
|
|
2008-11-26 14:34:29 +00:00
|
|
|
meta = (if args ? meta then args.meta else {}) // {
|
2009-03-02 13:45:48 +00:00
|
|
|
description = "Build of an RPM package on ${diskImage.fullName} (${diskImage.name})";
|
2008-11-25 00:20:51 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
)
|