From 45081f330db56891e6e4f47bad295a371aac8651 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 2 Mar 2009 13:45:48 +0000 Subject: [PATCH] * Append the version to the "name" attribute to make the store paths of Hydra builds more distinct (e.g. "patchelf-build-0.5pre1234" instead of just "patchelf-build"). If the version isn't known, append at least the revision. * Propagate the release name of the source tarball to Nix builds. Useful to provide sensible package names in channels. svn path=/nixpkgs/trunk/; revision=14294 --- pkgs/build-support/release/debian-build.nix | 17 ++++++++------- pkgs/build-support/release/default.nix | 8 ++++--- .../release/make-source-tarball.nix | 12 +++++++---- pkgs/build-support/release/nix-build.nix | 21 ++++++++++++++----- pkgs/build-support/release/rpm-build.nix | 17 ++++++++------- 5 files changed, 48 insertions(+), 27 deletions(-) diff --git a/pkgs/build-support/release/debian-build.nix b/pkgs/build-support/release/debian-build.nix index fad88a98f177..5144e3169e55 100644 --- a/pkgs/build-support/release/debian-build.nix +++ b/pkgs/build-support/release/debian-build.nix @@ -1,13 +1,14 @@ # This function compiles a source tarball in a virtual machine image # that contains a Debian-like (i.e. dpkg-based) OS. -{vmTools, fetchurl}: args: with args; +{ name ? "debian-build" +, diskImage +, src, stdenv, vmTools, checkinstall +, ... } @ args: vmTools.runInLinuxImage (stdenv.mkDerivation ( { - name = "debian-build"; - doCheck = true; prefix = "/usr"; @@ -15,10 +16,12 @@ vmTools.runInLinuxImage (stdenv.mkDerivation ( phases = "installExtraDebsPhase sysInfoPhase unpackPhase patchPhase configurePhase buildPhase checkPhase installPhase distPhase"; } - // args // + // removeAttrs args ["vmTools"] // { - src = src.path; + name = name + "-" + diskImage.name + "-" + src.version; + + src = if src ? outPath then src.outPath else src.path; # !!! cut&paste from rpm-build.nix postHook = '' @@ -50,7 +53,7 @@ vmTools.runInLinuxImage (stdenv.mkDerivation ( installCommand = '' export LOGNAME=root - + ${checkinstall}/sbin/checkinstall -y -D make install ensureDir $out/debs @@ -66,7 +69,7 @@ vmTools.runInLinuxImage (stdenv.mkDerivation ( ''; # */ meta = (if args ? meta then args.meta else {}) // { - description = "Build of a Deb package on ${args.diskImage.fullName} (${args.diskImage.name})"; + description = "Build of a Deb package on ${diskImage.fullName} (${diskImage.name})"; }; } diff --git a/pkgs/build-support/release/default.nix b/pkgs/build-support/release/default.nix index 58368bddf6be..130fae6e4bb8 100644 --- a/pkgs/build-support/release/default.nix +++ b/pkgs/build-support/release/default.nix @@ -18,10 +18,12 @@ rec { doCoverageAnalysis = true; } // args); - rpmBuild = args: import ./rpm-build.nix vmTools args; + rpmBuild = args: import ./rpm-build.nix ( + { inherit vmTools; + } // args); - debBuild = args: import ./debian-build.nix {inherit vmTools fetchurl;} ( - { inherit stdenv checkinstall; + debBuild = args: import ./debian-build.nix ( + { inherit stdenv vmTools checkinstall; } // args); } diff --git a/pkgs/build-support/release/make-source-tarball.nix b/pkgs/build-support/release/make-source-tarball.nix index 806246db7945..ccae6d612ab1 100644 --- a/pkgs/build-support/release/make-source-tarball.nix +++ b/pkgs/build-support/release/make-source-tarball.nix @@ -4,6 +4,8 @@ { officialRelease ? false , buildInputs ? [] +, name ? "source-tarball" +, version ? "0" , src, stdenv, autoconf, automake, libtool , ... } @ args: @@ -20,8 +22,6 @@ stdenv.mkDerivation ( # First, attributes that can be overriden by the caller (via args): { - name = "source-tarball"; - # By default, only configure and build a source distribution. # Some packages can only build a distribution after a general # `make' (or even `make install'). @@ -43,6 +43,8 @@ stdenv.mkDerivation ( # And finally, our own stuff. { + name = name + "-" + version + versionSuffix; + src = src.path; buildInputs = buildInputs ++ [autoconf automake libtool]; @@ -96,12 +98,14 @@ stdenv.mkDerivation ( test -n "$releaseName" && (echo "$releaseName" >> $out/nix-support/hydra-release-name) ''; # */ - passthru = {inherit src;}; + passthru = { + inherit src; + version = version + versionSuffix; + }; meta = (if args ? meta then args.meta else {}) // { description = "Build of a source distribution from a checkout"; }; - } ) diff --git a/pkgs/build-support/release/nix-build.nix b/pkgs/build-support/release/nix-build.nix index 5f127265d4a8..142bd7bc3629 100644 --- a/pkgs/build-support/release/nix-build.nix +++ b/pkgs/build-support/release/nix-build.nix @@ -8,13 +8,12 @@ { doCoverageAnalysis ? false , lcovFilter ? [] , src, stdenv +, name ? if doCoverageAnalysis then "nix-coverage" else "nix-build" , ... } @ args: stdenv.mkDerivation ( { - name = "nix-build"; - # Also run a `make check'. doCheck = true; @@ -24,13 +23,15 @@ stdenv.mkDerivation ( showBuildStats = true; # Hack - swap checkPhase and installPhase (otherwise Stratego barfs). - phases = "unpackPhase patchPhase configurePhase buildPhase installPhase checkPhase fixupPhase distPhase ${if doCoverageAnalysis then "coverageReportPhase" else ""}"; + phases = "unpackPhase patchPhase configurePhase buildPhase installPhase checkPhase fixupPhase distPhase ${if doCoverageAnalysis then "coverageReportPhase" else ""} finalPhase"; } // args // { - src = src.path; + name = name + "-" + src.version; + + src = if src ? outPath then src.outPath else src.path; postHook = '' ensureDir $out/nix-support @@ -43,7 +44,7 @@ stdenv.mkDerivation ( # If `src' is the result of a call to `makeSourceTarball', then it # has a subdirectory containing the actual tarball(s). If there are # multiple tarballs, just pick the first one. - echo $src + origSrc=$src if test -d $src/tarballs; then src=$(ls $src/tarballs/*.tar.bz2 $src/tarballs/*.tar.gz | sort | head -1) fi @@ -85,6 +86,16 @@ stdenv.mkDerivation ( lcovFilter = ["/nix/store/*"] ++ lcovFilter; + + + finalPhase = + '' + # Propagate the release name of the source tarball. This is + # to get nice package names in channels. + if test -e $origSrc/nix-support/hydra-release-name; then + cp $origSrc/nix-support/hydra-release-name $out/nix-support/hydra-release-name + fi + ''; meta = (if args ? meta then args.meta else {}) // { diff --git a/pkgs/build-support/release/rpm-build.nix b/pkgs/build-support/release/rpm-build.nix index 88273b5958cc..b094732f9b73 100644 --- a/pkgs/build-support/release/rpm-build.nix +++ b/pkgs/build-support/release/rpm-build.nix @@ -1,18 +1,19 @@ # 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'). -vmTools: args: with args; +{ name ? "rpm-build" +, diskImage +, src, vmTools +, ... } @ args: vmTools.buildRPM ( - { - name = "rpm-build"; - } - - // args // + removeAttrs args ["vmTools"] // { - src = src.path; + name = name + "-" + diskImage.name + "-" + src.version; + + src = if src ? outPath then src.outPath else src.path; preBuild = '' ensureDir $out/nix-support @@ -34,7 +35,7 @@ vmTools.buildRPM ( ''; # */ meta = (if args ? meta then args.meta else {}) // { - description = "Build of an RPM package on ${args.diskImage.fullName} (${args.diskImage.name})"; + description = "Build of an RPM package on ${diskImage.fullName} (${diskImage.name})"; }; }