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-07-13 18:58:39 +00:00
|
|
|
. ${./functions.sh}
|
|
|
|
propagateImageName
|
2014-11-05 17:21:44 +00:00
|
|
|
src=$(findTarball $src)
|
2012-07-13 18:58:39 +00:00
|
|
|
'';
|
2008-11-25 00:20:51 +00:00
|
|
|
|
|
|
|
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[*]}..."
|
2012-07-14 06:20:33 +00:00
|
|
|
rpm -Up ''${rpms[*]} --excludepath /nix/store
|
2012-05-31 13:50:47 +00:00
|
|
|
|
2012-05-01 20:31:01 +00:00
|
|
|
eval "$postRPMInstall"
|
2013-03-01 11:50:29 +00:00
|
|
|
|
2012-05-31 13:50:47 +00:00
|
|
|
echo "uninstalling ''${rpmNames[*]}..."
|
2012-07-14 06:27:09 +00:00
|
|
|
rpm -e ''${rpmNames[*]} --nodeps
|
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
|
2013-03-01 11:50:29 +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
|
2020-03-22 00:15:09 +00:00
|
|
|
'';
|
2008-11-25 00:20:51 +00:00
|
|
|
|
2008-11-26 14:34:29 +00:00
|
|
|
meta = (if args ? meta then args.meta else {}) // {
|
2013-03-01 11:50:29 +00:00
|
|
|
description = "RPM package for ${diskImage.fullName}";
|
2008-11-25 00:20:51 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
)
|