2007-06-04 17:28:23 -04:00
|
|
|
#!/bin/bash -e
|
2007-05-30 11:04:49 -04:00
|
|
|
#
|
|
|
|
# abs - download a PKGBUILD tree from a CVS repository
|
|
|
|
# @configure_input@
|
|
|
|
#
|
2007-04-11 17:04:51 -04:00
|
|
|
# Copyright (c) 2002-2007 by Judd Vinet <jvinet@zeroflux.org>
|
2007-05-30 11:04:49 -04:00
|
|
|
#
|
2007-04-11 17:04:51 -04:00
|
|
|
# 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.
|
2007-05-30 11:04:49 -04:00
|
|
|
#
|
2007-04-11 17:04:51 -04:00
|
|
|
# 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.
|
2007-05-30 11:04:49 -04:00
|
|
|
#
|
2007-04-11 17:04:51 -04:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
2007-05-30 11:04:49 -04:00
|
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
2007-04-11 17:04:51 -04:00
|
|
|
# USA.
|
|
|
|
#
|
2006-12-05 02:30:15 -05:00
|
|
|
|
2007-06-04 17:28:23 -04:00
|
|
|
##
|
|
|
|
# Script Exit Reasons
|
|
|
|
# -------------------
|
|
|
|
# E_OK : Everything worked :)
|
|
|
|
# E_MISSING_PROGRAM : A program the script depends on is not installed.
|
|
|
|
# E_CONFIG_ERROR : Missing/incorrect configuration.
|
|
|
|
# E_INVALID_OPTION : User has passed unknow/invalid option to script.
|
|
|
|
##
|
|
|
|
|
2007-06-04 01:21:14 -04:00
|
|
|
# gettext initialization
|
|
|
|
export TEXTDOMAIN='pacman'
|
|
|
|
export TEXTDOMAINDIR='@localedir@'
|
|
|
|
|
2007-04-11 15:53:43 -04:00
|
|
|
myver='@PACKAGE_VERSION@'
|
2007-06-04 17:28:23 -04:00
|
|
|
BUG_REPORT_EMAIL='@PACKAGE_BUGREPORT@'
|
2007-05-30 11:04:49 -04:00
|
|
|
CONFDIR="@sysconfdir@/abs"
|
2007-06-04 17:28:23 -04:00
|
|
|
PASSIVE='m'
|
|
|
|
|
|
|
|
# Source config files
|
|
|
|
if [ -r "$CONFDIR/abs.conf" ]; then
|
|
|
|
source "$CONFDIR/abs.conf"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# User based overrides
|
|
|
|
if [ -r ~/.abs.conf ]; then
|
|
|
|
source ~/.abs.conf
|
|
|
|
fi
|
2006-12-21 18:10:20 -05:00
|
|
|
|
|
|
|
|
2007-06-04 17:28:23 -04:00
|
|
|
msg() {
|
|
|
|
local mesg=$1; shift
|
|
|
|
printf "==> ${mesg}\n" "$@" >&2
|
|
|
|
}
|
|
|
|
|
|
|
|
error() {
|
|
|
|
local mesg=$1; shift
|
|
|
|
printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2
|
|
|
|
}
|
|
|
|
|
2006-12-05 02:30:15 -05:00
|
|
|
|
|
|
|
usage() {
|
2007-07-06 19:35:32 -04:00
|
|
|
printf "$(gettext "abs (pacman) %s - download a PKGBUILD tree from a CVS repository")\n\n" "$myver"
|
|
|
|
printf "$(gettext "Usage %s [options] [repository...]")\n\n" "$0"
|
2007-06-04 17:28:23 -04:00
|
|
|
printf "$(gettext "Options:")\n"
|
|
|
|
printf "$(gettext " -p, --passive The connection is opened in passive mode.")\n"
|
2007-06-04 01:21:14 -04:00
|
|
|
echo
|
2007-06-04 17:28:23 -04:00
|
|
|
printf "$(gettext " -h, --help Display this help message then exit.")\n"
|
|
|
|
printf "$(gettext " -V, --version Display version information then exit.")\n"
|
|
|
|
echo
|
2007-07-06 19:35:32 -04:00
|
|
|
printf "$(gettext "\
|
|
|
|
abs will synchronize build scripts from the CVS repository\n\
|
|
|
|
into %s. You can follow different package trees by\n\
|
|
|
|
editing %s files. If no argument is given, abs\n\
|
|
|
|
will synchronize from supfiles specified in %s.\n\n")" \
|
|
|
|
"$ABSROOT" "$CONFDIR/supfile.*" "$CONFDIR/abs.conf"
|
2007-06-04 17:28:23 -04:00
|
|
|
printf "$(gettext "Report bugs to <%s>.")\n" "$BUG_REPORT_EMAIL"
|
2006-12-05 02:30:15 -05:00
|
|
|
}
|
|
|
|
|
2007-04-11 15:53:43 -04:00
|
|
|
version() {
|
|
|
|
printf "abs (pacman) %s\n" "$myver"
|
2007-07-06 19:35:32 -04:00
|
|
|
printf "$(gettext "\
|
|
|
|
Copyright (C) 2002-2007 Judd Vinet <jvinet@zeroflux.org>.\n\n\
|
|
|
|
This is free software; see the source for copying conditions.\n\
|
|
|
|
There is NO WARRANTY, to the extent permitted by law.\n")"
|
2007-04-11 15:53:43 -04:00
|
|
|
}
|
|
|
|
|
2006-12-05 02:30:15 -05:00
|
|
|
|
2007-06-04 17:28:23 -04:00
|
|
|
##
|
|
|
|
# Signal Traps
|
|
|
|
##
|
|
|
|
trap 'error "$(gettext "TERM signal caught. Exiting...")"; exit 1' TERM HUP QUIT
|
|
|
|
trap 'error "$(gettext "Aborted by user! Exiting...")"; exit 1' INT
|
|
|
|
trap 'error "$(gettext "An unknown error has occured. Exiting...")"; exit 1' ERR
|
|
|
|
|
|
|
|
|
|
|
|
# Parse Command Line Options.
|
|
|
|
OPT_SHORT="hpV"
|
|
|
|
OPT_LONG="help,passive,version"
|
|
|
|
OPT_TEMP="$(getopt -o "$OPT_SHORT" -l "$OPT_LONG" -n "$(basename "$0")" -- "$@" || echo 'GETOPT GO BANG!')"
|
|
|
|
if echo "$OPT_TEMP" | grep -q 'GETOPT GO BANG!'; then
|
|
|
|
# This is a small hack to stop the script bailing with 'set -e'
|
|
|
|
echo; usage; exit 1 # E_INVALID_OPTION;
|
2006-12-05 02:30:15 -05:00
|
|
|
fi
|
2007-06-04 17:28:23 -04:00
|
|
|
eval set -- "$OPT_TEMP"
|
|
|
|
unset OPT_SHORT OPT_LONG OPT_TEMP
|
2006-12-05 02:30:15 -05:00
|
|
|
|
2007-06-04 17:28:23 -04:00
|
|
|
while true; do
|
|
|
|
case "$1" in
|
|
|
|
-p|--passive) PASSIVE='-';;
|
|
|
|
|
|
|
|
-h|--help) usage; exit 0;; # E_OK
|
|
|
|
-V|--version) version; exit 0;; # E_OK
|
|
|
|
|
|
|
|
--) OPT_IND=0; shift; break;;
|
|
|
|
*) usage; exit 1;; # E_INVALID_OPTION
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ $# -gt 0 ]; then
|
|
|
|
SUPFILES=("$@")
|
2007-04-11 15:53:43 -04:00
|
|
|
fi
|
|
|
|
|
2007-06-04 17:28:23 -04:00
|
|
|
|
|
|
|
# Check permissions and programs.
|
2006-12-21 18:10:20 -05:00
|
|
|
if [ ! -d "$ABSROOT" ]; then
|
2007-06-04 17:28:23 -04:00
|
|
|
error "$(gettext "%s does not exist or is not a directory.")" "$ABSROOT"
|
|
|
|
exit 1 # E_CONFIG_ERROR
|
|
|
|
elif [ ! -w "$ABSROOT" ]; then
|
|
|
|
error "$(gettext "You do not have write permissions in %s.")" "$ABSROOT"
|
|
|
|
exit 1 # E_CONFIG_ERROR
|
2006-12-05 02:30:15 -05:00
|
|
|
fi
|
|
|
|
|
2007-06-04 17:28:23 -04:00
|
|
|
|
2006-12-21 18:10:20 -05:00
|
|
|
if [ "$(type -p cvsup)" ]; then
|
2006-12-05 02:30:15 -05:00
|
|
|
CVSUP="cvsup"
|
2006-12-21 18:10:20 -05:00
|
|
|
elif [ "$(type -p csup)" ]; then
|
2006-12-05 02:30:15 -05:00
|
|
|
CVSUP="csup"
|
|
|
|
else
|
2007-06-04 17:28:23 -04:00
|
|
|
error "$(gettext "Missing CVS synchronization utility. Install cvsup or csup.")"
|
|
|
|
exit 1 # E_MISSING_PROGRAM
|
2006-12-05 02:30:15 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2007-06-04 17:28:23 -04:00
|
|
|
# Begin script.
|
|
|
|
for sup in ${SUPFILES[@]}; do
|
|
|
|
case "$sup" in
|
|
|
|
testing)
|
|
|
|
if [ ! -d "$ABSROOT/$sup" ]; then
|
|
|
|
mkdir "$ABSROOT/$sup"
|
|
|
|
fi
|
|
|
|
workdir="$ABSROOT/$sup"
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
if [ "$sup" != "${sup#!}" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
workdir="$ABSROOT"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
msg "$(gettext "Updating %s...")" "$sup"
|
|
|
|
cd "$workdir"
|
|
|
|
$CVSUP -L 1 -r 0 -g -b "$workdir" -P "$PASSIVE" -c .sup "$CONFDIR/supfile.$sup"
|
|
|
|
done
|
2006-12-05 02:30:15 -05:00
|
|
|
|
2007-06-04 17:28:23 -04:00
|
|
|
exit 0 # E_OK
|
2006-12-05 02:30:15 -05:00
|
|
|
|
2006-12-20 20:53:40 -05:00
|
|
|
# vim: set ts=2 sw=2 noet:
|