From 1a44dbbbb900acb993fc68995fc3cfb50e5122ba Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 30 Jun 2014 13:21:30 +0200 Subject: [PATCH] unpackFile: Always copy directories If $src refers to a directory, then always copy it. Previously, we checked the extension first, so if the directory had an extension like .tar, unpackPhase would fail. --- pkgs/build-support/fetchzip/default.nix | 4 +-- pkgs/stdenv/generic/setup.sh | 46 ++++++++++++++----------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/pkgs/build-support/fetchzip/default.nix b/pkgs/build-support/fetchzip/default.nix index 7c6e16a05892..12fb69ba8efd 100644 --- a/pkgs/build-support/fetchzip/default.nix +++ b/pkgs/build-support/fetchzip/default.nix @@ -13,9 +13,7 @@ , ... } @ args: fetchurl ({ - # Remove the extension, because otherwise unpackPhase will get - # confused. FIXME: fix unpackPhase. - name = args.name or lib.removeSuffix ".zip" (lib.removeSuffix ".tar.gz" (baseNameOf url)); + name = args.name or (baseNameOf url); recursiveHash = true; diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 286e9e019b1d..c3ebc3e9b5f0 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -475,32 +475,36 @@ unpackFile() { header "unpacking source archive $curSrc" 3 - case "$curSrc" in - *.tar.xz | *.tar.lzma) - # Don't rely on tar knowing about .xz. - xz -d < $curSrc | tar xf - - ;; - *.tar | *.tar.* | *.tgz | *.tbz2) - # GNU tar can automatically select the decompression method - # (info "(tar) gzip"). - tar xf $curSrc - ;; - *.zip) - unzip -qq $curSrc - ;; - *) - if [ -d "$curSrc" ]; then - stripHash $curSrc - cp -prd --no-preserve=timestamps $curSrc $strippedName - else + if [ -d "$curSrc" ]; then + + stripHash $curSrc + cp -prd --no-preserve=timestamps $curSrc $strippedName + + else + + case "$curSrc" in + *.tar.xz | *.tar.lzma) + # Don't rely on tar knowing about .xz. + xz -d < $curSrc | tar xf - + ;; + *.tar | *.tar.* | *.tgz | *.tbz2) + # GNU tar can automatically select the decompression method + # (info "(tar) gzip"). + tar xf $curSrc + ;; + *.zip) + unzip -qq $curSrc + ;; + *) if [ -z "$unpackCmd" ]; then echo "source archive $curSrc has unknown type" exit 1 fi runSingleHook unpackCmd - fi - ;; - esac + ;; + esac + + fi stopNest }