Newer
Older
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
#!/bin/bash
# vim:set ts=2 sw=2 ft=sh et:
. /etc/makepkg.conf
repo_path='/home/seblu/scm/archrepo/x86_64'
repo_db='seblu.db.tar.gz'
commit=0 #no commit by default
delete=1 #delete old pkg
usage() {
echo "${0##*/} [options] *$PKGEXT"
echo
echo "options:"
echo " -h: display this help"
echo " -c: svn commit"
echo " -p: preserve old packages in repository"
}
# check args count
(( $# < 1 )) && usage && exit 1
# parse optios
while getopts "hcp" opts; do
case $opts in
c) commit=1;;
d) delete=0;;
h) usage; exit 0;;
*) usage; exit 1;;
esac
done
# skip optional args
(( OPTIND > 0 )) && shift $((OPTIND - 1))
for pkg; do
[[ ! -r "$pkg" ]] && echo "No readable package $pkg, skipped." && continue
[[ ! "$pkg" =~ .*$PKGEXT ]] && echo "Invalid package $pkg, skipped." && continue
mv -i "$pkg" "$repo_path" && (
cd "$repo_path"
svn add "$pkg"
repo-add "$repo_db" "$pkg"
# remove old verions
(( delete )) || continue
pkgname=${pkg%-*}
pkgname=${pkgname%-*}
pkgname=${pkgname%-*}
for j in $pkgname-*$PKGEXT; do
[[ "$pkg" == "$j" ]] && continue
svn rm "$j"
done
)
done
(( commit )) && cd "$repo_path" && svn commit -m "add $*"