1 | #!/bin/bash
|
---|
2 |
|
---|
3 | # This script, create-release.sh, follows the instructions at
|
---|
4 | # http://internal.greenstone.org/wiki/Generating_Caveats_and_Binaries:_Handy_instructions#Generating_the_64_bit_Linux_Caveat
|
---|
5 |
|
---|
6 | # IF ON DARWIN: sudo su - nzdl
|
---|
7 | # IF ON LINUX: sudo su -
|
---|
8 | # Then run this script with gs-release-version and rc-number
|
---|
9 |
|
---|
10 | # http://stackoverflow.com/questions/6482377/bash-shell-script-check-input-argument
|
---|
11 | if [ $# -eq 0 ]; then
|
---|
12 | echo "Run as $0 <version> [release-candidate-number]"
|
---|
13 | echo "E.g. $0 3.06 rc1"
|
---|
14 | echo ""
|
---|
15 | exit
|
---|
16 | fi
|
---|
17 |
|
---|
18 | # String comparisons http://tldp.org/LDP/abs/html/comparison-ops.html
|
---|
19 | os=`uname`
|
---|
20 | currmachine=$os
|
---|
21 | arch=`uname -m`
|
---|
22 | curruser=`whoami`
|
---|
23 | if [ "$os" == "Linux" ] && [ "$curruser" != "root" ] ; then
|
---|
24 | echo "On linux release VMs, you need to first have run: sudo su -"
|
---|
25 | echo ""
|
---|
26 | exit
|
---|
27 | elif [ "$os" == "Darwin" ] && [ "$curruser" != "nzdl" ] ; then
|
---|
28 | echo "On mac release machines, you need to first have run: sudo su - nzdl"
|
---|
29 | echo ""
|
---|
30 | exit
|
---|
31 | fi
|
---|
32 |
|
---|
33 |
|
---|
34 | version=$1
|
---|
35 | if [ -n "$2" ]; then
|
---|
36 | versionextra=$2
|
---|
37 | fi
|
---|
38 |
|
---|
39 |
|
---|
40 | #######################################################################
|
---|
41 | # variables that tend to be fixed for a release machine
|
---|
42 |
|
---|
43 | linuxpath=/home/sjm84
|
---|
44 | darwinpath=/Volumes/Research/nzdl
|
---|
45 | toro_relkit_path="${darwinpath}/release-kits"
|
---|
46 | rata_relkit_path=/home/nzdl/release-kits
|
---|
47 |
|
---|
48 |
|
---|
49 | #######################################################################
|
---|
50 |
|
---|
51 | majorversion=3
|
---|
52 | # if prefixed with 2, then GS2. http://tldp.org/LDP/abs/html/comparison-ops.html
|
---|
53 | if [[ $version == 2* ]]; then
|
---|
54 | majorversion=2;
|
---|
55 | fi
|
---|
56 |
|
---|
57 |
|
---|
58 | # Release foldername should use version without dot
|
---|
59 | # http://www.linuxquestions.org/questions/linux-newbie-8/bash-command-for-removing-special-characters-from-string-644828/
|
---|
60 | releasefolder=`echo ${version//[-._]/}`
|
---|
61 | releasefolder=gs$releasefolder$versionextra
|
---|
62 |
|
---|
63 |
|
---|
64 | if [ "$os" == "Linux" ]; then
|
---|
65 | source ./setup-env.sh
|
---|
66 | # 64 bit or 32 bit linux vm
|
---|
67 | # http://stackoverflow.com/questions/229551/string-contains-in-bash
|
---|
68 | if [[ $arch == *64 ]]; then
|
---|
69 | currmachine+="64"
|
---|
70 | #/bin/mount --bind /proc /opt/lsb-buildenv-x86_64/proc
|
---|
71 | #chroot /opt/lsb-buildenv-x86_64
|
---|
72 | #else
|
---|
73 | #/bin/mount --bind /proc /opt/lsb-buildenv-ia32/proc
|
---|
74 | #chroot /opt/lsb-buildenv-ia32
|
---|
75 | fi
|
---|
76 | export PATH="${linuxpath}/release-kits/bin:$PATH"
|
---|
77 | #echo "PATH : $PATH"
|
---|
78 | cd "${linuxpath}/snapshots"
|
---|
79 |
|
---|
80 | elif [ "$os" == "Darwin" ]; then
|
---|
81 | kernel_release_ver=`uname -r`
|
---|
82 | if [[ $kernel_release_ver == 12.5* ]]; then
|
---|
83 | # toro is 12.5.0
|
---|
84 | currmachine+="MountainLion"
|
---|
85 | export PATH=$toro_relkit_path/bin:$PATH
|
---|
86 | elif [[ $kernel_release_ver == 9.8* ]]; then
|
---|
87 | # rata is 9.8.0
|
---|
88 | currmachine+="Leopard"
|
---|
89 | export PATH="${rata_relkit_path}/bin:$PATH"
|
---|
90 | fi
|
---|
91 |
|
---|
92 | cd "${darwinpath}/snapshots"
|
---|
93 | else
|
---|
94 | # not a known OS
|
---|
95 | echo "Unknown OS $os. Cannot generate release-binary. Exitting."
|
---|
96 | echo ""
|
---|
97 | exit
|
---|
98 | fi
|
---|
99 |
|
---|
100 |
|
---|
101 | mkdir $releasefolder
|
---|
102 | cd $releasefolder
|
---|
103 |
|
---|
104 | # create the rk properties file
|
---|
105 | propfile="rk$majorversion"
|
---|
106 | propfile+="-build.properties"
|
---|
107 | touch $propfile
|
---|
108 |
|
---|
109 | echo "version:$version" > $propfile
|
---|
110 |
|
---|
111 | # http://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash
|
---|
112 | # boolean operators: http://www.tldp.org/LDP/abs/html/ops.html
|
---|
113 | if [ -n "$versionextra" ] && [ "$versionextra" != "" ]; then
|
---|
114 | echo "version-extra:$versionextra" >> $propfile
|
---|
115 | fi
|
---|
116 |
|
---|
117 | # os = Linux|Darwin. We wouldn't be here if the os was windows
|
---|
118 | # if GS2, add property pointing to server.exe
|
---|
119 | if [ "$majorversion" == "2" ]; then
|
---|
120 | echo "server.exe.location:http://www.greenstone.org/caveat-emptor/latest-server.exe" >> $propfile
|
---|
121 | fi
|
---|
122 |
|
---|
123 | # Add in architecture, if 64-bit
|
---|
124 | # http://stackoverflow.com/questions/229551/string-contains-in-bash
|
---|
125 | if [[ $arch == *64 ]]; then
|
---|
126 | echo "x64:true" >> $propfile
|
---|
127 | fi
|
---|
128 |
|
---|
129 | # add an empty line
|
---|
130 | echo "" >> $propfile
|
---|
131 |
|
---|
132 | # run `rk3` or `rk2` from the releasefolder
|
---|
133 | `rk$majorversion`
|
---|