2008-11-24 16:10:06 +01: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 16:53:45 +01:00
|
|
|
{ officialRelease ? false
|
|
|
|
, buildInputs ? []
|
2009-03-02 14:45:48 +01:00
|
|
|
, name ? "source-tarball"
|
|
|
|
, version ? "0"
|
2008-11-25 16:53:45 +01:00
|
|
|
, src, stdenv, autoconf, automake, libtool
|
2008-12-04 16:32:30 +01:00
|
|
|
, ... } @ args:
|
2008-11-25 16:53:45 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
versionSuffix =
|
|
|
|
if officialRelease
|
|
|
|
then ""
|
2008-11-25 19:08:49 +01:00
|
|
|
else if src ? rev then "pre${toString src.rev}" else "";
|
2008-11-25 16:53:45 +01:00
|
|
|
|
|
|
|
in
|
2008-11-24 16:10:06 +01: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 17:12:50 +01:00
|
|
|
preConfigurePhases = "autoconfPhase";
|
|
|
|
postPhases = "finalPhase";
|
2008-11-24 16:10:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Then, the caller-supplied attributes.
|
|
|
|
// args //
|
|
|
|
|
|
|
|
# And finally, our own stuff.
|
|
|
|
{
|
2009-03-02 14:45:48 +01:00
|
|
|
name = name + "-" + version + versionSuffix;
|
|
|
|
|
2008-11-26 02:00:23 +01:00
|
|
|
buildInputs = buildInputs ++ [autoconf automake libtool];
|
2008-11-24 16:10:06 +01:00
|
|
|
|
|
|
|
postHook = ''
|
|
|
|
ensureDir $out/nix-support
|
2009-03-19 14:39:07 +01:00
|
|
|
shopt -s nullglob
|
2008-11-24 16:10:06 +01: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 "";
|
|
|
|
|
|
|
|
# Autoconfiscate the sources.
|
|
|
|
autoconfPhase = ''
|
2009-03-06 17:53:44 +01:00
|
|
|
export VERSION=${version}
|
2008-11-25 16:53:45 +01:00
|
|
|
export VERSION_SUFFIX=${versionSuffix}
|
|
|
|
|
2008-11-24 16:10:06 +01:00
|
|
|
eval "$preAutoconf"
|
|
|
|
|
|
|
|
if test -f ./bootstrap; then ./bootstrap
|
|
|
|
elif test -f ./bootstrap.sh; then ./bootstrap.sh
|
|
|
|
elif test -f ./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"
|
|
|
|
'';
|
|
|
|
|
|
|
|
# Cause distPhase to copy tar.bz2 in addition to tar.gz.
|
|
|
|
tarballs = "*.tar.gz *.tar.bz2";
|
|
|
|
|
2008-11-28 17:12:50 +01:00
|
|
|
finalPhase = ''
|
2008-11-24 16:10:06 +01:00
|
|
|
for i in $out/tarballs/*; do
|
|
|
|
echo "file source-dist $i" >> $out/nix-support/hydra-build-products
|
|
|
|
done
|
2008-11-25 17:12:36 +01: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)
|
2008-11-24 16:10:06 +01:00
|
|
|
''; # */
|
|
|
|
|
2009-03-02 14:45:48 +01:00
|
|
|
passthru = {
|
|
|
|
inherit src;
|
|
|
|
version = version + versionSuffix;
|
|
|
|
};
|
2008-11-24 16:10:06 +01:00
|
|
|
|
2008-11-26 15:34:29 +01:00
|
|
|
meta = (if args ? meta then args.meta else {}) // {
|
2008-11-24 16:10:06 +01:00
|
|
|
description = "Build of a source distribution from a checkout";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
)
|