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.
This commit is contained in:
Eelco Dolstra 2014-06-30 13:21:30 +02:00
parent 5e82aab5d4
commit 1a44dbbbb9
2 changed files with 26 additions and 24 deletions

View file

@ -13,9 +13,7 @@
, ... } @ args: , ... } @ args:
fetchurl ({ fetchurl ({
# Remove the extension, because otherwise unpackPhase will get name = args.name or (baseNameOf url);
# confused. FIXME: fix unpackPhase.
name = args.name or lib.removeSuffix ".zip" (lib.removeSuffix ".tar.gz" (baseNameOf url));
recursiveHash = true; recursiveHash = true;

View file

@ -475,6 +475,13 @@ unpackFile() {
header "unpacking source archive $curSrc" 3 header "unpacking source archive $curSrc" 3
if [ -d "$curSrc" ]; then
stripHash $curSrc
cp -prd --no-preserve=timestamps $curSrc $strippedName
else
case "$curSrc" in case "$curSrc" in
*.tar.xz | *.tar.lzma) *.tar.xz | *.tar.lzma)
# Don't rely on tar knowing about .xz. # Don't rely on tar knowing about .xz.
@ -489,19 +496,16 @@ unpackFile() {
unzip -qq $curSrc unzip -qq $curSrc
;; ;;
*) *)
if [ -d "$curSrc" ]; then
stripHash $curSrc
cp -prd --no-preserve=timestamps $curSrc $strippedName
else
if [ -z "$unpackCmd" ]; then if [ -z "$unpackCmd" ]; then
echo "source archive $curSrc has unknown type" echo "source archive $curSrc has unknown type"
exit 1 exit 1
fi fi
runSingleHook unpackCmd runSingleHook unpackCmd
fi
;; ;;
esac esac
fi
stopNest stopNest
} }