-
Notifications
You must be signed in to change notification settings - Fork 2
/
makeinstaller
executable file
·189 lines (163 loc) · 6.57 KB
/
makeinstaller
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
#!/bin/bash -e
os=$(uname -s)
showUsage () {
cat << EOF
$0 - creates an release of OMA standalone.
$0 [options] [target_path]
Run this script to create a new release of OMA standalone. The version will
be named according to what 'git describe' returns, so you should generally
create a new tag prior to creating a release.
Options:
-r <host> host where the releases are hosted. Need to be able to ssh to
this host. Also, an environment variable should be set in the
login script that sets DARWIN_BROWSER_SHARE. This can be
overwritten with the -p flag (see below). By default,
linneus77.ethz.ch is used.
-p <path> the path on the remote host where the browser data are stored,
i.e. the value of DARWIN_BROWSER_SHARE. If set, this overwrites
the value that might be set in the login script on the host.
-l do not deploy to the remote host. Just create the tarball
locally in the 'target_path' (see below).
taget_path path where the target is created. If not set,
${TMPDIR:-/tmp} is used.
EOF
}
webhost="linneus77.ethz.ch"
deploy="yes"
webpath=""
hog_branch=""
while getopts "hlr:p:b:" opt ; do
case $opt in
h) showUsage
exit 0
;;
r) webhost="$OPTARG"
;;
p) webpath="$OPTARG"
;;
l) deploy="no"
;;
b) hog_branch="-b $OPTARG"
;;
\?) echo "invalid option" >&2
showUsage
exit 1
;;
:) echo "option -$OPTARG requires an argument" >&2
showUsage
exit 1
;;
esac
done
shift $((OPTIND-1))
tmpdir=${TMPDIR:-/tmp}
target_path=${1:-$tmpdir}
if [ -z "$webpath" ]; then
case "$webhost" in
linneus*)
webpath="/pub/projects/cbrg-oma-browser";;
jet.cs.*)
webpath="/cs/research/biosciences/oma/oma-server";;
prd.vital-it.ch)
webpath="/scratch/ul/projects/cdessimo/oma-browser";;
wally*)
webpath="/nas/FAC/FBM/DBC/cdessim2/oma/D2c/oma-browser";;
*)
webpath=$(ssh $webhost "source ~/.bashrc && echo \$DARWIN_BROWSER_SHARE")
if [ -z "$webpath" ] ; then
echo "remote DARWIN_BROWSER_SHARE is not set"
exit 1
fi;;
esac
fi
webpath="$webpath/standalone"
versionnr=`git describe`
instpath=$target_path/OMA.$versionnr
darwinhome="[email protected]:v2/source/"
jumphost="-J [email protected]"
mkdir -p $instpath/bin
mkdir -p $instpath/DB
mkdir -p $instpath/data
# clone darwin repo, stripe .git folder and copy lib to $instpath
git clone --depth 1 ssh://[email protected]:2222/darwin
rm -rf darwin/lib/.git
mv darwin/lib $instpath/darwinlib
rm -rf darwin
# clone hog_bottom_up python repo
git clone $hog_branch --depth 1 ssh://[email protected]:2222/hog_bottom_up
cd hog_bottom_up; git log -n 1 --format=%H > bottom_up.version; cd ..
rm -rf hog_bottom_up/.git hog_bottom_up/.gitignore
mv hog_bottom_up $instpath/
# copy darwin binaries to $shortname/bin/${shortname}darwin
scp $jumphost $darwinhome/linux64_2.6.9/darwin $instpath/bin/omadarwin.linux64_2.6.9
scp $jumphost $darwinhome/linux64/darwin $instpath/bin/omadarwin.linux64
scp $jumphost $darwinhome/macintel64/darwin $instpath/bin/omadarwin.mac64
# copy oma library to $1/OMA$versionnr/lib
cp -r lib $instpath/
# copy OMA files to $1/OMA$versionnr
cp OMA.drw parameters.drw install.sh README.oma LICENSE release_notes.txt $instpath/
cp bin/oma bin/omadarwin bin/warthog bin/oma-* bin/create_warthog_venv.sh $instpath/bin/
# create file with previous releases that exist for download
prev_rels="Manual/previous_releases.html"
list_fn="/tmp/standalone_list.txt"
ssh $webhost "find $webpath -type f -name '*.tgz' -fprintf $list_fn '%p\t%TY%Tm%Td\t%TY %Tb %Td\n'"
scp $webhost:$list_fn $list_fn
python - << EOF
import os
with open("$list_fn",'rt') as fin, open("$prev_rels", 'w') as fout:
data = [line.split('\\t') for line in fin]
data.sort(key=lambda x:[x[1],x[0]], reverse=True)
fout.write("""<html><head>
<title>OMA standalone - Previous releases</title>
<link href="../browser.css" rel="stylesheet" type="text/css"></link>
<link href="manual.css" rel="stylesheet" type="text/css"></link>
</head><body>
<div class="content"><div class="title">OMA standalone</div>
<h1>Previous Releases</h1>
<table>
<tr><th style="width:220px;">Release</th><th>Release Date</th></tr>
""")
for row in data:
vers = os.path.basename(row[0])
fout.write('<tr><td><a href="http://omabrowser.org/standalone/{0}">{0}</a></td>'
'<td>{1}</td></tr>\\n'
.format(vers, row[2]))
fout.write('</table></body></html>\\n')
EOF
# create manual and copy files to $instpath
darwin < Manual/manual.drw
mkdir $instpath/Manual
cp Manual/manual.pdf $instpath/Manual/
cp Manual/manual.css $instpath/Manual/
cp Manual/manual.html $instpath/Manual/
cp Manual/*png $instpath/Manual/
cp release_notes.txt $instpath/Manual/
cp $prev_rels $instpath/Manual/
# copy toy example to $1/OMA$versionnr
cp -r ToyExample $instpath/ToyExample
(cd $instpath/ToyExample/data; rm GOdata.drw.gz; ln -s GOdata*gz GOdata.drw.gz)
# adjust for version number, remove devolopping functions
if [ $os = "Darwin" ]
then
sed -i '' -e "s/\[VERSIONNR\]/$versionnr/g" $instpath/lib/splashscreen.txt \
$instpath/install.sh $instpath/README.oma $instpath/bin/oma $instpath/hog_bottom_up/gethogs/file_manager.py
sed -i '' "/utildir/d" $instpath/lib/darwinit
sed -i '' "s|datadirname.*|datadirname := libname.'/../data':|" $instpath/darwinlib/darwinit
else
sed -i -e "s/\[VERSIONNR\]/$versionnr/g" $instpath/lib/splashscreen.txt \
$instpath/install.sh $instpath/README.oma $instpath/bin/oma $instpath/hog_bottom_up/gethogs/file_manager.py
sed -i "/utildir/d" $instpath/lib/darwinit
sed -i "s|datadirname.*|datadirname := libname.'/../data':|" $instpath/darwinlib/darwinit
fi
# create tarball
$(cd `dirname $instpath`; tar -cvzf `basename $instpath`.tgz `basename $instpath`)
if [ "$deploy" == "yes" ] ; then
# deploy webpage (html, css and tarball)
scp $(dirname $instpath)/$(basename $instpath).tgz ${webhost}:${webpath}
scp $(dirname $0)/Manual/manual.css ${webhost}:${webpath}
scp $(dirname $0)/Manual/manual.html ${webhost}:${webpath}/index.html
scp $(dirname $0)/Manual/*png ${webhost}:${webpath}
scp $(dirname $0)/Manual/previous_releases.html ${webhost}:${webpath}
scp $(dirname $0)/release_notes.txt ${webhost}:${webpath}
ssh ${webhost} "cd ${webpath}; rm -f OMA.latest.tgz; ln -s $(basename $instpath).tgz OMA.latest.tgz"
fi