summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-06-21 00:51:20 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-06-21 00:52:26 -0400
commitc4accb0e91507245584691691baa51a70723dc6e (patch)
tree7b942c05672442c0b987d5a7d9df4b136d654382
parent7b9ed9a218d408390049c5e9618d4c9b90d33ccb (diff)
libredbdiff: Fix configuration
1. the config at the top referenced libredbdiff.conf:statedir; which hadn't been loaded yet 2. the 'compare' arg parser referenced libredbdiff.conf:repos; which hadn't been loaded yet
-rwxr-xr-xsrc/abslibre-tools/libredbdiff45
1 files changed, 27 insertions, 18 deletions
diff --git a/src/abslibre-tools/libredbdiff b/src/abslibre-tools/libredbdiff
index 3fc505c..1527633 100755
--- a/src/abslibre-tools/libredbdiff
+++ b/src/abslibre-tools/libredbdiff
@@ -27,15 +27,6 @@ setup_traps
declare -r name="Libredbdiff"
declare -r cmd="${0##*/}"
-declare -r conffile_prbl="$statedir/pacman.conf.parabola"
-declare -r conffile_arch="$statedir/pacman.conf.archlinux"
-
-declare -r dbpath_prbl="$statedir/pacman.parabola"
-declare -r dbpath_arch="$statedir/pacman.archlinux"
-
-declare -r mirrorlist_prbl="$statedir/mirrorlist.parabola"
-declare -r mirrorlist_arch="$statedir/mirrorlist.archlinux"
-
declare -r field_pkgname_prbl=30
declare -r field_pkgname_arch=30
declare -r field_pkgname_total="$((field_pkgname_prbl + field_pkgname_arch))"
@@ -43,6 +34,17 @@ declare -r field_pkgname_total="$((field_pkgname_prbl + field_pkgname_arch))"
declare -r printf_format="%s %-${field_pkgname_prbl}s%-${field_pkgname_arch}s %s | %s\n"
declare -r printf_format_noarch="%s %-${field_pkgname_total}s %s\n"
+init_conf() {
+ declare -rg conffile_prbl="$statedir/pacman.conf.parabola"
+ declare -rg conffile_arch="$statedir/pacman.conf.archlinux"
+
+ declare -rg dbpath_prbl="$statedir/pacman.parabola"
+ declare -rg dbpath_arch="$statedir/pacman.archlinux"
+
+ declare -rg mirrorlist_prbl="$statedir/mirrorlist.parabola"
+ declare -rg mirrorlist_arch="$statedir/mirrorlist.archlinux"
+}
+
enablerepo() {
local repo="$1"
local conffile_arg="$2"
@@ -220,6 +222,17 @@ main() {
usage >&2
exit $EXIT_INVALIDARGUMENT
fi
+
+ if [[ $EUID != 0 ]]; then
+
+ error "Must run as root to initialize or update %s databases." "$cmd"
+ usage >&2
+ exit $EXIT_NOPERMISSION
+ fi
+
+ load_conf libredbdiff.conf statedir mirror_prbl mirror_arch || exit
+ init_conf
+
main_update
;;
compare)
@@ -228,24 +241,22 @@ main() {
usage >&2
exit $EXIT_INVALIDARGUMENT
fi
+
+ load_conf libredbdiff.conf statedir repos || exit
+ init_conf
+
if [[ $# = 1 ]]; then
if ! in_array "$1" "${repos[@]}"; then
die "The specified Parabola repo \"%s\" cannot be compared. It's not in the list of repos in the configuration variable \"repos\"." "$1"
fi
fi
+
main_compare "$@"
;;
esac
}
main_update() {
- if [[ $EUID != 0 ]]; then
- error "Must run as root to initialize or update %s databases." "$cmd"
- usage >&2
- exit $EXIT_NOPERMISSION
- fi
- load_conf libredbdiff.conf statedir mirror_prbl mirror_arch || exit
-
createdir "$statedir"
{
msg "Generating %s %q" Parabola pacman.conf
@@ -296,8 +307,6 @@ main_update() {
}
main_compare() {
- load_conf libredbdiff.conf statedir repos || exit
-
if ! [[ -f "$conffile_prbl" && \
-f "$conffile_arch" && \
-f "$dbpath_prbl/sync/libre.db" && \