1 | #!/bin/bash |
---|
2 | |
---|
3 | # Script for building a Seismic Handler release from subversion repository. |
---|
4 | # Main tasks: |
---|
5 | # 1. svn export into temporary directory |
---|
6 | # 2. remove all unwanted files from export |
---|
7 | # 3. build compressed tar file |
---|
8 | # 4. create self-executing installation script |
---|
9 | # |
---|
10 | |
---|
11 | LANG=C |
---|
12 | SRC=$1 |
---|
13 | [ "$SRC" == "" ] && SRC="trunk" |
---|
14 | URI="https://www.seismic-handler.org/svn/SH_SHM/${SRC}/" |
---|
15 | |
---|
16 | function setup { |
---|
17 | TMPDIR=`mktemp -d /tmp/release.XXXXXX` |
---|
18 | echo "0. Temp directory: $TMPDIR" |
---|
19 | #TMPDIR=/tmp/release.b26070/ |
---|
20 | } |
---|
21 | |
---|
22 | function cleanup { |
---|
23 | rm -rf $TMPDIR |
---|
24 | echo "Done. Temp directory removed." |
---|
25 | } |
---|
26 | |
---|
27 | function exportsource { |
---|
28 | echo "1. Exporting source from subversion server..." |
---|
29 | svn --force --quiet export $URI $TMPDIR |
---|
30 | rev=`svn info $URI | awk -F": " '$1=="Last Changed Rev" {print $2}'` |
---|
31 | } |
---|
32 | |
---|
33 | function update { |
---|
34 | echo "2. Updating source tree..." |
---|
35 | |
---|
36 | delinput="shm-config.txt LocalStatinf.dat LocalSensitivities.dat \ |
---|
37 | LocalFilterLookup.dat" |
---|
38 | |
---|
39 | for i in $delinput ; do rm -f $TMPDIR/inputs/$i ; done |
---|
40 | |
---|
41 | mv $TMPDIR/inputs/STATINF.DAT $TMPDIR/inputs/STATINF.DAT.dist |
---|
42 | mv $TMPDIR/inputs/sensitivities.txt $TMPDIR/inputs/sensitivities.txt.dist |
---|
43 | mv $TMPDIR/inputs/filter_lookup.txt $TMPDIR/inputs/filter_lookup.txt.dist |
---|
44 | mv $TMPDIR/inputs/chantrans.txt $TMPDIR/inputs/chantrans.txt.dist |
---|
45 | echo $rev > $TMPDIR/setup/revision |
---|
46 | } |
---|
47 | |
---|
48 | function compress { |
---|
49 | echo "3. Building tar archive..." |
---|
50 | cd $TMPDIR |
---|
51 | tar czf SHM.tar.gz * |
---|
52 | cd $OLDPWD |
---|
53 | } |
---|
54 | |
---|
55 | function joinarchive { |
---|
56 | echo "4. Creating self-extracting executable..." |
---|
57 | cat $TMPDIR/setup/decompress.sh > /tmp/SHM-install.sh |
---|
58 | base64 $TMPDIR/SHM.tar.gz >> /tmp/SHM-install.sh |
---|
59 | chmod 755 /tmp/SHM-install.sh |
---|
60 | } |
---|
61 | |
---|
62 | function main { |
---|
63 | setup |
---|
64 | exportsource |
---|
65 | update |
---|
66 | compress |
---|
67 | joinarchive |
---|
68 | cleanup |
---|
69 | } |
---|
70 | |
---|
71 | main |
---|