tl-makepkg/tl-makepkg

34 lines
825 B
Bash

#!/bin/bash
declare -A config
errmsg() {
echo "Error in ${FUNCNAME[1]}: $1" >&2
}
config_parse() {
# Parses 'name=value' pairs from the input file to the config array
if [[ ! -f "$1" ]]; then
errmsg "config file '$1' doesn't exist"
exit 1
fi
while IFS='' read -r line || [[ -n "$line" ]]; do
#[[ "$line" =~ ^#.*$ ]] && continue # Skip lines that start with '#'
local option=${line%%=*}
local value=${line##*=} # ref: http://wiki.bash-hackers.org/syntax/pe#substring_removal
config["$option"]=$value
done < <(sed '/^$/d;/^#.*$/d' "$1")
}
makepkg_run() {
PKGDEST="${config[REPO_DIR]}" makepkg ${config[MAKEPKG_OPTS]} "$@"
}
repose_run() {
repose ${config[REPOSE_OPTS]} --pool "${config[REPO_DIR]}" "${config[DB_FILE]}"
}
config_parse "${CONFIG_FILE:-/etc/tl-makepkg.conf}"
makepkg_run "$@"
repose_run