-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-snapshot
executable file
·87 lines (68 loc) · 2.23 KB
/
update-snapshot
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
#!/bin/sh
LOCKFILE_PATH=/opt/buildbot/update-snapshot.lock
LASTUPDATE_PATH=/opt/buildbot/update-snapshot.lastupdate
SCRIPT_PATH=$(dirname $0)
TARBALL_PATH=/opt/buildbot/lsb-master
TOP_PATH=/opt/buildbot/ftpdir
SNAPSHOT_PATH=pub/lsb/snapshots
REPOSITORY_PATH=pub/lsb/repositories
STAGING_PATH=pub/lsb/staging
UPLOAD_TARGET=/srv/ftp
BZR_PROGRESS_BAR=none
FTP_ROOT=$TOP_PATH
BUILD_DEBIAN=yes
LSB_VERSION=snapshot
export BZR_PROGRESS_BAR FTP_ROOT BUILD_DEBIAN LSB_VERSION
# Make sure only one of this script runs at a time.
echo $$ > $LOCKFILE_PATH.$$ 2>/dev/null || exit 1
ln $LOCKFILE_PATH.$$ $LOCKFILE_PATH 2>/dev/null || {
kill -0 $(cat $LOCKFILE_PATH) 2> /dev/null || {
rm -f $LOCKFILE_PATH
}
rm -f $LOCKFILE_PATH.$$
exit 0
}
rm -f $LOCKFILE_PATH.$$
# Check that there's a real update needed; incron isn't smart enough
# to only fire on actual tarball uploads.
if [ -f $LASTUPDATE_PATH ]; then
if [ $(find $TARBALL_PATH -name '*tar.gz' -newer $LASTUPDATE_PATH -print \
| wc -l) -eq 0 ]; then
rm -f $LOCKFILE_PATH
exit 0
fi
fi
# Record the last update time. We do this here to minimize the race
# condition between the above check and new uploads, so that a newly
# finished job doesn't slip through the cracks.
touch $LASTUPDATE_PATH
# Actually do the updates. Snapshot first.
$SCRIPT_PATH/update-snapshot-sdk
$SCRIPT_PATH/update-snapshot-prj
# Create snapshot repositories.
cd $TOP_PATH
bzr checkout -q http://bzr.linuxfoundation.org/lsb/devel/repogen
cd repogen
make -s snapshot
make -s install-snapshot
cd ..
rm -rf repogen
# Staging.
$SCRIPT_PATH/update-staging
# Send updates to the FTP site.
cd $TOP_PATH/$SNAPSHOT_PATH
rsync -a --delete * $UPLOAD_TARGET/$SNAPSHOT_PATH
if [ -d $TOP_PATH/$STAGING_PATH ]; then
cd $TOP_PATH/$STAGING_PATH
rsync -a --delete * $UPLOAD_TARGET/$STAGING_PATH
fi
cd $TOP_PATH/$REPOSITORY_PATH/rpm
rsync -a --delete lsb-snapshot $UPLOAD_TARGET/pub/lsb/repositories/rpm
if [ -d $TOP_PATH/$REPOSITORY_PATH/debian ]; then
cd $TOP_PATH/$REPOSITORY_PATH/debian
rsync -a --delete pkgs-snapshot $UPLOAD_TARGET/pub/lsb/repositories/debian
cd dists
rsync -a --delete lsb-snapshot $UPLOAD_TARGET/pub/lsb/repositories/debian/dists
fi
# Release the lock.
rm -f $LOCKFILE_PATH