summaryrefslogtreecommitdiff
path: root/src/xbs
diff options
context:
space:
mode:
Diffstat (limited to 'src/xbs')
-rw-r--r--src/xbs/Makefile2
-rwxr-xr-xsrc/xbs/xbs145
-rw-r--r--src/xbs/xbs.conf1
3 files changed, 148 insertions, 0 deletions
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..7673b35
--- /dev/null
+++ b/src/xbs/xbs
@@ -0,0 +1,145 @@
+#!/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
+ prose 'This is a pluggable tool. The BUILDSYSTEM it uses is configured in:'
+ bullet '/etc/xbs.conf'
+ bullet '${XDG_CONFIG_HOME}/xbs.conf'
+ bullet 'with the `-b` flag'
+ prose 'Later items take precidence over earlier ones.'
+ echo
+ prose 'It looks for a helper program at `/lib/xbs/helper-${BUILDSYSTEM}`.'
+ echo
+ print 'Options:'
+ flag "-b $(_ BUILDSYSTEM)" 'BUILDSYSTEM instead of the one configured in
+ xbs.conf'
+ flag '-h' 'Show this message'
+ echo
+ print 'Commands:'
+ flag 'status' \
+ 'Are there uncommited changes in `.`?'
+ flag 'download' \
+ 'Download or update the tree'
+ flag "release $(_ 'REPO ARCH')" \
+ 'Release `.`'
+ flag "unrelease $(_ 'PKGBASE REPO ARCH')" \
+ 'Unrelease a pkgbase'
+ flag "move $(_ 'FROMREPO TOREPO PKGBASE')" \
+ 'Move a pkgbase from one repo to another'
+ flag "releasepath $(_ 'PKGBASE REPO ARCH')" \
+ 'Print the path to the staged version of pkgbase'
+}
+
+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