Add --ext option to nix-prefetch-zip
This commit is contained in:
parent
6ad8fab785
commit
91a2973dc3
|
@ -6,6 +6,7 @@ usage(){
|
||||||
Options:
|
Options:
|
||||||
--url url The url of the archive to fetch.
|
--url url The url of the archive to fetch.
|
||||||
--name name The name to use for the store path (defaults to \`basename \$url\`).
|
--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 hash The hash of unpacked archive.
|
||||||
--hash-type type Use the specified cryptographic hash algorithm, which can be one of md5, sha1, and sha256.
|
--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.
|
--leave-root Keep the root directory of the archive.
|
||||||
|
@ -16,6 +17,7 @@ Options:
|
||||||
|
|
||||||
|
|
||||||
name=""
|
name=""
|
||||||
|
ext=""
|
||||||
argi=0
|
argi=0
|
||||||
argfun=""
|
argfun=""
|
||||||
for arg; do
|
for arg; do
|
||||||
|
@ -23,6 +25,7 @@ for arg; do
|
||||||
case $arg in
|
case $arg in
|
||||||
--url) argfun=set_url;;
|
--url) argfun=set_url;;
|
||||||
--name) argfun=set_name;;
|
--name) argfun=set_name;;
|
||||||
|
--ext) argfun=set_ext;;
|
||||||
--hash) argfun=set_expHash;;
|
--hash) argfun=set_expHash;;
|
||||||
--hash-type) argfun=set_hashType;;
|
--hash-type) argfun=set_hashType;;
|
||||||
--leave-root) leaveRoot=true;;
|
--leave-root) leaveRoot=true;;
|
||||||
|
@ -67,10 +70,12 @@ hashFormat="--base32"
|
||||||
tmp=$(mktemp -d 2>/dev/null || mktemp -d -t "$$")
|
tmp=$(mktemp -d 2>/dev/null || mktemp -d -t "$$")
|
||||||
trap "rm -rf '$tmp'" EXIT
|
trap "rm -rf '$tmp'" EXIT
|
||||||
|
|
||||||
unpackDirTmp=$tmp/unpacked-tmp/$name
|
dirname=$(basename -s "$ext" "$name")
|
||||||
|
|
||||||
|
unpackDirTmp=$tmp/unpacked-tmp/$dirname
|
||||||
mkdir -p $unpackDirTmp
|
mkdir -p $unpackDirTmp
|
||||||
|
|
||||||
unpackDir=$tmp/unpacked/$name
|
unpackDir=$tmp/unpacked/$dirname
|
||||||
mkdir -p $unpackDir
|
mkdir -p $unpackDir
|
||||||
|
|
||||||
downloadedFile=$tmp/$name
|
downloadedFile=$tmp/$name
|
||||||
|
|
Loading…
Reference in a new issue