summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2015-05-24 00:26:15 -0600
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-05-24 00:26:15 -0600
commit9dd48b64a8114f96970d2a71f19483f0ea08f29a (patch)
tree03d0a0308daa87f01b953b7f89d8ba9ce2ac6d1e /src
parentf14381c2a3df309de0034836ab9050fef382504b (diff)
xbs-abslibre: The server commands handled dest of `abstree` or `abslibre`.
It really should enforce the dest being in the `abslibre` format. Add checks for that and remove the code for dealing with an `abstree`. When I originally wrote it with the flexibility, it was because I was trying to capture a range of behaviors, without actually understanding how the tool would be used. Now that I know how it is to be used, I can remove the extra code.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/xbs-abslibre/helper-abslibre49
1 files changed, 24 insertions, 25 deletions
diff --git a/src/xbs-abslibre/helper-abslibre b/src/xbs-abslibre/helper-abslibre
index 4d4ebf6..c2dc068 100755
--- a/src/xbs-abslibre/helper-abslibre
+++ b/src/xbs-abslibre/helper-abslibre
@@ -27,6 +27,13 @@ unlockarch() {
lock_close 9
}
+checkgit() {
+ if [[ ! -d "${ABSLIBREDEST}/${arch}/.git" ]]; then
+ error 'Not a git repository: %s' "${ABSLIBREDEST}/${arch}"
+ exit 1
+ fi
+}
+
conf() {
. libremessages
. "$(librelib conf)"
@@ -96,6 +103,7 @@ release-server() {
local pkgbase="$(load_PKGBUILD >/dev/null; printf '%s\n' "${pkgbase:-${pkgname}}")"
local pkgdir="${ABSLIBREDEST}/${arch}/${repo}/${pkgbase}"
lockarch "$arch"
+ checkgit
if [[ -e $pkgdir ]]; then
rm -rf -- "$pkgdir"
@@ -104,11 +112,9 @@ release-server() {
mkdir -p -- "$pkgdir"
mv -- * "$pkgdir"
- if [[ -e "${ABSLIBREDEST}/${arch}/.git" ]]; then
- cd "$pkgdir"
- git add .
- git commit -q -m "xbs-abslibre: Release ${repo}/${pkgbase} for ${arch} (by $(id -un))"
- fi
+ cd "$pkgdir"
+ git add .
+ git commit -q -m "xbs-abslibre: Release ${repo}/${pkgbase} for ${arch} (by $(id -un))"
}
# Args: PKGBASE REPO ARCH
@@ -120,17 +126,13 @@ unrelease() {
local arch=$3
conf ABSLIBREDEST
- local pkgbase="$(load_PKGBUILD >/dev/null; printf '%s\n' "${pkgbase:-${pkgname}}")"
local pkgdir="${ABSLIBREDEST}/${arch}/${repo}/${pkgbase}"
lockarch "$arch"
+ checkgit
if [[ -f "${pkgdir}/PKGBUILD" ]]; then
- if [[ -e "${ABSLIBREDEST}/${arch}/.git" ]]; then
- git rm -qrf -- "$pkgdir"
- git commit -q -m "xbs-abslibre: Remove ${repo}/${pkgbase} from ${arch} (by $(id -un))"
- else
- rm -rf -- "$pkgdir"
- fi
+ git rm -qrf -- "$pkgdir"
+ git commit -q -m "xbs-abslibre: Remove ${repo}/${pkgbase} from ${arch} (by $(id -un))"
fi
}
@@ -144,29 +146,26 @@ move() {
conf ABSLIBREDEST ARCHES
+ # Execute each iteration in a subshell so that 'checkgit'
+ # bailing for an architecture doesn't abort the entire thing.
local arch
- for arch in "${ARCHES[@]}" any; do
+ for arch in "${ARCHES[@]}" any; do (
lockarch "$arch"
+ checkgit
local dir_from="${ABSLIBREDEST}/${arch}/${repo_from}/${pkgbase}"
local dir_to="${ABSLIBREDEST}/${arch}/${repo_to}/${pkgbase}"
if [[ -f "${dir_from}/PKGBUILD" ]]; then
- if [[ -e "${ABSLIBREDEST}/${arch}/.git" ]]; then
- if [[ -e "${dir_to}" ]]; then
- git rm -qrf -- "$dir_to"
- fi
- mkdir -p -- "${dir_to%/*}"
- git mv -- "$dir_from" "$dir_to"
- git commit -q -m "xbs-abslibre: Move ${pkgbase} from ${repo_from} to ${repo_to} on ${arch} (by $(id -un))"
- else
- rm -rf -- "$dir_to"
- mkdir -p -- "${dir_to%/*}"
- mv "$dir_from" "$dir_to"
+ if [[ -e "${dir_to}" ]]; then
+ git rm -qrf -- "$dir_to"
fi
+ mkdir -p -- "${dir_to%/*}"
+ git mv -- "$dir_from" "$dir_to"
+ git commit -q -m "xbs-abslibre: Move ${pkgbase} from ${repo_from} to ${repo_to} on ${arch} (by $(id -un))"
fi
unlock arch
- done
+ ) done
}
# Args: PKGBASE REPO ARCH