summaryrefslogtreecommitdiff
path: root/asp.in
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2018-08-18 12:28:37 -0400
committerDave Reisner <dreisner@archlinux.org>2018-08-19 07:12:55 -0400
commitbb83e6b56361906ce781a9940ab9bea537f9a0a1 (patch)
tree255e6923d94b5f1800fde8ec55ef2430997a7264 /asp.in
parentf3c8955cd76c6a9caadc7b45fd63137769281dae (diff)
downloadasp32-bb83e6b56361906ce781a9940ab9bea537f9a0a1.tar.xz
Avoid cd, references to $startdir
just set GIT_DIR appropriately and always operate from the original $PWD. As part of this, let's cleanup our error handling in initialize() a fair bit.
Diffstat (limited to 'asp.in')
-rw-r--r--asp.in28
1 files changed, 12 insertions, 16 deletions
diff --git a/asp.in b/asp.in
index 62eea9e..99f69fe 100644
--- a/asp.in
+++ b/asp.in
@@ -126,27 +126,23 @@ initialize() {
local remote
umask 0022
- startdir=$PWD
- if [[ ! -d $ASPROOT ]]; then
- log_info 'Initializing ASPROOT in %s' "$ASPROOT"
- mkdir -p "$ASPROOT"
- fi
+ export GIT_DIR=$ASPROOT/.git
- cd "$ASPROOT" || log_fatal "ASPROOT (%s) does not exist!" "$ASPROOT"
+ if [[ ! -f $ASPROOT/.asp ]]; then
+ git init -q "$ASPROOT" || return 1
+ for remote in "${ARCH_GIT_REPOS[@]}"; do
+ git remote add "$remote" "https://git.archlinux.org/svntogit/$remote.git" || return 1
+ done
- if [[ ! -d $ASPCACHE ]] && ! mkdir -p "$ASPCACHE"; then
- log_fatal 'failed to create ASPCACHE (%s)' "$ASPCACHE"
+ touch "$ASPROOT/.asp" || return 1
fi
- [[ -f .asp ]] && return 0
-
- git init -q || return 1
- for remote in "${ARCH_GIT_REPOS[@]}"; do
- git remote add "$remote" "https://git.archlinux.org/svntogit/$remote.git"
- done
+ if [[ ! -d $ASPCACHE ]]; then
+ mkdir -p "$ASPCACHE" || return 1
+ fi
- touch .asp
+ return 0
}
dump_packages() {
@@ -340,7 +336,7 @@ dispatch_action() {
esac
}
-initialize
+initialize || log_fatal 'failed to initialize asp repository in %s' "$ASPROOT"
while getopts ':a:fhV' flag; do
case $flag in