* 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
This commit is contained in:
Eelco Dolstra 2009-03-02 13:45:48 +00:00
parent f19aea6d5a
commit 45081f330d
5 changed files with 48 additions and 27 deletions

View file

@ -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})";
};
}

View file

@ -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);
}

View file

@ -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";
};
}
)

View file

@ -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 {}) // {

View file

@ -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})";
};
}