summaryrefslogtreecommitdiffstats
path: root/scripts/abs.in
blob: b086aea63b82176f95ab073f51795f7136649578 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
# 
#   abs
#  
#   Copyright (c) 2002-2007 by Judd Vinet <jvinet@zeroflux.org>
#  
#   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, write to the Free Software
#   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
#   USA.
#

myver='@PACKAGE_VERSION@'
CONFDIR="@SYSCONFDIR@/abs"
CONNMODE="m"

[ -f "$CONFDIR/abs.conf" ] && source "$CONFDIR/abs.conf"

#user based overrides
[ -f ~/.abs.conf ] && source ~/.abs.conf

usage() {
	echo "Arch Build System -- synchronization utility"
	echo "usage: $0 [-p] [repository1 [repository2 ...]]"
	echo
	echo "abs will synchronize PKGBUILD scripts from the CVS repository"
	echo "into $ABSROOT.  You can follow different package trees by"
	echo "editing @SYSCONFDIR@/abs/supfile.* files.  If no argument is given, abs "
	echo "will synchronize from supfiles specified in @SYSCONFDIR@/abs/abs.conf."
	echo "If -p is specified, the connection is opened in passive mode."
}

version() {
	printf "abs (pacman) %s\n" "$myver"
	printf "Copyright (C) 2002-2007 Judd Vinet <jvinet@zeroflux.org>.\n"
	echo
	printf "This is free software; see the source for copying conditions.\n"
	printf "There is NO WARRANTY, to the extent permitted by law.\n"
	echo
}

update() {
	cd "$ABSROOT"
	for sup in "${SUPFILES[@]}"; do
		if [ "$sup" != "testing" ]; then
			if [ "$sup" = "${sup#!}" ]; then
				$CVSUP -L 1 -r 0 -g -b "$ABSROOT" -P $CONNMODE -c .sup "$CONFDIR/supfile.$sup"
			fi
		elif [ "$sup" = "testing" ]; then
			if [ ! -d "$ABSROOT/testing" ]; then
				mkdir "$ABSROOT/testing"
			fi
			cd "$ABSROOT/testing"
			$CVSUP -L 1 -r 0 -g -b "$ABSROOT/testing" -P $CONNMODE -c .sup "$CONFDIR/supfile.testing"
			cd "$ABSROOT"
		fi
	done
} 

if [ "$1" = "-h" -o "$1" = "--help" ]; then
	usage
	exit 0
fi

if [ "$1" = "-V" -o "$1" = "--version" ]; then
	version
	exit 0
fi

if [ ! -d "$ABSROOT" ]; then
	echo "abs: $ABSROOT does not exist (or is not a directory)"
	exit 1
fi
if [ ! -w "$ABSROOT" ]; then
	echo "abs: no write permissions in $ABSROOT"
	exit 1
fi

if [ "$(type -p cvsup)" ]; then
	CVSUP="cvsup"
elif [ "$(type -p csup)" ]; then
	CVSUP="csup"
else
	echo "abs: missing CVS synchronization utility.  Install cvsup or csup."
	exit 1
fi

if [ "$1" = "-p" ] || [ "$1" = "--passive" ]; then
	CONNMODE="-"
	shift
else
	CONNMODE="m"
fi

if [ "$#" -ne "0" ]; then
	SUPFILES=("$@")
fi

update

exit 0
# vim: set ts=2 sw=2 noet: