* makeSourceTarball -> sourceTarball.

* Added a function binaryTarball to do a DESTDIR build into
  /usr/local.  Useful for making statically linked binaries.  However,
  it may be better to do this in a VM (since if you do it in a Nix
  build environment, you can still end up with a lot of Nix
  dependencies in your binaries, even if you do static linking).

svn path=/nixpkgs/trunk/; revision=14726
This commit is contained in:
Eelco Dolstra 2009-03-26 14:11:59 +00:00
parent 5322285f97
commit f30fe65b3e
5 changed files with 96 additions and 12 deletions

View File

@ -0,0 +1,87 @@
/* This function builds a binary tarball. The resulting binaries are
usually only useful if they are don't have any runtime dependencies
on any paths in the Nix store, since those aren't distributed in
the tarball. For instance, the binaries should be statically
linked: they can't depend on dynamic libraries in the store
(including Glibc).
The binaries are built and installed with a prefix of /usr/local by
default. They are installed by setting DESTDIR to a temporary
directory, so the Makefile of the package should support DESTDIR.
*/
{ src, stdenv
, name ? "binary-tarball"
, ... } @ args:
stdenv.mkDerivation (
{
# Also run a `make check'.
doCheck = true;
showBuildStats = true;
prefix = "/usr/local";
postPhases = "finalPhase";
}
// args //
{
name = name + (if src ? version then "-" + src.version else "");
postHook = ''
ensureDir $out/nix-support
echo "$system" > $out/nix-support/system
# 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.
origSrc=$src
if test -d $src/tarballs; then
src=$(ls $src/tarballs/*.tar.bz2 $src/tarballs/*.tar.gz | sort | head -1)
fi
if test -e $origSrc/nix-support/hydra-release-name; then
releaseName=$(cat $origSrc/nix-support/hydra-release-name)
fi
installFlagsArray=(DESTDIR=$TMPDIR/inst)
# Prefix hackery because of a bug in stdenv (it tries to `mkdir
# $prefix', which doesn't work due to the DESTDIR).
configureFlags="--prefix=$prefix $configureFlags"
dontAddPrefix=1
prefix=$TMPDIR/inst$prefix
''; # */
doDist = true;
distPhase =
''
ensureDir $out/tarballs
tar cvfj $out/tarballs/''${releaseName:-binary-dist}.tar.bz2 -C $TMPDIR/inst .
'';
finalPhase =
''
for i in $out/tarballs/*; do
echo "file binary-dist $i" >> $out/nix-support/hydra-build-products
done
# Propagate the release name of the source tarball. This is
# to get nice package names in channels.
test -n "$releaseName" && (echo "$releaseName" >> $out/nix-support/hydra-release-name)
'';
meta = (if args ? meta then args.meta else {}) // {
description = "Build of a generic binary distribution";
};
}
)

View File

@ -13,7 +13,7 @@ vmTools.runInLinuxImage (stdenv.mkDerivation (
prefix = "/usr";
phases = "installExtraDebsPhase sysInfoPhase unpackPhase patchPhase configurePhase buildPhase checkPhase installPhase distPhase";
prePhases = "installExtraDebsPhase sysInfoPhase";
}
// removeAttrs args ["vmTools"] //

View File

@ -4,11 +4,17 @@ with pkgs;
rec {
makeSourceTarball = args: import ./make-source-tarball.nix (
sourceTarball = args: import ./source-tarball.nix (
{ inherit autoconf automake libtool;
stdenv = stdenvNew;
} // args);
makeSourceTarball = sourceTarball; # compatibility
binaryTarball = args: import ./binary-tarball.nix (
{ inherit stdenv;
} // args);
nixBuild = args: import ./nix-build.nix (
{ inherit stdenv;
} // args);

View File

@ -47,15 +47,6 @@ stdenv.mkDerivation (
src=$(ls $src/tarballs/*.tar.bz2 $src/tarballs/*.tar.gz | sort | head -1)
fi
# Hack to compress log files. Prevents (by pointer hiding!)
# unnecessary dependencies.
startLogWrite() {
# Use process substitution to send the FIFO output to both
# stdout and bzip2.
bash -c "tee >(bzip2 > \"$1\".bz2) < \"$2\"" &
logWriterPid=$!
}
# Set GCC flags for coverage analysis, if desired.
if test -n "${toString doCoverageAnalysis}"; then
export NIX_CFLAGS_COMPILE="-O0 -fprofile-arcs -ftest-coverage $NIX_CFLAGS_COMPILE"

View File

@ -94,7 +94,7 @@ stdenv.mkDerivation (
finalPhase = ''
for i in $out/tarballs/*; do
echo "file source-dist $i" >> $out/nix-support/hydra-build-products
echo "file source-dist $i" >> $out/nix-support/hydra-build-products
done
# Try to figure out the release name.