2008-11-24 15:10:06 +00:00
|
|
|
# This function converts an un-Autoconfed source tarball (typically a
|
|
|
|
# checkout from a Subversion or CVS repository) into a source tarball
|
|
|
|
# by running `autoreconf', `configure' and `make dist'.
|
|
|
|
|
2008-11-25 15:53:45 +00:00
|
|
|
{ officialRelease ? false
|
|
|
|
, buildInputs ? []
|
2009-03-02 13:45:48 +00:00
|
|
|
, name ? "source-tarball"
|
|
|
|
, version ? "0"
|
2013-03-06 15:57:57 +00:00
|
|
|
, versionSuffix ?
|
2011-12-05 14:16:30 +00:00
|
|
|
if officialRelease
|
|
|
|
then ""
|
2013-01-15 14:03:38 +00:00
|
|
|
else "pre${toString (src.rev or src.revCount or "")}"
|
2008-11-25 15:53:45 +00:00
|
|
|
, src, stdenv, autoconf, automake, libtool
|
2013-03-06 15:57:57 +00:00
|
|
|
, # By default, provide all the GNU Build System as input.
|
|
|
|
bootstrapBuildInputs ? [ autoconf automake libtool ]
|
2008-12-04 15:32:30 +00:00
|
|
|
, ... } @ args:
|
2008-11-25 15:53:45 +00:00
|
|
|
|
2008-11-24 15:10:06 +00:00
|
|
|
stdenv.mkDerivation (
|
|
|
|
|
|
|
|
# First, attributes that can be overriden by the caller (via args):
|
|
|
|
{
|
|
|
|
# By default, only configure and build a source distribution.
|
|
|
|
# Some packages can only build a distribution after a general
|
|
|
|
# `make' (or even `make install').
|
|
|
|
dontBuild = true;
|
|
|
|
dontInstall = true;
|
|
|
|
doDist = true;
|
|
|
|
|
|
|
|
# If we do install, install to a dummy location.
|
|
|
|
useTempPrefix = true;
|
|
|
|
|
|
|
|
showBuildStats = true;
|
|
|
|
|
2008-11-28 16:12:50 +00:00
|
|
|
preConfigurePhases = "autoconfPhase";
|
|
|
|
postPhases = "finalPhase";
|
2009-11-19 13:57:57 +00:00
|
|
|
|
|
|
|
# Autoconfiscate the sources.
|
|
|
|
autoconfPhase = ''
|
|
|
|
export VERSION=${version}
|
|
|
|
export VERSION_SUFFIX=${versionSuffix}
|
|
|
|
|
|
|
|
# `svn-revision' is set for backwards compatibility with the old
|
|
|
|
# Nix buildfarm. (Stratego/XT's autoxt uses it. We should
|
|
|
|
# update it eventually.)
|
|
|
|
echo ${versionSuffix} | sed -e s/pre// > svn-revision
|
|
|
|
|
|
|
|
eval "$preAutoconf"
|
|
|
|
|
2012-02-23 23:50:56 +00:00
|
|
|
if test -x ./bootstrap && test -f ./bootstrap; then ./bootstrap
|
2009-11-19 13:57:57 +00:00
|
|
|
elif test -x ./bootstrap.sh; then ./bootstrap.sh
|
|
|
|
elif test -x ./autogen.sh; then ./autogen.sh
|
|
|
|
elif test -x ./autogen ; then ./autogen
|
|
|
|
elif test -x ./reconf; then ./reconf
|
|
|
|
elif test -f ./configure.in || test -f ./configure.ac; then
|
|
|
|
autoreconf --install --force --verbose
|
|
|
|
else
|
|
|
|
echo "No bootstrap, bootstrap.sh, configure.in or configure.ac. Assuming this is not an GNU Autotools package."
|
|
|
|
fi
|
|
|
|
|
|
|
|
eval "$postAutoconf"
|
|
|
|
'';
|
2011-01-05 07:31:29 +00:00
|
|
|
|
|
|
|
failureHook = ''
|
|
|
|
if test -n "$succeedOnFailure"; then
|
|
|
|
if test -n "$keepBuildDirectory"; then
|
|
|
|
KEEPBUILDDIR="$out/`basename $TMPDIR`"
|
|
|
|
header "Copying build directory to $KEEPBUILDDIR"
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $KEEPBUILDDIR
|
2016-01-26 13:03:06 +00:00
|
|
|
cp -R "$TMPDIR/"* $KEEPBUILDDIR
|
2011-01-05 07:31:29 +00:00
|
|
|
stopNest
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
'';
|
2008-11-24 15:10:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Then, the caller-supplied attributes.
|
2013-03-06 15:57:57 +00:00
|
|
|
// args //
|
2008-11-24 15:10:06 +00:00
|
|
|
|
|
|
|
# And finally, our own stuff.
|
|
|
|
{
|
2009-03-02 13:45:48 +00:00
|
|
|
name = name + "-" + version + versionSuffix;
|
|
|
|
|
2010-05-25 08:24:50 +00:00
|
|
|
buildInputs = buildInputs ++ bootstrapBuildInputs;
|
2013-03-06 15:57:57 +00:00
|
|
|
|
2012-04-04 16:05:08 +00:00
|
|
|
preUnpack = ''
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $out/nix-support
|
2013-03-06 15:57:57 +00:00
|
|
|
'';
|
2008-11-24 15:10:06 +00:00
|
|
|
|
|
|
|
postUnpack = ''
|
|
|
|
# Set all source files to the current date. This is because Nix
|
|
|
|
# resets the timestamp on all files to 0 (1/1/1970), which some
|
|
|
|
# people don't like (in particular GNU tar prints harmless but
|
|
|
|
# frightening warnings about it).
|
|
|
|
touch now
|
|
|
|
touch -d "1970-01-01 00:00:00 UTC" then
|
|
|
|
find $sourceRoot ! -newer then -print0 | xargs -0r touch --reference now
|
|
|
|
eval "$nextPostUnpack"
|
|
|
|
'';
|
|
|
|
|
|
|
|
nextPostUnpack = if args ? postUnpack then args.postUnpack else "";
|
|
|
|
|
|
|
|
# Cause distPhase to copy tar.bz2 in addition to tar.gz.
|
2009-11-18 14:12:39 +00:00
|
|
|
tarballs = "*.tar.gz *.tar.bz2 *.tar.xz";
|
2008-11-24 15:10:06 +00:00
|
|
|
|
2008-11-28 16:12:50 +00:00
|
|
|
finalPhase = ''
|
2009-11-18 14:12:39 +00:00
|
|
|
for i in "$out/tarballs/"*; do
|
2009-03-26 14:11:59 +00:00
|
|
|
echo "file source-dist $i" >> $out/nix-support/hydra-build-products
|
2008-11-24 15:10:06 +00:00
|
|
|
done
|
2008-11-25 16:12:36 +00:00
|
|
|
|
|
|
|
# Try to figure out the release name.
|
|
|
|
releaseName=$( (cd $out/tarballs && ls) | head -n 1 | sed -e 's^\.[a-z].*^^')
|
|
|
|
test -n "$releaseName" && (echo "$releaseName" >> $out/nix-support/hydra-release-name)
|
2009-11-18 14:12:39 +00:00
|
|
|
'';
|
2008-11-24 15:10:06 +00:00
|
|
|
|
2009-03-02 13:45:48 +00:00
|
|
|
passthru = {
|
|
|
|
inherit src;
|
|
|
|
version = version + versionSuffix;
|
|
|
|
};
|
2008-11-24 15:10:06 +00:00
|
|
|
|
2008-11-26 14:34:29 +00:00
|
|
|
meta = (if args ? meta then args.meta else {}) // {
|
2013-03-01 11:50:29 +00:00
|
|
|
description = "Source distribution";
|
2009-03-30 13:21:00 +00:00
|
|
|
|
|
|
|
# Tarball builds are generally important, so give them a high
|
|
|
|
# default priority.
|
|
|
|
schedulingPriority = "200";
|
2008-11-24 15:10:06 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
)
|