Newer
Older
#!/bin/bash
# vim:set ts=2 sw=2 ft=sh et:
# Copyright © Sébastien Luttringer
#
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
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
. /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 $*"