summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/abslibre-tools/createworkdir3
-rwxr-xr-xsrc/abslibre-tools/diff-unfree3
-rwxr-xr-xsrc/abslibre-tools/libreaddiff3
-rwxr-xr-xsrc/abslibre-tools/libredbdiff5
-rwxr-xr-xsrc/abslibre-tools/librerelease19
-rwxr-xr-xsrc/abslibre-tools/librestage10
-rwxr-xr-xsrc/aur3
-rwxr-xr-xsrc/chroot-tools/librechroot4
-rwxr-xr-xsrc/chroot-tools/libremakepkg3
-rwxr-xr-xsrc/dagpkg11
-rw-r--r--src/lib/blacklist.sh3
-rw-r--r--src/lib/conf.sh.3.ronn11
-rw-r--r--src/lib/conf.sh.in50
-rwxr-xr-xsrc/librefetch/librefetch3
-rwxr-xr-xsrc/toru/toru-path15
-rwxr-xr-xsrc/toru/toru-where3
-rwxr-xr-xsrc/xbs-abs/helper-abs3
-rwxr-xr-xsrc/xbs-abslibre/helper-abslibre3
-rwxr-xr-xsrc/xbs/xbs6
19 files changed, 63 insertions, 98 deletions
diff --git a/src/abslibre-tools/createworkdir b/src/abslibre-tools/createworkdir
index e3e4143..6f58b05 100755
--- a/src/abslibre-tools/createworkdir
+++ b/src/abslibre-tools/createworkdir
@@ -29,8 +29,7 @@ set -euE
. "$(librelib conf)"
main() {
- load_files libretools
- check_vars libretools WORKDIR ABSLIBRERECV ABSLIBRESEND # these are asked for by `xbs download`
+ load_conf libretools.conf WORKDIR ABSLIBRERECV ABSLIBRESEND || exit # these are asked for by `xbs download`
trap 'error "Aborting..."' EXIT
diff --git a/src/abslibre-tools/diff-unfree b/src/abslibre-tools/diff-unfree
index 2d54379..860c985 100755
--- a/src/abslibre-tools/diff-unfree
+++ b/src/abslibre-tools/diff-unfree
@@ -40,8 +40,7 @@ main() {
return 0
fi
- load_files libretools
- check_vars libretools DIFFPROG || return 1
+ load_conf libretools.conf DIFFPROG || exit
local package_guess=${PWD##*/}
local repo=${1:-$(basename "${PWD%/*}")}
diff --git a/src/abslibre-tools/libreaddiff b/src/abslibre-tools/libreaddiff
index b0e2c1d..9336198 100755
--- a/src/abslibre-tools/libreaddiff
+++ b/src/abslibre-tools/libreaddiff
@@ -33,8 +33,7 @@ usage() {
}
main() {
- load_files libretools
- check_vars libretools WORKDIR
+ load_conf libretools.conf WORKDIR || exit
while getopts 'h' arg; do
case "$arg" in
diff --git a/src/abslibre-tools/libredbdiff b/src/abslibre-tools/libredbdiff
index 1903c8c..5d301f6 100755
--- a/src/abslibre-tools/libredbdiff
+++ b/src/abslibre-tools/libredbdiff
@@ -22,7 +22,6 @@
set -euE -o pipefail
. "$(librelib messages)"
. "$(librelib conf)"
-load_files libredbdiff || exit
setup_traps
declare -r name="Libredbdiff"
@@ -245,7 +244,7 @@ main_update() {
usage >&2
exit 1
fi
- check_vars libredbdiff statedir mirror_prbl mirror_arch || exit 1
+ load_conf libredbdiff.conf statedir mirror_prbl mirror_arch || exit
createdir "$statedir"
{
@@ -297,7 +296,7 @@ main_update() {
}
main_compare() {
- check_vars libredbdiff statedir repos || exit 1
+ load_conf libredbdiff.conf statedir repos || exit
if ! [[ -f "$conffile_prbl" && \
-f "$conffile_arch" && \
diff --git a/src/abslibre-tools/librerelease b/src/abslibre-tools/librerelease
index 51cf6de..e673081 100755
--- a/src/abslibre-tools/librerelease
+++ b/src/abslibre-tools/librerelease
@@ -164,21 +164,10 @@ main() {
return 0
fi
- # defer exiting on errors until we've tried to parse *all*
- # config files, to have more complete error messages.
- local err=false
- {
- load_files makepkg &&
- check_vars makepkg GPGKEY
- } || err=true
- {
- load_files libretools &&
- # the HOOK* are settings are optional
- check_vars libretools WORKDIR REPODEST ABSLIBREDEST # HOOKPRERELEASE HOOKPOSTRELEASE
- } || err=true
- if $err; then
- return 6
- fi
+ declare -i ret=0
+ load_conf makepkg.conf GPGKEY || ret=$?
+ load_conf libretools.conf WORKDIR REPODEST ABSLIBREDEST || ret=$? # and HOOK{PRE,POST}RELEASE, which are optional
+ [[ $ret = 0 ]] || exit $ret
local re_url='^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$'
local re_authority='^(([^@]*)@)?([^][@:]*|\[[^]]*\])(:([0-9]*))?$'
diff --git a/src/abslibre-tools/librestage b/src/abslibre-tools/librestage
index 74de8fb..0794b13 100755
--- a/src/abslibre-tools/librestage
+++ b/src/abslibre-tools/librestage
@@ -60,10 +60,12 @@ main() {
fi
# Load configuration
- load_files libretools
- check_vars libretools WORKDIR || return 1
- load_files makepkg # for PKGDEST, SRCDEST, and SRCPKGDEST, which are optional
- load_files librefetch # for MIRRORS, which is optional
+ declare -i ret=0
+ load_conf libretools.conf WORKDIR || ret=$?
+ load_conf makepkg.conf || ret=$? # for PKGDEST, SRCDEST, and SRCPKGDEST, which are optional
+ load_conf librefetch.conf || ret=$? # for MIRRORS, which is optional
+ [[ $ret = 0 ]] || exit $ret
+
SRCPKGPOOL="$WORKDIR/staging/sources/parabola"
# Load the PKGBUILD
diff --git a/src/aur b/src/aur
index 8f69505..314bfe7 100755
--- a/src/aur
+++ b/src/aur
@@ -46,8 +46,7 @@ main() {
fi
. "$(librelib conf)"
- load_files libretools
- check_vars libretools DIFFPROG || exit 1
+ load_conf libretools.conf libretools DIFFPROG || exit
local startdir=$PWD
local missing_deps=()
diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot
index 7b1c8c2..db4c87b 100755
--- a/src/chroot-tools/librechroot
+++ b/src/chroot-tools/librechroot
@@ -37,8 +37,6 @@ set -euE
shopt -s nullglob
umask 0022
-load_files chroot
-
################################################################################
# Wrappers for files in ${pkglibexecdir}/chroot/ #
################################################################################
@@ -380,7 +378,7 @@ main() {
return 0
fi
- check_vars chroot CHROOTDIR CHROOT
+ load_conf chroot.conf CHROOTDIR CHROOT
eval "$(calculate_directories)"
readonly LIBREUSER LIBREHOME
diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg
index 019bae1..02b31a8 100755
--- a/src/chroot-tools/libremakepkg
+++ b/src/chroot-tools/libremakepkg
@@ -212,8 +212,7 @@ main() {
if $INCHROOT; then
copydir='/'
else
- load_files chroot
- check_vars chroot CHROOTDIR CHROOT
+ load_conf chroot.conf CHROOTDIR CHROOT || exit
[[ -z ${chroot} ]] || CHROOT=$chroot
if [[ ${copy:0:1} = / ]]; then
copydir=$copy
diff --git a/src/dagpkg b/src/dagpkg
index d6f7cca..f205390 100755
--- a/src/dagpkg
+++ b/src/dagpkg
@@ -137,13 +137,10 @@ visit_pkgbuild() {
main() {
# Source variables from libretools
- load_files libretools
- check_vars libretools FULLBUILDCMD || exit 1
- #check_vars libretools HOOKPREBUILD HOOKLOCALRELEASE || exit 1 # optional
-
- # Source variables from makepkg
- load_files makepkg
- check_vars makepkg CARCH || exit 1
+ declare -i ret=0
+ load_conf libretools.conf FULLBUILDCMD || ret=$ # and HOOK{PRE,POST}BUILD, which are optional
+ load_conf makepkg.conf CARCH || ret=$?
+ [[ $ret = 0 ]] || exit $ret
setup_traps trap_exit
diff --git a/src/lib/blacklist.sh b/src/lib/blacklist.sh
index 9597bbc..fc07815 100644
--- a/src/lib/blacklist.sh
+++ b/src/lib/blacklist.sh
@@ -43,8 +43,7 @@ blacklist-cat() {
# Updates (or creates) the cached copy of the blacklist.
blacklist-update() (
. "$(librelib messages)"
- load_files libretools || return 1
- check_vars libretools BLACKLIST || return 1
+ load_conf libretools.conf BLACKLIST || return
local remote_blacklist="$BLACKLIST"
local local_blacklist="$XDG_CACHE_HOME/libretools/blacklist.txt"
diff --git a/src/lib/conf.sh.3.ronn b/src/lib/conf.sh.3.ronn
index 0974bdb..c17a3ee 100644
--- a/src/lib/conf.sh.3.ronn
+++ b/src/lib/conf.sh.3.ronn
@@ -47,14 +47,13 @@ configuration files; that is the basename of the files. For example,
The routines you will likely actually use are:
- * `load_files` <SLUG>:
+ * `load_conf` <SLUG>.conf <VARS>...:
Loads the configuration files for <SLUG>, loading the files in
the correct order, and checking the appropriate environmental
- variables.
- * `check_vars` <SLUG> <VARS>...:
- Checks to see if all of <VARS> are defined. If any of them
- aren't, it prints a message telling the user to configure them in
- the configuration files for <SLUG>, and returns with a non-zero
+ variables. If any <VARS> are listed, check to make sure that
+ each of them are defined. If any of them are not defined, it
+ prints a message telling the user to configure them in the
+ configuration files for <SLUG>, and returns with a non-zero
status.
* `get_var` <SLUG> <VAR> <DEFAULT>:
If <VAR> is set in the configuration for <SLUG>, print its
diff --git a/src/lib/conf.sh.in b/src/lib/conf.sh.in
index 18760e1..7d1646b 100644
--- a/src/lib/conf.sh.in
+++ b/src/lib/conf.sh.in
@@ -104,22 +104,26 @@ list_envvars() {
# High-level generic functions #################################################
-# Usage: load_files $slug
-# Loads the configuration files for $slug in the proper order.
-load_files() {
- local slug=$1
- local var
- local file
+# Usage: load_conf $slug.conf [VAR1 VAR2...]
+#
+# Loads the configuration files for $slug in the proper order, and
+# optionally verify that certain variables are set.
+load_conf() {
+ [[ "$1" = *.conf ]] || libremessages panic || exit 1
+ local slug=${1%.conf}
+ shift
+
+ local var file
# Save the existing versions at _VARNAME
while read -r var; do
- [[ -n ${!var:-} ]] && eval "_$var=\${$var}"
+ [[ -n ${!var:-} ]] && eval "local _$var=\${$var}"
done < <(list_envvars "$slug")
# Load the files
while read -r file; do
if [[ -r $file ]]; then
- . "$file" || return 1
+ . "$file" || return 6
fi
done < <(list_files "$slug")
@@ -127,33 +131,21 @@ load_files() {
while read -r var; do
eval "$var=\${_$var:-\${$var:-}}"
done < <(list_envvars "$slug")
-}
-
-# Usage: check_vars $slug VAR1 VAR2...
-# Check whether the variables listed are properly set.
-# If not, it prints a message saying to set them in the configuration file(s)
-# for $slug.
-check_vars() {
- local slug=$1; shift
- local ret=0
-
- local VAR
- for VAR in "$@"; do
- if [[ -z ${!VAR:-} ]]; then
+ # Verify that the variables we need were set
+ declare -i ret=0
+ for var in "$@"; do
+ if [[ -z ${!var:-} ]]; then
if [[ $(list_files "$slug"|wc -l) -gt 1 ]]; then
- libremessages _l print "Configure '%s' in one of:" "$VAR"
+ libremessages _l print "Configure '%s' in one of:" "$var"
list_files "$slug" | sed 's/./ -> &/'
else
- libremessages _l print "Configure '%s' in '%s'" "$VAR" "$(list_files "$slug")"
+ libremessages _l print "Configure '%s' in '%s'" "$var" "$(list_files "$slug")"
fi
- ret=1
+ ret=6
fi
done >&2
-
- if [[ $ret != 0 ]]; then
- return 1
- fi
+ return $ret
}
# Usage: get_var <slug> <var_name> <default_value>
@@ -163,7 +155,7 @@ get_var() (
local slug=$1
local setting=$2
local default=$3
- load_files "$slug"
+ load_conf "$slug.conf"
printf '%s' "${!setting:-${default}}"
)
diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch
index 7573678..58a98b9 100755
--- a/src/librefetch/librefetch
+++ b/src/librefetch/librefetch
@@ -174,8 +174,7 @@ doit() {
# Mode: download #######################################################
if [[ $mode =~ download ]]; then
- load_files librefetch
- check_vars librefetch MIRRORS DOWNLOADER || exit 1
+ load_conf librefetch.conf MIRRORS DOWNLOADER || exit
# Canonicalize $src
if [[ "$src" == libre://* ]]; then
diff --git a/src/toru/toru-path b/src/toru/toru-path
index f2445a6..611a857 100755
--- a/src/toru/toru-path
+++ b/src/toru/toru-path
@@ -54,11 +54,7 @@ usage() {
main() {
setup_traps
- load_files libretools
- load_files abs
-
# TODO: better option parsing
- TORUPATH=${T:-${TORUPATH}}
VERBOSE=${V:-false}
FORCE=${F:-false}
# TODO: add an option to override/augment libretools.conf:REPOS
@@ -71,8 +67,15 @@ main() {
return 2
fi
- check_vars libretools TORUPATH REPOS || return 1
- check_vars abs ABSROOT || return 1
+ declare -i ret=0
+ if [[ -n "${T:-}" ]]; then
+ load_conf libretools.conf REPOS || ret=$?
+ TORUPATH=$T
+ else
+ load_conf libretools.conf TORUPATH REPOS || ret=$?
+ fi
+ load_conf abs.conf ABSROOT || ret=$?
+ [[ $ret = 0 ]] || exit $ret
if [ ! -w "$TORUPATH" ]; then
error "Toru's path isn't writable. Please check your TORUPATH: %q" "$TORUPATH"
diff --git a/src/toru/toru-where b/src/toru/toru-where
index ba7fb0a..5eb491b 100755
--- a/src/toru/toru-where
+++ b/src/toru/toru-where
@@ -21,8 +21,7 @@
. "$(librelib conf)"
main() {
- load_files libretools
- check_vars libretools TORUPATH || exit 1
+ load_conf libretools.conf TORUPATH || exit
tcamgr get "${TORUPATH}/paths.tch" "$1" 2>/dev/null || echo ""
}
diff --git a/src/xbs-abs/helper-abs b/src/xbs-abs/helper-abs
index e8f41de..6c9ee56 100755
--- a/src/xbs-abs/helper-abs
+++ b/src/xbs-abs/helper-abs
@@ -33,9 +33,8 @@
load_config() {
. "$(librelib conf)"
- load_files xbs-abs
# SVNUSER is optional
- check_vars xbs-abs SVNDIR SVNREPOS ARCHES || exit 1
+ load_conf xbs-abs.conf SVNDIR SVNREPOS ARCHES || exit
}
# This is taken from dbscripts:db-fuctions
diff --git a/src/xbs-abslibre/helper-abslibre b/src/xbs-abslibre/helper-abslibre
index 3d3be9a..7ebed0a 100755
--- a/src/xbs-abslibre/helper-abslibre
+++ b/src/xbs-abslibre/helper-abslibre
@@ -40,8 +40,7 @@ checkgit() {
conf() {
. "$(librelib conf)"
- load_files libretools
- check_vars libretools "$@" || exit 1
+ load_conf libretools.conf || exit
}
################################################################################
diff --git a/src/xbs/xbs b/src/xbs/xbs
index 7200800..12c5770 100755
--- a/src/xbs/xbs
+++ b/src/xbs/xbs
@@ -140,11 +140,7 @@ main() {
shift $((OPTIND - 1))
if [[ -z $BUILDSYSTEM ]]; then
- load_files xbs || return 1
- check_vars xbs BUILDSYSTEM || {
- prose 'or specify the `-b` flag.' >&2
- return 1
- }
+ load_conf xbs.conf BUILDSYSTEM || exit
fi
if [[ -z $XBS_LIBDIR ]]; then