From 558f26d5770d3bf3d60be6b25569dcf24d8f5503 Mon Sep 17 00:00:00 2001 From: mid-kid Date: Wed, 12 Nov 2014 22:05:27 +0100 Subject: [PATCH] Started config thingy for default commands, commented example satellite --- astronaut | 17 +++++++++++------ hello.sat | 13 +++++++++++-- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/astronaut b/astronaut index e428267..37caa4a 100755 --- a/astronaut +++ b/astronaut @@ -60,6 +60,10 @@ if [ ! -f "$satellite" ]; then exiterr "Can't find satellite file" fi +# Configuration +cmd_download="curl -#L -o {dst} {src}" +cmd_extract="tar xf {src}" + # Tools for the astronaut mksum() { echo $(md5sum "$@" 2> /dev/null | cut -d' ' -f1) @@ -75,11 +79,12 @@ download() { if [ ! -f "$path" -o "$checksum" != "$2" ]; then msg "Downloading $name" if [ "$3" ]; then - local cmd="$(echo "$2" | sed -e 's@{dst}@'"$path"'@g' -e 's@{source}@'"$1"'@g')" - $cmd + local cmd="$3" else - curl -#L -o "$path" "$1" + local cmd="$cmd_download" fi + $(echo "$cmd" | sed -e 's@{dst}@'"$path"'@g' -e 's@{src}@'"$1"'@g') + checksum="$(mksum "$path")" if [ "$2" -a "$checksum" != "$2" ]; then msg "Checksum: $checksum" @@ -91,11 +96,11 @@ download() { extract() { msg "Extracting $1" if [ "$2" ]; then - local cmd="$(echo "$2" | sed -e 's@{src}@'"$dir_source/$1"'@g')" - $cmd + local cmd="$2" else - tar xf "$dir_source/$1" + local cmd="$cmd_extract" fi + $(echo "$cmd" | sed -e 's@{src}@'"$dir_source/$1"'@g') } dlextract() { diff --git a/hello.sat b/hello.sat index 10a522e..669ecc6 100644 --- a/hello.sat +++ b/hello.sat @@ -1,11 +1,20 @@ # Example of a satellite file, which is just a shell script with a cool name. +# Info (Please declare it, as it will be used outside of this script, too) name=hello version=2.9 -dlextract "http://ftp.gnu.org/pub/gnu/$name/$name-$version.tar.gz" \ - "67607d2616a0faaf5bc94c59dca7c3cb" +# Get them files +download "http://ftp.gnu.org/pub/gnu/$name/$name-$version.tar.gz" \ # URL [REQUIRED] + "67607d2616a0faaf5bc94c59dca7c3cb" \ # MD5sum [REQUIRED] + "curl -L -o {dst} {src}" # Custom command +extract "$name-$version.tar.gz" \ # Name [REQUIRED] + "tar xvf {src}" # Custom command +#dlextract "http://ftp.gnu.org/pub/gnu/$name/$name-$version.tar.gz" \ # Abbreviation for the above functions +# "67607d2616a0faaf5bc94c59dca7c3cb" # Does not allow custom commands +#extrafile "Herpaderp.txt" # Copy local file to build directory. Path relative to the location of the satellite file +# Compilation instructions cd "$name-$version" ./configure make