summaryrefslogtreecommitdiff
path: root/src/xbs-abslibre/helper-abslibre
diff options
context:
space:
mode:
Diffstat (limited to 'src/xbs-abslibre/helper-abslibre')
-rwxr-xr-xsrc/xbs-abslibre/helper-abslibre136
1 files changed, 71 insertions, 65 deletions
diff --git a/src/xbs-abslibre/helper-abslibre b/src/xbs-abslibre/helper-abslibre
index 57d8369..ce21b99 100755
--- a/src/xbs-abslibre/helper-abslibre
+++ b/src/xbs-abslibre/helper-abslibre
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
# Copyright (C) 2012-2013 Luke Shumaker <lukeshu@sbcglobal.net>
#
@@ -17,13 +17,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# Here's the idea:
-# We have two sources of abslibre:
-# - git - does not include packages imported directly from Arch Linux
-# - rsync - is read-only
-# They should be identical, except for the mentioned differences.
-#
-
status() {
[[ -z $(git status -s .) ]]
}
@@ -31,25 +24,9 @@ status() {
download() {
. $(librelib conf)
load_files libretools
- check_vars libretools WORKDIR ABSLIBRERECV || return 1
-
- # Get the Parabola-added git repo
- libregit "$ABSLIBRERECV" master "$WORKDIR/abslibre" || return 1
- # This bit configures a 'pushUrl' to use ssh, leaves plain https for
- # 'url' (used for fetch).
- if [[ -n ${ABSLIBRESEND:-} ]]; then
- pushd "$WORKDIR/abslibre" >/dev/null
- local pushUrl="$(git config --get remote.origin.pushUrl)"
- if [[ $? != 0 ]]; then
- git config remote.origin.pushUrl "$ABSLIBRESEND";
- elif [[ $pushUrl != "$ABSLIBRESEND" ]]; then
- warning "A %s is configured for %s, but it doesn't match %s" pushUrl "$WORKDIR/abslibre" "$ABSLIBRESEND"
- fi
- popd >/dev/null
- fi
+ check_vars libretools WORKDIR ABSLIBRERECV ABSLIBRESEND || return 1
- # Get the everything-included tree
- abs
+ gitget -f -p "$ABSLIBRESEND" checkout "$ABSLIBRERECV" "$WORKDIR/abslibre" || return 1
}
release() {
@@ -59,18 +36,23 @@ release() {
. libremessages
. $(librelib conf)
load_files libretools
- check_vars libretools WORKDIR || return 1
- local lookupfile="${WORKDIR}/abslibre.xbs-lookup"
-
- read mode type sha1 file <<<"$(git ls-tree -d --full-tree HEAD "$(pwd)")"
-
- lock 9 "$lookupfile.lock" "Waiting for lock on %s" "$lookupfile"
- {
- sed "/^$repo $arch $pkgbase /d" < "$lookupfile"
- echo "$repo $arch $pkgbase $sha1 $path"
- } > "$lookupfile.$$"
- mv "$lookupfile.$$" "$lookupfile"
- lock_close 9
+ check_vars libretools WORKDIR ABSLIBREDEST || return 1
+ local pkgbase="$(load_PKGBUILD; printf '%s\n' "${pkgbase:-${pkgname}}")"
+ local pkgdir="${ABSLIBREDEST}/${arch}/${repo}/${pkgbase}"
+
+ lock 9 "${ABSLIBREDEST}/${arch}.lock" "Waiting for a lock on the ABSLibre release directory for ${arch}"
+
+ if [[ -e $pkgdir ]]; then
+ rm -rf -- "$pkgdir"
+ fi
+ mkdir -p -- "$pkgdir"
+ git ls-files -z | xargs -0 -I{} cp {} "$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
}
unrelease() {
@@ -81,12 +63,21 @@ unrelease() {
. libremessages
. $(librelib conf)
load_files libretools
- check_vars libretools WORKDIR || return 1
- local lookupfile="${WORKDIR}/abslibre.xbs-lookup"
+ check_vars libretools ABSLIBREDEST || return 1
- lock 9 "$lookupfile.lock" "Waiting for lock on %s" "$lookupfile"
- sed -i "/^$repo $arch $pkgbase /d" "$lookupfile"
- lock_close 9
+ local pkgbase="$(load_PKGBUILD; printf '%s\n' "${pkgbase:-${pkgname}}")"
+ local pkgdir="${ABSLIBREDEST}/${arch}/${repo}/${pkgbase}"
+
+ lock 9 "${ABSLIBREDEST}/${arch}.lock" "Waiting for a lock on the ABSLibre release directory for ${arch}"
+
+ 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
+ fi
}
move() {
@@ -97,14 +88,32 @@ move() {
. libremessages
. $(librelib conf)
load_files libretools
- check_vars libretools WORKDIR || return 1
- local lookupfile="${WORKDIR}/abslibre.xbs-lookup"
-
- lock 9 "$lookupfile.lock" "Waiting for lock on %s" "$lookupfile"
- sed -ri "s/^${repo_from} (\S+) $pkgbase /${repo_to} \1 $pkgbase/" "$lookupfile"
- # TODO
- lock_close 9
- return 1
+ check_vars libretools ABSLIBREDEST ARCHES || return 1
+
+ local mv
+ local arch
+ for arch in "${ARCHES[@]}" any; do
+ lock 9 "${ABSLIBREDEST}/${arch}.lock" "Waiting for a lock on the ABSLibre release directory for ${arch}"
+
+ 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"
+ fi
+ fi
+ lock_close 9
+ done
}
releasepath() {
@@ -112,22 +121,19 @@ releasepath() {
local repo=$2
local arch=$3
- local r=0
+ . libremessages
. $(librelib conf)
load_files libretools
- check_vars libretools WORKDIR || r=$?
- load_files abs
- check_vars abs ABSROOT || r=$?
-
- local abstree
- local dir
- for abstree in "$WORKDIR/abslibre" "$ABSROOT"; do
- dir="$abstree/$repo/$pkgbase"
- if [[ -f "$dir/PKGBUILD" ]]; then
- printf '%s\n' "$dir"
- return 0
- fi
- done
+ check_vars libretools ABSLIBREDEST || return 1
+ local pkgdir="${ABSLIBREDEST}/${arch}/${repo}/${pkgbase}"
+
+ lock 9 "${ABSLIBREDEST}/${arch}.lock" "Waiting for a lock on the ABSLibre release directory for ${arch}"
+
+ if [[ -f "${pkgdir}/PKGBUILD" ]]; then
+ printf '%s\n' "$pkgdir"
+ return 0
+ fi
+
return 1
}