From c90bd0756cbfe1225666a096b580d32c0101fda2 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 25 Nov 2008 02:20:41 +0000 Subject: [PATCH] * Automatically build Debian packages using checkinstall, as suggested by Pjotr Prins a while back. This could also be used to generate RPMs for packages that don't have a spec-file. * Added checkinstall to Nixpkgs. However we don't use our own build yet because with it "make install" segfaults in a Debian VM, while the pre-built binary does work. svn path=/nixpkgs/trunk/; revision=13400 --- pkgs/build-support/release/debian-build.nix | 35 ++++++++++++++++--- pkgs/build-support/release/default.nix | 2 +- pkgs/build-support/vm/default.nix | 4 +++ .../checkinstall/default.nix | 24 +++++++++++++ pkgs/top-level/all-packages.nix | 4 +++ 5 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 pkgs/tools/package-management/checkinstall/default.nix diff --git a/pkgs/build-support/release/debian-build.nix b/pkgs/build-support/release/debian-build.nix index 96efd1913cc6..3bae38e1d06d 100644 --- a/pkgs/build-support/release/debian-build.nix +++ b/pkgs/build-support/release/debian-build.nix @@ -3,7 +3,7 @@ # just for portability testing: it doesn't produce any Debian # packages. -vmTools: args: with args; +{vmTools, fetchurl}: args: with args; vmTools.runInLinuxImage (stdenv.mkDerivation ( @@ -12,10 +12,9 @@ vmTools.runInLinuxImage (stdenv.mkDerivation ( doCheck = true; - # Don't install the result in the Nix store. - useTempPrefix = true; + prefix = "/usr"; - phases = "sysInfoPhase unpackPhase patchPhase configurePhase buildPhase checkPhase installPhase distPhase"; + phases = "installExtraDebsPhase sysInfoPhase unpackPhase patchPhase configurePhase buildPhase checkPhase installPhase distPhase"; } // args // @@ -37,6 +36,19 @@ vmTools.runInLinuxImage (stdenv.mkDerivation ( fi ''; # */ + extraDebs = [ + (fetchurl { + url = http://checkinstall.izto.org/files/deb/checkinstall_1.6.1-1_i386.deb; + sha256 = "0c9wwk1m0w677gr37zd4lhvkskkcrwa0bk7csh7b3qy94pnab618"; + }) + ]; + + installExtraDebsPhase = '' + for i in $extraDebs; do + dpkg --install $i + done + ''; + sysInfoPhase = '' echo "System/kernel: $(uname -a)" if test -e /etc/debian_version; then echo "Debian release: $(cat /etc/debian_version)"; fi @@ -45,6 +57,21 @@ vmTools.runInLinuxImage (stdenv.mkDerivation ( stopNest ''; + installCommand = '' + /usr/local/sbin/checkinstall -y -D make install + + ensureDir $out/debs + find . -name "*.deb" -exec cp {} $out/debs \; + + shopt -s nullglob + for i in $out/debs/*.deb; do + header "Generated DEB package: $i" + dpkg-deb --info $i + echo "file deb $i" >> $out/nix-support/hydra-build-products + stopNest + done + ''; # */ + meta = { description = "Test build on ${args.diskImage.fullName} (${args.diskImage.name})"; }; diff --git a/pkgs/build-support/release/default.nix b/pkgs/build-support/release/default.nix index dd46164d9f29..f90c56fbc8e5 100644 --- a/pkgs/build-support/release/default.nix +++ b/pkgs/build-support/release/default.nix @@ -19,7 +19,7 @@ rec { rpmBuild = args: import ./rpm-build.nix vmTools args; - debBuild = args: import ./debian-build.nix vmTools ( + debBuild = args: import ./debian-build.nix {inherit vmTools fetchurl;} ( { inherit stdenv; } // args); diff --git a/pkgs/build-support/vm/default.nix b/pkgs/build-support/vm/default.nix index 427e7dc58ff1..756aa14c0955 100644 --- a/pkgs/build-support/vm/default.nix +++ b/pkgs/build-support/vm/default.nix @@ -863,6 +863,10 @@ rec { "patch" "diff" "locales" + # Needed by checkinstall: + "util-linux" + "file" + "dpkg-dev" ]; diff --git a/pkgs/tools/package-management/checkinstall/default.nix b/pkgs/tools/package-management/checkinstall/default.nix new file mode 100644 index 000000000000..80f774e8e5d9 --- /dev/null +++ b/pkgs/tools/package-management/checkinstall/default.nix @@ -0,0 +1,24 @@ +{stdenv, fetchurl, gettext}: + +stdenv.mkDerivation { + name = "checkinstall-1.6.1"; + + src = fetchurl { + url = http://checkinstall.izto.org/files/source/checkinstall-1.6.1.tgz; + sha256 = "0p6gbbnk4hjwkmv8dr7c4v5wpdnanczavi7yiiivvf45zyfl8lil"; + }; + + buildInputs = [gettext]; + + preBuild = '' + makeFlagsArray=(PREFIX=$out) + + substituteInPlace checkinstall --replace /usr/local/lib/checkinstall $out/lib/checkinstall + substituteInPlace checkinstallrc-dist --replace /usr/local $out + ''; + + meta = { + homepage = http://checkinstall.izto.org/; + description = "A tool for automatically generating Slackware, RPM or Debian packages when doing `make install'"; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 50819014d099..e8394aea3413 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -572,6 +572,10 @@ let inherit fetchurl stdenv cmake libcap zlib bzip2; }; + checkinstall = import ../tools/package-management/checkinstall { + inherit fetchurl stdenv gettext; + }; + cheetahTemplate = builderDefsPackage (selectVersion ../tools/text/cheetah-template "2.0.1") { inherit makeWrapper python; };