From 865cfe59509bf45f01ba9411df624cbe2bceb844 Mon Sep 17 00:00:00 2001 From: mid-kid Date: Wed, 29 Jun 2016 16:06:35 +0200 Subject: [PATCH] Add string replacement for dir_install --- astronaut/astronaut | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/astronaut/astronaut b/astronaut/astronaut index a9f5bfb..6cd038d 100755 --- a/astronaut/astronaut +++ b/astronaut/astronaut @@ -6,6 +6,10 @@ dir_build="/tmp/astronaut/build" # Temporary directory to build packages dir_source="/tmp/astronaut/source" # Directory where the package sources will be placed dir_install="/tmp/astronaut/install" # Directory where the package will be installed +# The source directory will have subdirs for each different $name, +# specified inside the satellite file. +# The $dir_install variable will have '{pkg}' replaced with $_satname, +# which is the filename of the satellite, without the .sat suffix. # Runtime directories dir_sysroot="/" # The root directory of the system @@ -42,6 +46,11 @@ vcs_compile=false unset _user_options # Options specified in the command line get the highest priority #_nuke_dir_install (This can be set from wrappers) +# Should be specified in the satellite +unset name +unset version +unset update_url + # Some printing functions _show_help() { echo "This astronaut will help you build some satellites. @@ -60,7 +69,7 @@ Usage: $0 [-sbipr ] [-Id] [-o ] -o Set package options (comma-separated) Tips: -- Use \`head -n 32 $0 > astronaut.conf.example\` to generate a default configuration file. +- Use \`head -n 36 $0 > astronaut.conf.example\` to generate a default configuration file. - Keep in mind that when specifying options on the command line in a string, the first always takes priority. For example, in \"opt,someotheropt,!opt\", opt is enabled, due to it being the first occurrence. - If you have set \$dir_satellites in the config, you can omit the .sat suffix. @@ -126,6 +135,10 @@ _mksum() { echo "$(md5sum "$@" 2> /dev/null | cut -d' ' -f1)" } +_safe_sed() { + echo "$1" | sed 's/[[\.*^$/]/\\&/g' +} + download() { mkdir -p "$dir_source/$name" @@ -138,7 +151,7 @@ download() { _msg "Downloading $filename" [ "$3" ] && local cmd="$3" || local cmd="$cmd_download" - eval $(echo "$cmd" | sed -e "s@{dst}@'$path'@g" -e "s@{src}@'$1'@g") + eval $(echo "$cmd" | sed -e "s@{dst}@'$(_safe_sed "$path")'@g" -e "s@{src}@'$(_safe_sed "$1")'@g") checksum="$(_mksum "$path")" if [ "$2" -a "$checksum" != "$2" ]; then @@ -287,6 +300,9 @@ mkdir -p "$dir_source" dir_source="$(realpath "$dir_source")" if [ "$_download_only" = false ]; then + # Fix up the install path + dir_install="$(echo "$dir_install" | sed -e "s@{pkg}@$(_safe_sed "$satname")@g")" + # This variable can be set by a wrapper script in need to nuke the install dir. if [ "$_nuke_dir_install" = true -a ! -z "$dir_install" ]; then rm -rf "$dir_install"