summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-11-29 17:56:21 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-11-29 18:15:37 -0500
commitb7baff2c2bd86402d2645828af30d2f46bd68edb (patch)
treeda4a3514709bb0e4b6873942e0342edb8cbee003 /src
parentcceb77e73bc5e83a3da6e5bf5505eaef5d99b3a0 (diff)
initial implementations of xbs and xbs-abslibre
Diffstat (limited to 'src')
-rw-r--r--src/xbs-abslibre/Makefile3
-rwxr-xr-xsrc/xbs-abslibre/helper-abslibre117
-rw-r--r--src/xbs/Makefile2
-rwxr-xr-xsrc/xbs/xbs138
-rw-r--r--src/xbs/xbs.conf1
5 files changed, 261 insertions, 0 deletions
diff --git a/src/xbs-abslibre/Makefile b/src/xbs-abslibre/Makefile
new file mode 100644
index 0000000..cbe09fa
--- /dev/null
+++ b/src/xbs-abslibre/Makefile
@@ -0,0 +1,3 @@
+pkgconfdir = $(sysconfdir)/xbs
+pkglibexecdir = $(libexecdir)/xbs
+include ../../common.mk
diff --git a/src/xbs-abslibre/helper-abslibre b/src/xbs-abslibre/helper-abslibre
new file mode 100755
index 0000000..d8ef6ee
--- /dev/null
+++ b/src/xbs-abslibre/helper-abslibre
@@ -0,0 +1,117 @@
+#!/bin/bash
+
+# Copyright (c) 2012-2013 Luke Shumaker <lukeshu@sbcglobal.net>
+#
+# 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/>.
+
+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
+
+ local lookupfile=
+
+ . libremessages
+ . $(librelib conf)
+ load_files libretools
+ check_vars libretools WORKDIR || return 1
+
+ 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
+
+ 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
+
+ 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
diff --git a/src/xbs/Makefile b/src/xbs/Makefile
new file mode 100644
index 0000000..fcb8ac2
--- /dev/null
+++ b/src/xbs/Makefile
@@ -0,0 +1,2 @@
+pkgconfdir = $(sysconfdir)
+include ../../common.mk
diff --git a/src/xbs/xbs b/src/xbs/xbs
new file mode 100755
index 0000000..099e1a1
--- /dev/null
+++ b/src/xbs/xbs
@@ -0,0 +1,138 @@
+#!/bin/bash
+
+# Copyright (c) 2013 Luke Shumaker <lukeshu@sbcglobal.net>
+#
+# 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/>.
+
+. libremessages
+. $(librelib conf)
+
+errusage() {
+ if [[ $# -gt 0 ]]; then
+ error "$@"
+ fi
+ usage >&2
+ exit 1
+}
+
+usage() {
+ print 'Usage: %s [-b SYSTEM|-h] COMMAND [ARGUMENTS]' "${0##*/}"
+ print 'Tool for working with arbitrary ABS-like build systems'
+ echo
+ print 'This is a pluggable tool. The BUILDSYSTEM it uses is configured in:'
+ print ' - /etc/xbs.conf'
+ print ' - ${XDG_CONFIG_HOME}/xbs.conf'
+ print ' - with the `-b` flag'
+ print 'Later items take precidence over earlier ones.'
+ print 'It looks for a helper program at `/lib/xbs/helper-${BUILDSYSTEM}`.'
+ echo
+ print 'Options:'
+ print ' -b BUILDSYSTEM Use BUILDSYSTEM instead of the'
+ print ' BUILDSYSTEM configured in xbs.conf'
+ print ' -h Show this message'
+ echo
+ print 'Commands:'
+ print ' status Are there uncommited changes in `.`?'
+ print ' download Download or update the tree'
+ print ' release REPO ARCH Release `.`'
+ print ' unrelease PKGBASE REPO ARCH Unrelease'
+ print ' move FROMREPO TOREPO PKGBASE'
+ print ' releasepath PKGBASE REPO ARCH Path to staged version'
+}
+
+status() {
+ if [[ ! -f PKGBUILD ]]; then
+ error 'PKGBUILD not found'
+ exit 1
+ fi
+ "$HELPER" status "$@"
+}
+
+download() {
+ "$HELPER" download "$@"
+}
+
+release() {
+ if [[ ! -f PKGBUILD ]]; then
+ error 'PKGBUILD not found'
+ exit 1
+ fi
+ if ! status; then
+ error 'You have not committed your changes yet!'
+ exit 1
+ fi
+ "$HELPER" release "$@"
+}
+
+unrelease() {
+ "$HELPER" unrelease "$@"
+}
+
+move() {
+ "$HELPER" move "$@"
+}
+
+releasepath() {
+ "$HELPER" releasepath "$@"
+}
+
+main() {
+ BUILDSYSTEM=''
+ while getopts 'b:h' arg; do
+ case $arg in
+ b) BUILDSYSTEM=$OPTARG;;
+ h) usage; return 0;;
+ *) errusage;;
+ esac
+ done
+ shift $(($OPTIND - 1))
+
+ if [[ -z $BUILDSYSTEM ]]; then
+ load_files xbs || return 1
+ check_vars xbs BUILDSYSTEM || return 1
+ fi
+
+ HELPER="/lib/xbs/helper-${BUILDSYSTEM}"
+ if [[ ! -x "$HELPER" ]]; then
+ error 'No helper for build system found: %s' "$BUILDSYSTEM"
+ return 1;
+ fi
+
+ if [[ $# -lt 1 ]]; then
+ errusage "Must specify a command"
+ fi
+
+ if [[ -w / ]]; then
+ error 'Run as a normal user'
+ fi
+
+ local cmd=$1; shift
+ case "$cmd" in
+ status|download)
+ [[ $# -eq 0 ]] || errusage 'bad number of argments'
+ $cmd "$@"
+ ;;
+ release)
+ [[ $# -eq 2 ]] || errusage 'bad number of argments'
+ $cmd "$@"
+ ;;
+ move|unrelease|releasepath)
+ [[ $# -eq 3 ]] || errusage 'bad number of argments'
+ $cmd "$@"
+ ;;
+ *) errusage 'unknown command: %s' "$cmd";;
+ esac
+}
+
+main "$@"
diff --git a/src/xbs/xbs.conf b/src/xbs/xbs.conf
new file mode 100644
index 0000000..caf8d8b
--- /dev/null
+++ b/src/xbs/xbs.conf
@@ -0,0 +1 @@
+BUILDSYSTEM=abs