diff options
author | Lluís Batlle i Rossell <viric@vicerveza.homeunix.net> | 2009-11-19 19:09:10 +0000 |
---|---|---|
committer | Lluís Batlle i Rossell <viric@vicerveza.homeunix.net> | 2009-11-19 19:09:10 +0000 |
commit | e85500987b7df503b37a127a5ea49a07f92e70f0 (patch) | |
tree | 5f66b5de9aadaf0ff3ba52c394dc0066114e11e2 /pkgs/build-support | |
parent | 7ade207f6b75da0fde94cec621ac6d8fa6c3e586 (diff) | |
parent | 58f543f19f1a2eed8a46202b36a855836cfc9e0f (diff) | |
download | nixlib-e85500987b7df503b37a127a5ea49a07f92e70f0.tar nixlib-e85500987b7df503b37a127a5ea49a07f92e70f0.tar.gz nixlib-e85500987b7df503b37a127a5ea49a07f92e70f0.tar.bz2 nixlib-e85500987b7df503b37a127a5ea49a07f92e70f0.tar.lz nixlib-e85500987b7df503b37a127a5ea49a07f92e70f0.tar.xz nixlib-e85500987b7df503b37a127a5ea49a07f92e70f0.tar.zst nixlib-e85500987b7df503b37a127a5ea49a07f92e70f0.zip |
Merging from trunk. I had to do two manual merges, quite trivial I think.
svn path=/nixpkgs/branches/stdenv-updates/; revision=18472
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/builder-defs/builder-defs.nix | 4 | ||||
-rwxr-xr-x | pkgs/build-support/fetchgit/nix-prefetch-git | 14 | ||||
-rw-r--r-- | pkgs/build-support/fetchhg/builder.sh | 9 | ||||
-rw-r--r-- | pkgs/build-support/fetchhg/default.nix | 3 | ||||
-rw-r--r-- | pkgs/build-support/fetchurl/default.nix | 3 | ||||
-rw-r--r-- | pkgs/build-support/fetchurl/mirrors.nix | 11 | ||||
-rw-r--r-- | pkgs/build-support/release/source-tarball.nix | 56 | ||||
-rw-r--r-- | pkgs/build-support/trivial-builders.nix | 71 | ||||
-rw-r--r-- | pkgs/build-support/vm/default.nix | 13 |
9 files changed, 132 insertions, 52 deletions
diff --git a/pkgs/build-support/builder-defs/builder-defs.nix b/pkgs/build-support/builder-defs/builder-defs.nix index 814ce460794c..5eaa40c61118 100644 --- a/pkgs/build-support/builder-defs/builder-defs.nix +++ b/pkgs/build-support/builder-defs/builder-defs.nix @@ -373,10 +373,6 @@ let inherit (builtins) head tail trace; in /*debug = x:(trace x x); debugX = x:(trace (toXML x) x);*/ - replaceScriptVar = file: name: value: "sed -e 's`^${name}=.*`${name}='\\''${value}'\\''`' -i ${file}"; - replaceInScript = file: l: concatStringsSep "\n" ((pairMap (replaceScriptVar file) l)); - replaceScripts = l: concatStringsSep "\n" (pairMap replaceInScript l); - doReplaceScripts = fullDepEntry (replaceScripts (attrByPath ["shellReplacements"] [] args)) ["minInit"]; makeNest = x: if x == defNest.text then x else "startNest\n" + x + "\nstopNest\n"; textClosure = a: steps: textClosureMap makeNest a (["defNest"] ++ steps); diff --git a/pkgs/build-support/fetchgit/nix-prefetch-git b/pkgs/build-support/fetchgit/nix-prefetch-git index d14f13bfa11a..9f2eb4b3a4c0 100755 --- a/pkgs/build-support/fetchgit/nix-prefetch-git +++ b/pkgs/build-support/fetchgit/nix-prefetch-git @@ -6,7 +6,7 @@ expHash=$3 hashType=$NIX_HASH_ALGO if test -z "$hashType"; then - hashType=md5 + hashType=sha256 fi if test -z "$url"; then @@ -36,15 +36,19 @@ if test -z "$finalPath"; then trap "rm -rf $tmpPath" EXIT # Perform the checkout. - git clone --depth 1 "$url" $tmpFile + git clone "$url" $tmpFile 1>&2 if test -n "$rev"; then cd $tmpFile - echo $tmpFile - git checkout $rev + echo $tmpFile >&2 + git checkout $rev 1>&2 fi # Allow doing additional processing before .git removal eval "$NIX_PREFETCH_GIT_CHECKOUT_HOOK" - find $tmpFile -name .git\* | xargs rm -rf + if test "$NIX_PREFETCH_GIT_LEAVE_DOT_GIT" != 1 + then + echo "removing \`.git'..." >&2 + rm -rf .git + fi # Compute the hash. hash=$(nix-hash --type $hashType $hashFormat $tmpFile) diff --git a/pkgs/build-support/fetchhg/builder.sh b/pkgs/build-support/fetchhg/builder.sh new file mode 100644 index 000000000000..fbdd12b4f055 --- /dev/null +++ b/pkgs/build-support/fetchhg/builder.sh @@ -0,0 +1,9 @@ +source $stdenv/setup + +header "getting $url${tag:+ ($tag)} into $out" + +hg clone ${tag:+-r "$tag"} "$url" "$out" + +rm -rf "$out/.hg" + +stopNest diff --git a/pkgs/build-support/fetchhg/default.nix b/pkgs/build-support/fetchhg/default.nix index a7696458856c..a80835cc71fb 100644 --- a/pkgs/build-support/fetchhg/default.nix +++ b/pkgs/build-support/fetchhg/default.nix @@ -1,7 +1,8 @@ {stdenv, mercurial, nix}: {url, tag ? null, md5}: +# TODO: statically check if mercurial as the https support if the url starts woth https. stdenv.mkDerivation { - name = "fetchdarcs"; + name = "fetchhg"; builder = ./builder.sh; buildInputs = [mercurial nix]; diff --git a/pkgs/build-support/fetchurl/default.nix b/pkgs/build-support/fetchurl/default.nix index 00b7f3cc0794..1ba9124027d4 100644 --- a/pkgs/build-support/fetchurl/default.nix +++ b/pkgs/build-support/fetchurl/default.nix @@ -1,6 +1,3 @@ -# Argh, this thing is duplicated (more-or-less) in Nix (in corepkgs). -# Need to find a way to combine them. - {stdenv, curl}: # Note that `curl' may be `null', in case of the native stdenv. let diff --git a/pkgs/build-support/fetchurl/mirrors.nix b/pkgs/build-support/fetchurl/mirrors.nix index 3e8675b2168c..88f4e064fa13 100644 --- a/pkgs/build-support/fetchurl/mirrors.nix +++ b/pkgs/build-support/fetchurl/mirrors.nix @@ -22,10 +22,18 @@ rec { sf = sourceforge; - # GNU. + # GNU (http://www.gnu.org/prep/ftp.html). gnu = [ + # This one redirects to a (supposedly) nearby and (supposedly) up-to-date + # mirror. + http://ftpmirror.gnu.org/ + http://ftp.nluug.nl/pub/gnu/ http://mirrors.kernel.org/gnu/ + ftp://mirror.cict.fr/gnu/ + ftp://ftp.cs.tu-berlin.de/pub/gnu/ + ftp://ftp.chg.ru/pub/gnu/ + http://ftp.gnu.org/pub/gnu/ ]; @@ -209,6 +217,7 @@ rec { http://ftp.funet.fi/pub/linux/mirrors/opensuse/ http://ftp5.gwdg.de/pub/opensuse/ http://ftp.opensuse.org/pub/opensuse/ + http://ftp5.gwdg.de/pub/opensuse/discontinued/ ]; # Gnome (see http://ftp.gnome.org/pub/GNOME/MIRRORS). diff --git a/pkgs/build-support/release/source-tarball.nix b/pkgs/build-support/release/source-tarball.nix index 579127f3a4d6..7cd3208d105c 100644 --- a/pkgs/build-support/release/source-tarball.nix +++ b/pkgs/build-support/release/source-tarball.nix @@ -36,6 +36,32 @@ stdenv.mkDerivation ( preConfigurePhases = "autoconfPhase"; postPhases = "finalPhase"; + + # 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" + + if test -x ./bootstrap; then ./bootstrap + 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" + ''; } # Then, the caller-supplied attributes. @@ -64,42 +90,18 @@ stdenv.mkDerivation ( nextPostUnpack = if args ? postUnpack then args.postUnpack else ""; - # 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" - - 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"; + tarballs = "*.tar.gz *.tar.bz2 *.tar.xz"; finalPhase = '' - for i in $out/tarballs/*; do + for i in "$out/tarballs/"*; do echo "file source-dist $i" >> $out/nix-support/hydra-build-products done # 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) - ''; # */ + ''; passthru = { inherit src; diff --git a/pkgs/build-support/trivial-builders.nix b/pkgs/build-support/trivial-builders.nix new file mode 100644 index 000000000000..1c9e7fc49f28 --- /dev/null +++ b/pkgs/build-support/trivial-builders.nix @@ -0,0 +1,71 @@ +{ stdenv, lndir }: + +rec { + + # Run the shell command `buildCommand' to produce a store path named + # `name'. The attributes in `env' are added to the environment + # prior to running the command. + runCommand = name: env: buildCommand: + stdenv.mkDerivation ({ + inherit name buildCommand; + } // env); + + + # Create a single file. + writeTextFile = + { name # the name of the derivation + , text + , executable ? false # run chmod +x ? + , destination ? "" # relative path appended to $out eg "/bin/foo" + }: + runCommand name {inherit text executable; } + '' + n=$out${destination} + mkdir -p "$(dirname "$n")" + echo -n "$text" > "$n" + (test -n "$executable" && chmod +x "$n") || true + ''; + + + # Shorthands for `writeTextFile'. + writeText = name: text: writeTextFile {inherit name text;}; + writeScript = name: text: writeTextFile {inherit name text; executable = true;}; + writeScriptBin = name: text: writeTextFile {inherit name text; executable = true; destination = "/bin/${name}";}; + + + # Create a forest of symlinks to the files in `paths'. + symlinkJoin = name: paths: + runCommand name { inherit paths; } + '' + mkdir -p $out + for i in $paths; do + ${lndir}/bin/lndir $i $out + done + ''; + + + # Make a package that just contains a setup hook with the given contents. + makeSetupHook = script: + runCommand "hook" {} + '' + ensureDir $out/nix-support + cp ${script} $out/nix-support/setup-hook + ''; + + + # Write the references (i.e. the runtime dependencies in the Nix store) of `path' to a file. + writeReferencesToFile = path: runCommand "runtime-deps" + { + exportReferencesGraph = ["graph" path]; + } + '' + touch $out + while read path; do + echo $path >> $out + read dummy + read nrRefs + for ((i = 0; i < nrRefs; i++)); do read ref; done + done < graph + ''; + +} diff --git a/pkgs/build-support/vm/default.nix b/pkgs/build-support/vm/default.nix index 88ef284fa3b6..1a8e584d65f8 100644 --- a/pkgs/build-support/vm/default.nix +++ b/pkgs/build-support/vm/default.nix @@ -252,15 +252,6 @@ rec { ''; - modifyDerivation = f: attrs: - let attrsCleaned = removeAttrs attrs ["meta" "passthru" "outPath" "drvPath"]; - newDrv = derivation (attrsCleaned // (f attrs)); - in newDrv // - { meta = if attrs ? meta then attrs.meta else {}; - passthru = if attrs ? passthru then attrs.passthru else {}; - }; - - /* Run a derivation in a Linux virtual machine (using Qemu/KVM). By default, there is no disk image; the root filesystem is a tmpfs, and /nix/store is shared with the host (via the CIFS protocol to @@ -282,7 +273,7 @@ rec { `run-vm' will be left behind in the temporary build directory that allows you to boot into the VM and debug it interactively. */ - runInLinuxVM = modifyDerivation (attrs: { + runInLinuxVM = drv: lib.overrideDerivation drv (attrs: { builder = "${bash}/bin/sh"; args = ["-e" (vmRunCommand qemuCommandLinux)]; origArgs = attrs.args; @@ -317,7 +308,7 @@ rec { - Reboot to shutdown the machine (because Qemu doesn't seem capable of a APM/ACPI VM shutdown). */ - runInGenericVM = modifyDerivation (attrs: { + runInGenericVM = drv: lib.overrideDerivation drv (attrs: { system = "i686-linux"; builder = "${bash}/bin/sh"; args = ["-e" (vmRunCommand qemuCommandGeneric)]; |