From 399d23373e8c15fa57dcda83ba3e0b58c05e96e9 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 22 Feb 2005 09:55:03 +0000 Subject: [PATCH] * Split downloading and unpacking. * Add an MD5 hash for the downloaded files. * Rename some files. svn path=/nixpkgs/trunk/; revision=2267 --- pkgs/stdenv/linux/default.nix | 43 ++++++++++++++----- .../linux/scripts/builder-stdenv-initial.sh | 1 - pkgs/stdenv/linux/scripts/download.sh | 3 ++ .../scripts/{curl-unpack => unpack-curl.sh} | 0 .../scripts/{download-script => unpack.sh} | 6 +-- 5 files changed, 36 insertions(+), 17 deletions(-) create mode 100644 pkgs/stdenv/linux/scripts/download.sh rename pkgs/stdenv/linux/scripts/{curl-unpack => unpack-curl.sh} (100%) rename pkgs/stdenv/linux/scripts/{download-script => unpack.sh} (65%) diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index 8067dfed1dee..f412252d3c4e 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -23,47 +23,68 @@ rec { cp = ./tools/cp; curl = ./curl-static/curl-7.12.2-static.tar.bz2; system = "i686-linux"; - args = [ ./scripts/curl-unpack ]; + args = [ ./scripts/unpack-curl.sh ]; + }; + + # This function downloads a file. + download = {url, md5, pkgname}: derivation { + name = baseNameOf (toString url); + system = "i686-linux"; + builder = ./tools/bash; + inherit curl url; + args = [ ./scripts/download.sh ]; + + # Nix 0.8 fixed-output derivations. + outputHashAlgo = "md5"; + outputHash = md5; + + # Compatibility with Nix <= 0.7. + id = md5; }; # This function downloads and unpacks a file. - download = - { url, pkgname, postProcess ? [], addToPath ? [] + downloadAndUnpack = + { url, md5, pkgname, postProcess ? [], addToPath ? [] , extra ? null, extra2 ? null , extra3 ? null, extra4? null, patchelf ? null}: derivation { name = pkgname; + system = "i686-linux"; builder = ./tools/bash; tar = ./tools/tar; bunzip2 = ./tools/bunzip2; cp = ./tools/cp; - inherit curl url; - system = "i686-linux"; - args = [ ./scripts/download-script ]; + args = [ ./scripts/unpack.sh ]; + tarball = download {inherit url md5 pkgname;}; inherit postProcess addToPath extra extra2 extra3 extra4 patchelf; }; # The various statically linked components that make up the standard # environment. - staticTools = download { - url = http://catamaran.labs.cs.uu.nl/dist/tarballs/stdenv-linux/////static.tar.bz2; + staticTools = downloadAndUnpack { + url = http://catamaran.labs.cs.uu.nl/dist/tarballs/stdenv-linux/static-tools.tar.bz2; pkgname = "static-tools"; + md5 = "9419d3dcccbe1af10d9d0d7d54269785"; }; - binutils = download { + binutils = downloadAndUnpack { url = http://catamaran.labs.cs.uu.nl/dist/tarballs/stdenv-linux/binutils-2.15-static.tar.bz2; pkgname = "binutils"; + md5 = "9c134038b7f1894a4b307d600207047c"; }; - gcc = (download {url = http://catamaran.labs.cs.uu.nl/dist/tarballs/stdenv-linux/gcc-3.4.2-static.tar.bz2; + gcc = (downloadAndUnpack { + url = http://catamaran.labs.cs.uu.nl/dist/tarballs/stdenv-linux/gcc-3.4.2-static.tar.bz2; pkgname = "gcc"; + md5 = "600452fac470a49a41ea81d39c209f35"; postProcess = [./scripts/fix-outpath.sh]; addToPath = [staticTools]; }) // { langC = true; langCC = false; langF77 = false; }; - glibc = download { + glibc = downloadAndUnpack { url = http://catamaran.labs.cs.uu.nl/dist/tarballs/stdenv-linux/glibc-2.3.3-static.tar.bz2; pkgname = "glibc"; + md5 = "36ff244e666c60784edfe1cc66f68e4c"; postProcess = [./scripts/fix-outpath.sh]; addToPath = [staticTools]; }; diff --git a/pkgs/stdenv/linux/scripts/builder-stdenv-initial.sh b/pkgs/stdenv/linux/scripts/builder-stdenv-initial.sh index eca7adfac743..f2867b3cbb58 100644 --- a/pkgs/stdenv/linux/scripts/builder-stdenv-initial.sh +++ b/pkgs/stdenv/linux/scripts/builder-stdenv-initial.sh @@ -1,4 +1,3 @@ -set -x set -e PATH=$coreutils/bin diff --git a/pkgs/stdenv/linux/scripts/download.sh b/pkgs/stdenv/linux/scripts/download.sh new file mode 100644 index 000000000000..1d010f88d1e4 --- /dev/null +++ b/pkgs/stdenv/linux/scripts/download.sh @@ -0,0 +1,3 @@ +set -e +echo "downloading $out from $url" +$curl/bin/curl --fail --location --max-redirs 20 "$url" > "$out" diff --git a/pkgs/stdenv/linux/scripts/curl-unpack b/pkgs/stdenv/linux/scripts/unpack-curl.sh similarity index 100% rename from pkgs/stdenv/linux/scripts/curl-unpack rename to pkgs/stdenv/linux/scripts/unpack-curl.sh diff --git a/pkgs/stdenv/linux/scripts/download-script b/pkgs/stdenv/linux/scripts/unpack.sh similarity index 65% rename from pkgs/stdenv/linux/scripts/download-script rename to pkgs/stdenv/linux/scripts/unpack.sh index e5dd0044e381..6ba1f1bddd81 100644 --- a/pkgs/stdenv/linux/scripts/download-script +++ b/pkgs/stdenv/linux/scripts/unpack.sh @@ -1,10 +1,6 @@ set -e -echo "using curl executable $curl" - -$curl/bin/curl "$url" > .tmp - -$bunzip2 -d < .tmp | $tar xvf - +$bunzip2 -d < $tarball | $tar xvf - $cp -prd * $out