summaryrefslogtreecommitdiff
path: root/src/xbs-abslibre
diff options
context:
space:
mode:
Diffstat (limited to 'src/xbs-abslibre')
-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