nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 138 lines 4.1 kB view raw
1# This function converts an un-Autoconfed source tarball (typically a 2# checkout from a Subversion or CVS repository) into a source tarball 3# by running `autoreconf', `configure' and `make dist'. 4 5{ 6 officialRelease ? false, 7 buildInputs ? [ ], 8 name ? "source-tarball", 9 version ? "0", 10 versionSuffix ? if officialRelease then "" else "pre${toString (src.rev or src.revCount or "")}", 11 src, 12 lib, 13 stdenv, 14 autoconf, 15 automake, 16 libtool, 17 # By default, provide all the GNU Build System as input. 18 bootstrapBuildInputs ? [ 19 autoconf 20 automake 21 libtool 22 ], 23 ... 24}@args: 25 26stdenv.mkDerivation ( 27 28 # First, attributes that can be overridden by the caller (via args): 29 { 30 # By default, only configure and build a source distribution. 31 # Some packages can only build a distribution after a general 32 # `make' (or even `make install'). 33 dontBuild = true; 34 dontInstall = true; 35 doDist = true; 36 37 # If we do install, install to a dummy location. 38 useTempPrefix = true; 39 40 showBuildStats = true; 41 42 preConfigurePhases = [ "autoconfPhase" ]; 43 postPhases = [ "finalPhase" ]; 44 45 # Autoconfiscate the sources. 46 autoconfPhase = '' 47 export VERSION=${version} 48 export VERSION_SUFFIX=${versionSuffix} 49 50 # `svn-revision' is set for backwards compatibility with the old 51 # Nix buildfarm. (Stratego/XT's autoxt uses it. We should 52 # update it eventually.) 53 echo ${versionSuffix} | sed -e s/pre// > svn-revision 54 55 eval "$preAutoconf" 56 57 if test -x ./bootstrap && test -f ./bootstrap; then ./bootstrap 58 elif test -x ./bootstrap.sh; then ./bootstrap.sh 59 elif test -x ./autogen.sh; then ./autogen.sh 60 elif test -x ./autogen ; then ./autogen 61 elif test -x ./reconf; then ./reconf 62 elif test -f ./configure.in || test -f ./configure.ac; then 63 autoreconf --install --force --verbose 64 else 65 echo "No bootstrap, bootstrap.sh, configure.in or configure.ac. Assuming this is not an GNU Autotools package." 66 fi 67 68 eval "$postAutoconf" 69 ''; 70 71 failureHook = '' 72 if test -n "$succeedOnFailure"; then 73 if test -n "$keepBuildDirectory"; then 74 KEEPBUILDDIR="$out/`basename $TMPDIR`" 75 echo "Copying build directory to $KEEPBUILDDIR" 76 mkdir -p $KEEPBUILDDIR 77 cp -R "$TMPDIR/"* $KEEPBUILDDIR 78 fi 79 fi 80 ''; 81 } 82 83 # Then, the caller-supplied attributes. 84 // (removeAttrs args [ "lib" ]) 85 // 86 87 # And finally, our own stuff. 88 { 89 name = name + "-" + version + versionSuffix; 90 91 buildInputs = buildInputs ++ bootstrapBuildInputs; 92 93 preUnpack = '' 94 mkdir -p $out/nix-support 95 ''; 96 97 postUnpack = '' 98 # Set all source files to the current date. This is because Nix 99 # resets the timestamp on all files to 0 (1/1/1970), which some 100 # people don't like (in particular GNU tar prints harmless but 101 # frightening warnings about it). 102 touch now 103 touch -d "1970-01-01 00:00:00 UTC" then 104 find $sourceRoot ! -newer then -print0 | xargs -0r touch --reference now 105 rm now then 106 eval "$nextPostUnpack" 107 ''; 108 109 nextPostUnpack = if args ? postUnpack then args.postUnpack else ""; 110 111 # Cause distPhase to copy tar.bz2 in addition to tar.gz. 112 tarballs = "*.tar.gz *.tar.bz2 *.tar.xz"; 113 114 finalPhase = '' 115 for i in "$out/tarballs/"*; do 116 echo "file source-dist $i" >> $out/nix-support/hydra-build-products 117 done 118 119 # Try to figure out the release name. 120 releaseName=$( (cd $out/tarballs && ls) | head -n 1 | sed -e 's^\.[a-z].*^^') 121 test -n "$releaseName" && (echo "$releaseName" >> $out/nix-support/hydra-release-name) 122 ''; 123 124 passthru = { 125 inherit src; 126 version = version + versionSuffix; 127 }; 128 129 meta = (lib.optionalAttrs (args ? meta) args.meta) // { 130 description = "Source distribution"; 131 132 # Tarball builds are generally important, so give them a high 133 # default priority. 134 schedulingPriority = 200; 135 }; 136 } 137 138)