From 9dd48b64a8114f96970d2a71f19483f0ea08f29a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 24 May 2015 00:26:15 -0600 Subject: 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. --- src/xbs-abslibre/helper-abslibre | 49 ++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 25 deletions(-) (limited to 'src/xbs-abslibre') 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 -- cgit v1.2.2