Browse Source

Added custom filenames to the download command

master
mid-kid 8 years ago
parent
commit
f518214d31
  1. 4
      astronaut/astronaut
  2. 3
      astronaut/examples/hello.sat

4
astronaut/astronaut

@ -161,7 +161,7 @@ safe_sed() {
download() {
mkdir -p "$dir_source/$name"
local filename="$(basename $(echo "$1" | cut -d? -f1))"
[ "$3" ] && local filename="$3" || local filename="$(basename $(echo "$1" | cut -d? -f1))"
local path="$dir_source/$name/$filename"
[ "$2" -a -f "$path" ] && local checksum="$(_mksum "$path")"
@ -169,7 +169,7 @@ download() {
if [ ! -e "$path" -o "$checksum" != "$2" ]; then
_msg "Downloading $filename"
[ "$3" ] && local cmd="$3" || local cmd="$cmd_download"
[ "$4" ] && local cmd="$4" || local cmd="$cmd_download"
eval $(echo "$cmd" | sed -e "s/{dst}/'$(safe_sed "$path")'/g" -e "s/{src}/'$(safe_sed "$1")'/g")
checksum="$(_mksum "$path")"

3
astronaut/examples/hello.sat

@ -44,9 +44,10 @@ define_option 'test=Default value' # It is also allowed to provide no descripti
# - options
# Get them files.
# URL [REQUIRED], MD5sum, Custom command
# URL [REQUIRED], MD5sum, Custom filename, Custom command
download "https://ftp.gnu.org/gnu/$name/$name-$version.tar.gz" \
'6cd0ffea3884a4e79330338dcc2987d6' \
"$name-$version.tar.gz" \
'curl -L -o {dst} {src}'
# Abbreviation download and extract. Does not allow custom commands.

Loading…
Cancel
Save