diff options
Diffstat (limited to 'src/xbs-abslibre/helper-abslibre')
-rwxr-xr-x | src/xbs-abslibre/helper-abslibre | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/src/xbs-abslibre/helper-abslibre b/src/xbs-abslibre/helper-abslibre new file mode 100755 index 0000000..57d8369 --- /dev/null +++ b/src/xbs-abslibre/helper-abslibre @@ -0,0 +1,137 @@ +#!/bin/bash + +# Copyright (C) 2012-2013 Luke Shumaker <lukeshu@sbcglobal.net> +# +# License: GNU GPLv2+ +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 .) ]] +} + +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 + + # Get the everything-included tree + abs +} + +release() { + local repo=$1 + local arch=$2 + + . 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 +} + +unrelease() { + local pkgbase=$1 + local repo=$2 + local arch=$3 + + . 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 -i "/^$repo $arch $pkgbase /d" "$lookupfile" + lock_close 9 +} + +move() { + local repo_from=$1 + local repo_to=$2 + local pkgbase=$3 + + . 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 +} + +releasepath() { + local pkgbase=$1 + local repo=$2 + local arch=$3 + + local r=0 + . $(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 + return 1 +} + +case "$1" in + status|download|release|unrelease|move|releasepath) "$@";; + *) exit 127;; +esac |