blob: b56a70f4886034a26189dae0a3a305224a9be386 (
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
#!/bin/bash
if [ $# -ne 1 ]; then
msg "usage: $(basename $0) <reponame>"
exit 1
fi
. "$(dirname $0)/db-functions"
. "$(dirname $0)/config"
reponame="$1"
current_arch=""
if ! check_repo_permission "$reponame"; then
error "you shouldn't be updating $reponame on this server!"
exit 1
fi
ADDPKGS=""
ANYPKGS=""
stagedir="$STAGING/$reponame"
if [ ! -d $stagedir ]; then
error "staging directory missing: $stagedir"
exit 1
fi
msg "Updating $reponame..."
# Remove any package from $stagedir that is already in the FTP repository
for current_arch in ${ARCHES[@]} any; do
ftppath="$FTP_BASE/$reponame/os/$current_arch"
for f in $stagedir/*-$current_arch$PKGEXT; do
bf=$(basename $f)
if [[ -f $ftppath/$bf ]]; then
warning " Package file $bf already exists in FTP repo" \
" Removing from $stagedir"
/bin/rm $f
fi
done
done
# Process architecture-independent packages first.
if [ -d "$stagedir" ]; then
ANYPKGS="$(getpkgfiles $stagedir/*-any$PKGEXT 2>/dev/null)"
fi
cd "$WORKDIR"
if [ -n "$ANYPKGS" ]; then
pkgtotal=$(echo "$ANYPKGS" | wc -w)
/usr/bin/svn checkout -q -N $SVNREPO checkout >/dev/null
cd checkout
to_add_any=""
for pkg in $ANYPKGS; do
pkgfile=$(basename $pkg)
pkgname="$(getpkgname $pkg)"
pkgbase="$(getpkgbase $pkg)"
svnrepo="$reponame-any"
if ! check_pkg_arch "$pkg" "any"; then
error "$pkgfile is not architecture independent!"
else
/usr/bin/svn up -q $pkgbase
if [ -d "$pkgbase/repos/$svnrepo" ]; then
pkgver=$(. "$pkgbase/repos/$svnrepo/PKGBUILD"; echo ${pkgver})
pkgrel=$(. "$pkgbase/repos/$svnrepo/PKGBUILD"; echo ${pkgrel})
if echo "$pkgfile" | grep -q "$pkgname-$pkgver-$pkgrel-any"; then
to_add_any="$to_add_any $pkg"
else
warning "$pkgfile does not match PKGBUILD in $svnrepo"
fi
else
warning "Package $pkgbase not found in $svnrepo"
fi
fi
done
fi
for current_arch in ${ARCHES[@]}; do
ftppath="$FTP_BASE/$reponame/os/$current_arch"
ftppath_any="$FTP_BASE/$reponame/os/any"
poolpath="$FTP_BASE/$(get_pkgpool_for_host)"
# The following is used to create relative symlinks
poolrel="../../../$(get_pkgpool_for_host)"
if [ ! -d "$ftppath" ]; then
error "FTP path for this repo ($reponame) is missing" \
" -> $ftppath" \
"Please contact a system administrator"
exit 1
fi
svnrepo="$reponame-$current_arch"
repo_lock $reponame $current_arch || continue
/bin/mkdir -p "$WORKDIR/build"
cd "$WORKDIR"
# copy the db file into our working area
if [ -f "$ftppath/$reponame$DBEXT" ]; then
/bin/cp "$ftppath/$reponame$DBEXT" build/$reponame-$current_arch$DBEXT
fi
to_add=""
if [ -d "$stagedir" ]; then
ADDPKGS="$(getpkgfiles $stagedir/*-${current_arch}$PKGEXT 2>/dev/null)"
fi
if [ -n "$ADDPKGS" -o -n "$ANYPKGS" ]; then
if [ -f "$ftppath/$reponame$DBEXT" ]; then
/bin/cp "$ftppath/$reponame$DBEXT" build/$reponame-$current_arch$DBEXT
fi
pkgtotal=$(echo "$ADDPKGS $ANYPKGS" | wc -w)
cd "$WORKDIR"
/usr/bin/svn checkout -N $SVNREPO checkout >/dev/null
cd checkout
if [ -n "$ADDPKGS" ]; then
for pkg in $ADDPKGS; do
pkgfile=$(basename $pkg)
pkgname="$(getpkgname $pkg)"
pkgbase="$(getpkgbase $pkg)"
if ! check_pkg_arch "$pkg" "$current_arch"; then
error "$pkgfile was built for the wrong architecture"
else
/usr/bin/svn up -q $pkgbase
if [ -d "$pkgbase/repos/$svnrepo" ]; then
pkgver=$(. "$pkgbase/repos/$svnrepo/PKGBUILD"; echo ${pkgver})
pkgrel=$(. "$pkgbase/repos/$svnrepo/PKGBUILD"; echo ${pkgrel})
if echo "$pkgfile" | grep -q "$pkgname-$pkgver-$pkgrel-$current_arch"; then
to_add="$to_add $pkg"
else
warning "$pkgfile does not match PKGBUILD in $svnrepo"
fi
else
warning "Package $pkgbase not found in $svnrepo"
fi
fi
done
fi
if [ -n "$to_add" -o -n "$to_add_any" ]; then
cd "$WORKDIR/build/"
for f in $to_add $to_add_any; do /bin/cp "$f" .; done
pkgs=""
for pkg in $to_add $to_add_any; do pkgs="$pkgs $(basename $pkg)"; done
/usr/bin/repo-add -q "$reponame-$current_arch$DBEXT" $pkgs >/dev/null
else
rm -f "build/$reponame-$current_arch$DBEXT"
error "Errors found when adding packages"
fi
else
warning "No packages to add"
fi
# if non empty, move all build dirs
if [ $(/bin/ls "$WORKDIR/build/" 2>/dev/null | wc -l) != 0 ]; then
if [ $(getpkgfiles "$WORKDIR/build/"*-$current_arch$PKGEXT 2>/dev/null | wc -l) != 0 ]; then
for f in "$WORKDIR/build/"*-$current_arch$PKGEXT; do
/bin/chmod 664 "$f" &>/dev/null
if ! /bin/cp "$f" "$poolpath/"; then
die "failure while copying files to $poolpath"
fi
fname="$(basename $f)"
if ! ln -s "$poolrel/$fname" "$ftppath/$fname"; then
die "failure symlinking $fname to $ftppath"
fi
done
fi
if [ $(getpkgfiles "$WORKDIR/build/"*-any$PKGEXT 2>/dev/null | wc -l) != 0 ]; then
for f in "$WORKDIR/build/"*-any$PKGEXT; do
/bin/chmod 664 "$f" &>/dev/null
fname="$(basename $f)"
if ! /bin/cp "$f" "$poolpath/"; then
die "failure while copying files to $poolpath"
fi
if ! ln -s "$poolrel/$fname" "$ftppath/$fname"; then
die "failure symlinking $fname to $ftppath"
fi
done
fi
if ! /bin/cp "$WORKDIR/build/$reponame-$current_arch$DBEXT" "$ftppath/$reponame$DBEXT"; then
die "failed to move repository $reponame-$current_arch".
fi
ln -sf "$reponame$DBEXT" "$ftppath/$reponame${DBEXT%.tar.*}"
else
warning "Nothing to copy, no work done"
fi
if [ -n "$to_add" ]; then
/bin/rm $to_add
fi
repo_unlock $reponame $current_arch
done
if [ -n "$to_add_any" ]; then
/bin/rm $to_add_any
fi
# vim: set ts=4 sw=4 noet ft=sh:
|