Newer
Older
# 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.
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
dbname='seblu'
repo="/srv/http/archlinux/$dbname"
repo_32="$repo/i686"
repo_64="$repo/x86_64"
[[ ! -f PKGBUILD ]] && echo 'No PKGBUILD' && exit 1
source /etc/makepkg.conf
source PKGBUILD
shopt -s nullglob
msg() {
printf "\e[1;32m==>\e[0;1m $1\e[m\n" "${@:1}"
}
# usage : in_array( $needle, $haystack )
# return : 0 - found
# 1 - not found
in_array() {
local needle=$1; shift
local item
for item in "$@"; do
[[ $item = $needle ]] && return 0 # Found
done
return 1 # Not Found
}
# sign $1
sign() {
msg "Sign $1"
gpg --detach-sign "$1" || exit 1
}
# commit
declare -a to_32 to_64
for _pkgname in "${pkgname[@]}"; do
# add any pkg in both repo
filename="$_pkgname-$pkgver-$pkgrel-any$PKGEXT"
if [[ -f "$filename" ]]; then
[[ -f "$filename.sig" ]] || sign "$filename"
# register
to_32+=("$filename")
to_64+=("$filename")
fi
# add i686 repo
filename="$_pkgname-$pkgver-$pkgrel-i686$PKGEXT"
if [[ -f "$filename" ]]; then
[[ -f "$filename.sig" ]] || sign "$filename"
to_32+=("$filename")
fi
# add x86_64 repo
filename="$_pkgname-$pkgver-$pkgrel-x86_64$PKGEXT"
if [[ -f "$filename" ]]; then
[[ -f "$filename.sig" ]] || sign "$filename"
to_64+=("$filename")
fi
done
if ((${#to_32[@]} > 0)); then
msg "Adding into $dbname i686 dir"
# copy new
for _i in "${to_32[@]}"; do
cp -vf "$_i" "$repo_32" || exit 2
cp -vf "$_i.sig" "$repo_32" || exit 2
done
pushd "$repo_32" >/dev/null
# update db
msg "Adding into $dbname i686 db"
repo-add -q -s "$dbname.db.tar.gz" "${to_32[@]}"
msg "Adding into $dbname i686 file db"
repo-add -q -s -f "$dbname.files.tar.gz" "${to_32[@]}"
popd >/dev/null
fi
if ((${#to_64[@]} > 0)); then
msg "Adding into $dbname x86_64 dir"
# copy new
for _i in "${to_64[@]}"; do
cp -vf "$_i" "$repo_64" || exit 2
cp -vf "$_i.sig" "$repo_64" || exit 2
done
pushd "$repo_64" >/dev/null
# update db
msg "Adding into $dbname x86_64 db"
repo-add -q -s "$dbname.db.tar.gz" "${to_64[@]}"
msg "Adding into $dbname x86_64 file db"
repo-add -q -s -f "$dbname.files.tar.gz" "${to_64[@]}"
popd >/dev/null
fi
# vim:set ts=2 sw=2 ft=sh noet: