Browse Source

Added per-package options, documented a bit more

master
mid-kid 9 years ago
parent
commit
accd076d0c
  1. 47
      astronaut/astronaut

47
astronaut/astronaut

@ -1,15 +1,37 @@
#!/bin/sh -e
# Configuration
# Build/install-time directories
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
# Runtime directories
dir_sysroot="" # The root directory of the system
dir_prefix="/usr" # Prefix directory (for /bin, /lib, /share and such)
# Default commands
cmd_download="curl -# -L -o {dst} {src}" # Command to execute to download files
cmd_extract="tar -x -C {dst} -f {src}" # Command to execute to extract files
unset dir_satellites # Directory where the satellite files are placed.
unset options
# If we can't find the satellite file, we'll look in this directory for it.
unset dir_satellites
# Options are comma-separated and parsed from front to back.
# This means that in "!opt,someotheropt,opt", opt is disabled.
unset options # The least-priority global options
package_options() { :; } # Per-package options function.
# Example for package_options:
# package_options() {
# case "$1" in
# package1) echo "opt1,opt2,opt3" ;;
# package2) echo "someotheropts" ;;
# esac
# }
# Load any user configuration
[ -f /etc/astronaut.conf ] && . /etc/astronaut.conf
[ -f "$HOME/.astronaut.conf" ] && . "$HOME/.astronaut.conf"
@ -17,6 +39,7 @@ unset options
_download_only=false
_vcs_only=false
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)
# Some printing functions
@ -34,7 +57,14 @@ Usage: $0 [-sbipr <dir>] [-Id] [-o <options>] <satellite>
-I Nuke install directory before build [WARNING: You will not be prompted]
-d Only download package files
-v Only build vcs package if any updates have been made to it
-o Set package options (comma-separated)"
-o Set package options (comma-separated)
Tips:
- Use \`head -n 32 $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.
"
}
_msg() {
@ -78,7 +108,7 @@ while getopts "h?s:b:i:r:p:IcCdvo:" opt; do
_vcs_only=true
;;
o)
options="$options,$OPTARG"
_user_options="$OPTARG,$_user_options"
;;
esac
done
@ -164,15 +194,19 @@ option() {
local enabled=false
local opt
local IFS=','; for option in $options; do
local option_negate=false
case "$option" in
*=*)
local value="$(echo "$option" | cut -d '=' -f 2)"
local option="$(echo "$option" | cut -d '=' -f 1)"
;;
!*)
local option="$(echo "$option" | cut -c 2-)"
local option_negate=true
esac
if [ "$option" = "$check" ]; then
local enabled=true
[ "$option_negate" = true ] && local enabled=false || local enabled=true
break
fi
done
@ -243,6 +277,9 @@ if [ ! -f "$_satellite" ]; then
fi
fi
# Build the definitive options list
options="$_user_options$(package_options "$_satname"),$options"
# Create the directories
if [ "$_download_only" = false ]; then
# This variable can be set by a wrapper script in need to nuke the install dir.

Loading…
Cancel
Save