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