tl-makepkg/tl-makepkg

39 lines
1.0 KiB
Bash

#!/bin/bash
declare -A config
errmsg() {
echo "Error in ${FUNCNAME[1]}: $1" >&2
}
config_parse() { # Usage: config_parse <CONFIG_FILE>
if [[ ! -f "$1" ]]; then
errmsg "config file '$1' doesn't exist"
exit 1
fi
while IFS='' read -r line || [[ -n "$line" ]]; do
local option=${line%%= *}
local value=${line##* =} # ref: http://wiki.bash-hackers.org/syntax/pe#substring_removal
config["$option"]=$value
done < <(pacini "$1") # Thanks to alad for showing me pacini
}
makepkg_run() { # Usage: makepkg_run <RepoDir> <MakepkgOpts>
PKGDEST="$1"
shift 1
makepkg "$@"
}
repose_run() { # Usage: repose_run <ReposeOpts> <RepoDir> <DBFile>
repose $1 --root "$2" --pool "$2" "$3"
}
# If not running interactively, don't do anything
# Allows for using these functions as commands by sourcing this script
[[ $- != *i* ]] && return
config_parse "${CONFIG_FILE:-/etc/tl-makepkg.conf}"
makepkg_run "${config[RepoDir]}" "${config[MakepkgOpts]} $@"
repose_run "${config[ReposeOpts]}" "${config[RepoDir]}" "${config[DBFile]}"