stdenv: Move unzip support to unzip's setup hook

This commit is contained in:
Eelco Dolstra 2014-06-30 14:12:35 +02:00
parent f97ee61255
commit d7b356f73b
3 changed files with 11 additions and 7 deletions

View file

@ -489,23 +489,20 @@ addHook unpackCmd _defaultUnpack
_defaultUnpack() {
if [ -d "$curSrc" ]; then
stripHash $curSrc
cp -prd --no-preserve=timestamps $curSrc $strippedName
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 -
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
tar xf "$curSrc"
;;
*)
return 1

View file

@ -31,6 +31,8 @@ stdenv.mkDerivation {
installFlags = "prefix=$(out)";
setupHook = ./setup-hook.sh;
meta = {
homepage = http://www.info-zip.org;
description = "An extraction utility for archives compressed in .zip format";

View file

@ -0,0 +1,5 @@
addHook unpackCmd _tryUnzip
_tryUnzip() {
if ! [[ "foo.zip" =~ \.zip$ ]]; then return 1; fi
unzip -qq "$curSrc"
}