summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-06-02 21:09:01 -0600
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-06-02 21:09:01 -0600
commit115d0aec3a8d447e18298d177e55f73e4d534c99 (patch)
tree2ff2fb6482450e7b43e8e31bc4669a3d80bddd6f
parentb1c3eb2a14160acfc7009c82ca5443bba16e7d81 (diff)
add pbs-download
-rwxr-xr-xpbs-download97
-rw-r--r--pbs.conf5
2 files changed, 102 insertions, 0 deletions
diff --git a/pbs-download b/pbs-download
new file mode 100755
index 0000000..ffe7177
--- /dev/null
+++ b/pbs-download
@@ -0,0 +1,97 @@
+#!/bin/bash -euE
+
+# Copyright (c) 2012-2013 Pacman Development Team <pacman-dev@archlinux.org>
+# 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/>.
+
+. libremessages
+. $(librelib conf.sh)
+
+cmd=${0##*/}
+usage() {
+ echo "Usage: $cmd [-h]"
+ echo 'Downloads or updates the PBS tree.'
+ echo ''
+ echo 'Options:'
+ echo ' -h Show this message'
+}
+
+load_configuration() {
+ r=0
+
+ load_files libretools
+ check_vars libretools WORKDIR || r=$?
+
+ load_files pbs
+ check_vars pbs PBSGIT || r=$?
+
+ if [[ $r -gt 0 ]]; then
+ return $r
+ fi
+}
+
+# Downloads/updates git based on $dir, $repo, and $ref
+# Mostly taken from makepkg
+download_git() {
+ if [[ ! -d "$dir/.git" ]] ; then
+ msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "git"
+ if ! git clone "$repo" "$dir"; then
+ error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "git"
+ plain "$(gettext "Aborting...")"
+ exit 1
+ fi
+ else
+ cd "$dir"
+ # Make sure we are fetching the right repo
+ if [[ "$repo" != "$(git config --get remote.origin.url)" ]] ; then
+ error "$(gettext "%s is not a clone of %s")" "$dir" "$repo"
+ plain "$(gettext "Aborting...")"
+ exit 1
+ fi
+ msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "git"
+ if ! git pull origin "$ref"; then
+ # only warn on failure to allow offline builds
+ warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "git"
+ fi
+ fi
+}
+
+main() {
+ while getopts 'h' arg; do
+ case $arg in
+ h) usage; return 0;;
+ *) usage >&2; return 1;;
+ esac
+ done
+ if [[ $# -gt 0 ]]; then
+ usage >&2
+ return 1
+ fi
+
+ load_configuration
+
+ mkdir -p "$WORKDIR"
+ (
+ dir="$WORKDIR/pbs"
+ repo="$PBSGIT"
+ ref="master"
+ download_git
+ )
+ cd "$WORKDIR/pbs"
+ git submodule init
+ git submodule update
+}
+
+main "$@"
diff --git a/pbs.conf b/pbs.conf
new file mode 100644
index 0000000..a64d90b
--- /dev/null
+++ b/pbs.conf
@@ -0,0 +1,5 @@
+#!/bin/bash # non-executable, but put this there as a hint to text editors
+
+# What git remote to use for the PBS tree
+#PBSGIT='http://projects.parabolagnulinux.org/pbs.git'
+PBSGIT='ssh://git@parabolagnulinux.org:1863/srv/git/pbs.git'