core/pkgs/build-support/release/rpm-build.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

60 lines
1.5 KiB
Nix
Raw Normal View History

2024-05-02 00:46:19 +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').
{
name ? "rpm-build",
diskImage,
src,
lib,
vmTools,
...
}@args:
vmTools.buildRPM (
removeAttrs args [ "vmTools" ]
//
2024-06-30 08:12:46 +00:00
2024-05-02 00:46:19 +00:00
{
name = name + "-" + diskImage.name + (lib.optionalString (src ? version) "-${src.version}");
2024-06-30 08:12:46 +00:00
2024-05-02 00:46:19 +00:00
preBuild = ''
. ${./functions.sh}
propagateImageName
src=$(findTarball $src)
'';
2024-06-30 08:12:46 +00:00
2024-05-02 00:46:19 +00:00
postInstall = ''
declare -a rpms rpmNames
for i in $out/rpms/*/*.rpm; do
if echo $i | grep -vq "\.src\.rpm$"; then
echo "file rpm $i" >> $out/nix-support/hydra-build-products
rpms+=($i)
rpmNames+=("$(rpm -qp "$i")")
fi
done
2024-06-30 08:12:46 +00:00
2024-05-02 00:46:19 +00:00
echo "installing ''${rpms[*]}..."
rpm -Up ''${rpms[*]} --excludepath /nix/store
2024-06-30 08:12:46 +00:00
2024-05-02 00:46:19 +00:00
eval "$postRPMInstall"
2024-06-30 08:12:46 +00:00
2024-05-02 00:46:19 +00:00
echo "uninstalling ''${rpmNames[*]}..."
rpm -e ''${rpmNames[*]} --nodeps
2024-06-30 08:12:46 +00:00
2024-05-02 00:46:19 +00:00
for i in $out/rpms/*/*.src.rpm; do
echo "file srpm $i" >> $out/nix-support/hydra-build-products
done
2024-06-30 08:12:46 +00:00
2024-05-02 00:46:19 +00:00
for rpmdir in $extraRPMs ; do
echo "file rpm-extra $(ls $rpmdir/rpms/*/*.rpm | grep -v 'src\.rpm' | sort | head -1)" >> $out/nix-support/hydra-build-products
done
'';
2024-06-30 08:12:46 +00:00
2024-05-02 00:46:19 +00:00
meta = (lib.optionalAttrs (args ? meta) args.meta) // {
description = "RPM package for ${diskImage.fullName}";
};
}
)