1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-05 03:53:41 +00:00
nixpkgs/pkgs/build-support/release/debian-build.nix
Profpatsch 28f8ca560f debian-build: fix checkinstall invocation (#15538)
Checkinstall had two problems:
1. when it was called without a version (e.g. with a derivation created
by fetchFromGitHub) it would use `src` as debian version, which caused
dpkg to fail
2. when dpkg failed, it would invoke the pager with the log, which hangs
the build

So now
1. the default version is the dummy `0.0.0`
2. the used pager is `cat`
2016-05-19 09:41:10 +01:00

99 lines
2.7 KiB
Nix

# This function compiles a source tarball in a virtual machine image
# that contains a Debian-like (i.e. dpkg-based) OS.
{ name ? "debian-build"
, diskImage
, src, stdenv, vmTools, checkinstall
, fsTranslation ? false
, # Features provided by this package.
debProvides ? []
, # Features required by this package.
debRequires ? []
, ... } @ args:
with stdenv.lib;
vmTools.runInLinuxImage (stdenv.mkDerivation (
{
doCheck = true;
prefix = "/usr";
prePhases = "installExtraDebsPhase sysInfoPhase";
}
// removeAttrs args ["vmTools"] //
{
name = name + "-" + diskImage.name + (if src ? version then "-" + src.version else "");
# !!! cut&paste from rpm-build.nix
postHook = ''
. ${./functions.sh}
propagateImageName
src=$(findTarball $src)
'';
installExtraDebsPhase = ''
for i in $extraDebs; do
dpkg --install $(ls $i/debs/*.deb | sort | head -1)
done
'';
sysInfoPhase = ''
[ ! -f /etc/lsb-release ] || (source /etc/lsb-release; echo "OS release: $DISTRIB_DESCRIPTION")
echo "System/kernel: $(uname -a)"
if test -e /etc/debian_version; then echo "Debian release: $(cat /etc/debian_version)"; fi
header "installed Debian packages"
dpkg-query --list
stopNest
'';
installPhase = ''
eval "$preInstall"
export LOGNAME=root
# otherwise build hangs when it wants to display
# the log file
export PAGER=cat
${checkinstall}/sbin/checkinstall --nodoc -y -D \
--fstrans=${if fsTranslation then "yes" else "no"} \
--requires="${concatStringsSep "," debRequires}" \
--provides="${concatStringsSep "," debProvides}" \
${if (src ? version) then "--pkgversion=$(echo ${src.version} | tr _ -)"
else "--pkgversion=0.0.0"} \
''${debMaintainer:+--maintainer="'$debMaintainer'"} \
''${debName:+--pkgname="'$debName'"} \
$checkInstallFlags \
-- \
$SHELL -c "''${installCommand:-make install}"
mkdir -p $out/debs
find . -name "*.deb" -exec cp {} $out/debs \;
[ "$(echo $out/debs/*.deb)" != "" ]
for i in $out/debs/*.deb; do
header "Generated DEB package: $i"
dpkg-deb --info "$i"
pkgName=$(dpkg-deb -W "$i" | awk '{print $1}')
dpkg -i "$i"
echo "file deb $i" >> $out/nix-support/hydra-build-products
stopNest
done
for i in $extraDebs; do
echo "file deb-extra $(ls $i/debs/*.deb | sort | head -1)" >> $out/nix-support/hydra-build-products
done
eval "$postInstall"
''; # */
meta = (if args ? meta then args.meta else {}) // {
description = "Deb package for ${diskImage.fullName}";
};
}
))