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 | URI="https://www.seismic-handler.org/svn/SH_SHM/trunk/" |
---|
13 | |
---|
14 | function setup { |
---|
15 | TMPDIR=`mktemp -d /tmp/release.XXXXXX` |
---|
16 | echo "0. Temp directory: $TMPDIR" |
---|
17 | #TMPDIR=/tmp/release.b26070/ |
---|
18 | } |
---|
19 | |
---|
20 | function cleanup { |
---|
21 | rm -rf $TMPDIR |
---|
22 | echo "Done. Temp directory removed." |
---|
23 | } |
---|
24 | |
---|
25 | function exportsource { |
---|
26 | echo "1. Exporting source from subversion server..." |
---|
27 | svn --force --quiet export $URI $TMPDIR |
---|
28 | rev=`svn info $URI | awk -F": " '$1=="Last Changed Rev" {print $2}'` |
---|
29 | } |
---|
30 | |
---|
31 | function update { |
---|
32 | echo "2. Updating source tree..." |
---|
33 | |
---|
34 | delinput="shm-config.txt LocalStatinf.dat LocalSensitivities.dat \ |
---|
35 | LocalFilterLookup.dat" |
---|
36 | |
---|
37 | rm $TMPDIR/setup/shsetup |
---|
38 | for i in $delinput ; do rm $TMPDIR/inputs/$i ; done |
---|
39 | |
---|
40 | mv $TMPDIR/inputs/STATINF.DAT $TMPDIR/inputs/STATINF.DAT.dist |
---|
41 | mv $TMPDIR/inputs/sensitivities.txt $TMPDIR/inputs/sensitivities.txt.dist |
---|
42 | mv $TMPDIR/inputs/filter_lookup.txt $TMPDIR/inputs/filter_lookup.txt.dist |
---|
43 | mv $TMPDIR/inputs/chantrans.txt $TMPDIR/inputs/chantrans.txt.dist |
---|
44 | echo $rev > $TMPDIR/setup/revision |
---|
45 | } |
---|
46 | |
---|
47 | function compress { |
---|
48 | echo "3. Building tar archive..." |
---|
49 | cd $TMPDIR |
---|
50 | tar czf SHM.tar.gz * |
---|
51 | cd $OLDPWD |
---|
52 | } |
---|
53 | |
---|
54 | function joinarchive { |
---|
55 | echo "4. Creating self-extracting executable..." |
---|
56 | cat decompress.sh > /tmp/SHM-install.sh |
---|
57 | base64 $TMPDIR/SHM.tar.gz >> /tmp/SHM-install.sh |
---|
58 | } |
---|
59 | |
---|
60 | function main { |
---|
61 | setup |
---|
62 | exportsource |
---|
63 | update |
---|
64 | compress |
---|
65 | joinarchive |
---|
66 | cleanup |
---|
67 | } |
---|
68 | |
---|
69 | main |
---|