2008-11-24 16:20:51 -08:00
|
|
|
# This function compiles a source tarball in a virtual machine image
|
2008-11-24 18:26:54 -08:00
|
|
|
# that contains a Debian-like (i.e. dpkg-based) OS.
|
2008-11-24 16:20:51 -08:00
|
|
|
|
2009-03-02 05:45:48 -08:00
|
|
|
{ name ? "debian-build"
|
|
|
|
, diskImage
|
|
|
|
, src, stdenv, vmTools, checkinstall
|
2009-09-23 13:10:39 -07:00
|
|
|
, fsTranslation ? false
|
2009-11-05 06:40:25 -08:00
|
|
|
, # Features provided by this package.
|
|
|
|
debProvides ? []
|
|
|
|
, # Features required by this package.
|
|
|
|
debRequires ? []
|
2009-03-02 05:45:48 -08:00
|
|
|
, ... } @ args:
|
2008-11-24 16:20:51 -08:00
|
|
|
|
2012-01-03 14:33:48 -08:00
|
|
|
with stdenv.lib;
|
|
|
|
|
2008-11-24 16:20:51 -08:00
|
|
|
vmTools.runInLinuxImage (stdenv.mkDerivation (
|
|
|
|
|
|
|
|
{
|
2011-10-11 02:13:31 -07:00
|
|
|
doCheck = true;
|
2008-11-24 16:20:51 -08:00
|
|
|
|
2008-11-24 18:20:41 -08:00
|
|
|
prefix = "/usr";
|
2008-11-24 16:20:51 -08:00
|
|
|
|
2016-12-30 14:13:04 -08:00
|
|
|
prePhases = "installExtraDebsPhase sysInfoPhase";
|
|
|
|
}
|
|
|
|
|
|
|
|
// removeAttrs args ["vmTools"] //
|
|
|
|
|
|
|
|
{
|
|
|
|
name = name + "-" + diskImage.name + (if src ? version then "-" + src.version else "");
|
2009-03-02 05:45:48 -08:00
|
|
|
|
2008-11-24 16:20:51 -08:00
|
|
|
# !!! cut&paste from rpm-build.nix
|
|
|
|
postHook = ''
|
2012-07-13 11:58:39 -07:00
|
|
|
. ${./functions.sh}
|
|
|
|
propagateImageName
|
2014-11-05 09:21:44 -08:00
|
|
|
src=$(findTarball $src)
|
2012-07-13 11:58:39 -07:00
|
|
|
'';
|
2008-11-24 16:20:51 -08:00
|
|
|
|
2008-11-24 18:20:41 -08:00
|
|
|
installExtraDebsPhase = ''
|
|
|
|
for i in $extraDebs; do
|
2009-10-01 00:25:50 -07:00
|
|
|
dpkg --install $(ls $i/debs/*.deb | sort | head -1)
|
2008-11-24 18:20:41 -08:00
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
2008-11-24 16:20:51 -08:00
|
|
|
sysInfoPhase = ''
|
2011-02-14 08:52:32 -08:00
|
|
|
[ ! -f /etc/lsb-release ] || (source /etc/lsb-release; echo "OS release: $DISTRIB_DESCRIPTION")
|
2008-11-24 16:20:51 -08:00
|
|
|
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
|
|
|
|
'';
|
|
|
|
|
2009-06-02 01:11:40 -07:00
|
|
|
installPhase = ''
|
2014-02-06 05:21:58 -08:00
|
|
|
eval "$preInstall"
|
2008-12-10 09:12:19 -08:00
|
|
|
export LOGNAME=root
|
2009-03-02 05:45:48 -08:00
|
|
|
|
2016-05-19 01:41:10 -07:00
|
|
|
# otherwise build hangs when it wants to display
|
|
|
|
# the log file
|
|
|
|
export PAGER=cat
|
2009-09-23 13:10:39 -07:00
|
|
|
${checkinstall}/sbin/checkinstall --nodoc -y -D \
|
|
|
|
--fstrans=${if fsTranslation then "yes" else "no"} \
|
2012-01-03 14:33:48 -08:00
|
|
|
--requires="${concatStringsSep "," debRequires}" \
|
|
|
|
--provides="${concatStringsSep "," debProvides}" \
|
2016-05-19 01:41:10 -07:00
|
|
|
${if (src ? version) then "--pkgversion=$(echo ${src.version} | tr _ -)"
|
|
|
|
else "--pkgversion=0.0.0"} \
|
2014-02-06 05:21:58 -08:00
|
|
|
''${debMaintainer:+--maintainer="'$debMaintainer'"} \
|
2014-08-08 05:15:05 -07:00
|
|
|
''${debName:+--pkgname="'$debName'"} \
|
2014-02-06 05:21:58 -08:00
|
|
|
$checkInstallFlags \
|
2014-08-08 05:15:05 -07:00
|
|
|
-- \
|
|
|
|
$SHELL -c "''${installCommand:-make install}"
|
2008-11-24 18:20:41 -08:00
|
|
|
|
2012-01-18 12:16:00 -08:00
|
|
|
mkdir -p $out/debs
|
2008-11-24 18:20:41 -08:00
|
|
|
find . -name "*.deb" -exec cp {} $out/debs \;
|
|
|
|
|
2012-01-03 14:25:46 -08:00
|
|
|
[ "$(echo $out/debs/*.deb)" != "" ]
|
|
|
|
|
2008-11-24 18:20:41 -08:00
|
|
|
for i in $out/debs/*.deb; do
|
|
|
|
header "Generated DEB package: $i"
|
2009-03-26 08:45:37 -07:00
|
|
|
dpkg-deb --info "$i"
|
|
|
|
pkgName=$(dpkg-deb -W "$i" | awk '{print $1}')
|
2008-11-24 18:20:41 -08:00
|
|
|
echo "file deb $i" >> $out/nix-support/hydra-build-products
|
|
|
|
stopNest
|
|
|
|
done
|
2018-02-19 04:27:34 -08:00
|
|
|
dpkg -i $out/debs/*.deb
|
2009-10-01 05:12:45 -07:00
|
|
|
|
|
|
|
for i in $extraDebs; do
|
2009-10-02 02:49:53 -07:00
|
|
|
echo "file deb-extra $(ls $i/debs/*.deb | sort | head -1)" >> $out/nix-support/hydra-build-products
|
2009-10-01 05:12:45 -07:00
|
|
|
done
|
|
|
|
|
2016-12-30 14:13:04 -08:00
|
|
|
eval "$postInstall"
|
2020-03-21 17:15:09 -07:00
|
|
|
'';
|
2008-11-24 18:20:41 -08:00
|
|
|
|
2008-11-26 06:34:29 -08:00
|
|
|
meta = (if args ? meta then args.meta else {}) // {
|
2013-03-01 03:50:29 -08:00
|
|
|
description = "Deb package for ${diskImage.fullName}";
|
2008-11-24 16:20:51 -08:00
|
|
|
};
|
2016-12-30 14:13:04 -08:00
|
|
|
}
|
2008-11-24 16:20:51 -08:00
|
|
|
|
|
|
|
))
|