-
Notifications
You must be signed in to change notification settings - Fork 2
/
checkout.svn
executable file
·227 lines (202 loc) · 6.73 KB
/
checkout.svn
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#!/bin/sh
# Create a Gemini Python or Gemaux source tarball from SVN, scraping the
# "GDPSG Wiki" page for the branch & revision corresponding to a given tag.
# Adapted for AstroConda from Ureka's pkg_source.gemini_python (this should
# get significantly simpler as and when the code moves to git).
# Currently, the user must already have SVN login credentials stored.
deps="svn wget" # (wget is only on Linux)
# Parse script arguments:
status=1
unset clean rev pkgname tag
while [ -n "$1" ]; do
case "$1" in
-h)
pkgname=""
status=0
break
;;
--clean)
clean=1
;;
-r) # override wiki revision
shift
rev=$1
[ -z "$rev" ] && status=1
;;
-*)
status=1
break
;;
*)
if [ -z "$pkgname" ]; then
pkgname=$1
status=0
elif [ -z "$tag" ]; then
tag=$1
else
status=1
fi
;;
esac
shift
done
if [ -z "$pkgname" -o $status = 1 ]; then
echo "Usage: `basename $0` [--clean] [-r rev] package [tag]" >&2
exit $status
fi
if [ -n "$rev" ]; then
revflags="-r $rev"
else
revflags="" # set from wiki
fi
case "$pkgname" in
gemini_python|gemini-python)
pkgname="gemini_python"
subpkg=$pkgname
;;
gemaux|gemaux_python|gemaux-python)
pkgname="gemaux_python"
subpkg=$pkgname
;;
disco_stu|disco-stu)
pkgname="gemini_python"
subpkg="disco_stu"
;;
*)
echo "Invalid package name: '$pkgname'" >&2
exit 1
;;
esac
# Get common build configuration & parse the version tag etc.:
. ./config || exit 1
# Generate & change to temporary working directory:
work_in_tmp_dir "$subpkg"
# If a tag other than LATEST is specified, determine the corresponding revision
# number by parsing a table on the group wiki page (sorry, Kathleen insisted on
# using that as the master reference). This should probably have been written
# in Python, but works and is not worth rewriting before the code moves to git.
if [ $tag = "latest" ]; then
branch="trunk"
wiki_status=0
if [ -n "$rev" ]; then
echo "Using trunk r$rev"
else
echo "Using latest trunk revision"
fi
else
wget -nv -O wikipage.html $WIKIPAGE
wiki_status=$?
if [ $pkgname = "gemaux_python" ]; then
titlexpr=">[ \t]*[Gg]emaux.[Pp]ython"
else
titlexpr=">[ \t]*[Gg]emini.[Pp]ython"
fi
if [ $wiki_status = 0 ]; then
# Parse the table of revision numbers into variables using awk:
# - First strip out the relevant table from the page:
cat wikipage.html | awk -v titlexpr="$titlexpr" 'BEGIN {intable=0} \
/<caption>/ {if ($0~titlexpr) {intable=1}} /<\/table>/ {intable=0} \
(intable==1) {print}' > wikitable
# - Next strip out the relevant table row:
cat wikitable | awk -v version=$tag \
'BEGIN {inentry=0; RS="</*tr>"; htag="<td>[ \t]*"version"[ \t<]"} \
{if ($0~htag) print}' > wikiline
# - Parse the row into colon-delimited fields
fields=`cat wikiline | sed -e 's|</td>[ \t]*<td>|:|g' \
-e 's|</*td>||' -e '/^[ \t]*$/d'`
# - Parse the branch name (if any) from the second column:
branch=`echo $fields | awk 'BEGIN {FS=":"} {print $2}' | \
sed -e 's|^[ \t]*||' -e 's|[ \t]*$||'`
if [ -z "$branch" -o "`echo $branch | tr 'A-Z' 'a-z'`" = "trunk" ]
then
branch="trunk"
fi
if [ -z "$revflags" ]; then
# - Parse the revision number from the third column:
rev=`echo $fields | awk 'BEGIN {FS=":"} {print $3}' | \
sed -e 's|^[ \t]*||' -e 's|[ \t]*$||' -e 's|^r||'`
# - Check that what we got was actually a number:
gotnum=`echo $rev | sed -e 's|[0-9][0-9]*|yes|'`
if [ "$gotnum" = "yes" ]; then
echo "Parsed revision: $pkgname $TAG = r$rev ($branch)"
revflags="-r $rev"
else
wiki_status=1
echo "Failed to parse revision for $TAG (got [$rev])" >&2
fi
else
echo "Specified revision: $pkgname $TAG = r$rev ($branch)"
fi
else
echo "Failed to retrieve wiki page" >&2
fi
fi
# If we appear to have got a revision number successfully or are using LATEST,
# check out the relevant package version:
svnopts="-q --non-interactive"
if [ $wiki_status = 0 ]; then
# Attempt check out. Sometimes this times out over the network to Hawaii
# and a single failure can mean repeating a whole addon build process,
# so try 3 times before giving up:
echo -n "Checking out $subpkg $TAG..."
if [ "$subpkg" = "$pkgname" ]; then
suburl=""
else
suburl="${subpkg}"
fi
if [ "$branch" = "trunk" ]; then
url=$SVNROOT/$pkgname/trunk/$suburl
else
url=$SVNROOT/$pkgname/branches/QAP/$branch/$suburl
fi
checkout_status=1
count=0
while [ $checkout_status != 0 -a $count -lt 3 ]; do
[ $count -gt 0 ] && echo -n "repeat..."
svn $svnopts co $revflags $url $pkgstr/
checkout_status=$?
count=`expr $count + 1`
done
# If it worked, package the contents:
# Currently we don't do "python setup.py sdist" because that's broken,
# but installation works directly from the repository tree, so just
# tar that up instead.
if [ $checkout_status = 0 ]; then
echo "done."
echo -n "Making tarball..."
tar zcf ../${session}.tar.gz $pkgstr/
status=$?
cd ..
if [ $status = 0 ]; then
echo "done."
rm -fr $session
mv -f ${session}.tar.gz ${pkgstr}.tar.gz
status=$?
else
echo "failed."
fi
else
echo "failed."
status=1
fi
else
status=1
fi
# This is what we did for Ureka, to provide source tarballs to STScI. We may
# want to do the same thing for AstroConda, but I'm leaving it commented out
# until we establish some logistical details (such as proliferation of
# tarballs now there's a date string, co-ordination of site builds etc).
# # If all went well, replace the tarball on the sftp server with this one.
# # We assume the server has an ssh key from the machine we're running on.
# if [ $status = 0 ]; then
# echo "Initiating upload."
# scp -p ${pkgstr}.tar.gz $gemini_sources/
# status=$?
# fi
# Copy the source to /rtfperm, for use by each build machine (removing any old
# versions if requested to):
if [ $status = 0 ]; then
mv_src_tarball "$pkgstr" $clean || status=1
fi
# Report success/failure:
checkout_victory $status