From 91a2973dc3a33f76fa212be1258c00ea81c2d21e Mon Sep 17 00:00:00 2001 From: obadz Date: Tue, 30 Jun 2015 18:57:21 +0100 Subject: Add --ext option to nix-prefetch-zip --- pkgs/build-support/fetchzip/nix-prefetch-zip | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'pkgs/build-support') diff --git a/pkgs/build-support/fetchzip/nix-prefetch-zip b/pkgs/build-support/fetchzip/nix-prefetch-zip index ccc03e087e52..aeea134f1922 100755 --- a/pkgs/build-support/fetchzip/nix-prefetch-zip +++ b/pkgs/build-support/fetchzip/nix-prefetch-zip @@ -6,6 +6,7 @@ usage(){ Options: --url url The url of the archive to fetch. --name name The name to use for the store path (defaults to \`basename \$url\`). + --ext ext The file extension (.zip, .tar.gz, ...) to be REMOVED from name --hash hash The hash of unpacked archive. --hash-type type Use the specified cryptographic hash algorithm, which can be one of md5, sha1, and sha256. --leave-root Keep the root directory of the archive. @@ -16,6 +17,7 @@ Options: name="" +ext="" argi=0 argfun="" for arg; do @@ -23,6 +25,7 @@ for arg; do case $arg in --url) argfun=set_url;; --name) argfun=set_name;; + --ext) argfun=set_ext;; --hash) argfun=set_expHash;; --hash-type) argfun=set_hashType;; --leave-root) leaveRoot=true;; @@ -67,10 +70,12 @@ hashFormat="--base32" tmp=$(mktemp -d 2>/dev/null || mktemp -d -t "$$") trap "rm -rf '$tmp'" EXIT -unpackDirTmp=$tmp/unpacked-tmp/$name +dirname=$(basename -s "$ext" "$name") + +unpackDirTmp=$tmp/unpacked-tmp/$dirname mkdir -p $unpackDirTmp -unpackDir=$tmp/unpacked/$name +unpackDir=$tmp/unpacked/$dirname mkdir -p $unpackDir downloadedFile=$tmp/$name -- cgit 1.4.1