blob: 4f64dfec4e09e2116040b8202e7c94d330b9ce7b (
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
|
#!/bin/bash
# where are the arch scripts located?
ARCHDIR="/arch"
#All this fun stuff used to be in the db-(whatever) files
# Let's make it cleaner
export CARCH="$arch"
ftppath="/home/ftp/$reponame/os/$arch/"
svnpath="/home/svn-packages"
svnrepo="$reponame-$arch"
#Hacky for now
if [ "$arch" = "x86_64" ]; then
stagedir="$HOME/staging/$reponame-64"
else
stagedir="$HOME/staging/$reponame"
fi
[ "$UID" = "" ] && UID=$(uid)
TMPDIR="/tmp/archpkg.$arch.$repoid.$UID"
if [ ! `type -p fakeroot` ]; then
echo "error: fakeroot is missing" >&2
exit 1
fi
if [ ! -d $stagedir ]; then
echo "error: staging directory missing: $stagedir" >&2
exit 1
fi
# Get the package name from the filename
# hackish, but should work for now
getpkgname() {
local tmp
tmp=${1##*/}
tmp=${tmp%.pkg.tar.gz}
tmp=${tmp%-i686}
tmp=${tmp%-x86_64}
echo ${tmp%-*-*}
}
cleanup() {
rm -rf $TMPDIR
# unlock
rm -f /tmp/.repolck.$arch.$repoid
[ "$1" ] && exit $1
}
ctrl_c() {
echo "Interrupted" >&2
cleanup 0
}
die() {
echo "$*" >&2
cleanup 1
}
# check for locks
if [ -f /tmp/.repolck.$arch.$repoid ]; then
owner=`/bin/ls -l /tmp/.repolck.$arch.$repoid | awk '{print $3}'`
echo "error: db generation is already in progress (started by $owner)"
exit 1
fi
# catch ^C breaks
trap ctrl_c SIGINT
# lock
touch /tmp/.repolck.$arch.$repoid
# RedHat's mktemp is broken...
if [ -d $TMPDIR ]; then
echo "==> Removing old temp dir..." >&2
rm -rf $TMPDIR || exit 1
fi
mkdir $TMPDIR; [ $? -gt 0 ] && exit 1
cd $TMPDIR
# Checkout the SVN module if we need to
updatelists=
if [ "`ls $stagedir/add 2>/dev/null`" -o "`ls $stagedir/del 2>/dev/null`" ]; then
# if $svndir is set, then use that instead of doing our own cvs checkout
if [ "$svndir" ]; then
mv $svndir $TMPDIR/checkout
else
echo "==> Checking out repo: $svnrepo ($arch)"
svn export file://$svnpath $TMPDIR/checkout
if [ $? -gt 0 ]; then
die "==> SVN export failed!"
fi
fi
updatelists=1
else
echo "No files to process"
cleanup 0
fi
# Right-O, now we look through the "add" and "del" subdirectories of
# $stagedir and process the packages there accordingly -- all packages
# in the "add" dir are added/updated, all packages in the "del" dir
# are removed.
#
# This means the sync db could actually be unpacked/repacked twice in
# one db-* invocation, but it's not a huge performance hit.
if [ -d $stagedir/add -a "`ls $stagedir/add`" ]; then
cd $TMPDIR
echo "==> Processing new/updated packages for repository '$reponame'..." >&2
# copy the db file into our working area
cp $ftppath/$reponame.db.tar.gz .
cd $stagedir/add
# run it thru fakeroot make sure everything is owned by root.root
echo "$ARCHDIR/updatesync-many add $TMPDIR/$reponame.db.tar.gz $TMPDIR/checkout $svnrepo" \
| fakeroot
if [ $? -ne 0 ]; then
die "==> Error returned from updatesync-many"
fi
cp $TMPDIR/$reponame.db.tar.gz $ftppath
# only for i686 (for now)
if [ "$arch" = "i686" ]; then
echo "==> Scanning for New/Updated packages..." >&2
cd $stagedir/add
$ARCHDIR/pkgdb1 $TMPDIR/checkout $svnrepo | $ARCHDIR/pkgdb2-add $repoid $stagedir/add
fi
# move the package files into the ftp directory
mv -f $stagedir/add/*.pkg.tar.gz $ftppath
fi
if [ -d $stagedir/del -a "`ls $stagedir/del`" ]; then
cd $TMPDIR
echo "==> Processing deleted packages for repository '$reponame'..." >&2
# copy the db file into our working area
cp $ftppath/$reponame.db.tar.gz .
cd $stagedir/del
# run it thru fakeroot make sure everything is owned by root.root
echo "$ARCHDIR/updatesync-many del $TMPDIR/$reponame.db.tar.gz NOT-USED ZOMGWOO" \
| fakeroot
if [ $? -ne 0 ]; then
die "==> Error returned from updatesync-many"
fi
cp $TMPDIR/$reponame.db.tar.gz $ftppath
# only for i686 (for now)
if [ "$arch" = "i686" ]; then
echo "==> Scanning for Deleted packages..." >&2
cd $stagedir/del
(
for i in *.pkg.tar.gz; do
pkgname=$(getpkgname $i)
echo $pkgname
done
) | $ARCHDIR/pkgdb2-del $repoid $stagedir/del
fi
# remove the package files
rm -f $stagedir/del/*.pkg.tar.gz
fi
if [ "$updatelists" ]; then
echo "==> Generating Text Package List..." >&2
cd $TMPDIR/checkout
$ARCHDIR/genpkglist $ftppath $arch
mv packages.txt $ftppath/packages.txt
fi
cleanup
# vim: set ts=4 sw=4 noet ft=sh:
|