#!/bin/bash # This script, create-release.sh, follows the instructions at # http://internal.greenstone.org/wiki/Generating_Caveats_and_Binaries:_Handy_instructions#Generating_the_64_bit_Linux_Caveat # IF ON DARWIN: sudo su - nzdl # IF ON LINUX: sudo su - # Then run this script with gs-release-version and rc-number # http://stackoverflow.com/questions/6482377/bash-shell-script-check-input-argument if [ $# -eq 0 ]; then echo "Run as $0 [release-candidate-number]" echo "E.g. $0 3.06 rc1" echo "" exit fi # String comparisons http://tldp.org/LDP/abs/html/comparison-ops.html os=`uname` currmachine=$os arch=`uname -m` curruser=`whoami` if [ "$os" == "Linux" ] && [ "$curruser" != "root" ] ; then echo "On linux release VMs, you need to first have run: sudo su -" echo "" exit elif [ "$os" == "Darwin" ] && [ "$curruser" != "nzdl" ] ; then echo "On mac release machines, you need to first have run: sudo su - nzdl" echo "" exit fi version=$1 if [ -n "$2" ]; then versionextra=$2 fi ####################################################################### # variables that tend to be fixed for a release machine linuxpath=/home/sjm84 darwinpath=/Volumes/Research/nzdl toro_relkit_path="${darwinpath}/release-kits" rata_relkit_path=/home/nzdl/release-kits ####################################################################### majorversion=3 # if prefixed with 2, then GS2. http://tldp.org/LDP/abs/html/comparison-ops.html if [[ $version == 2* ]]; then majorversion=2; fi # Release foldername should use version without dot # http://www.linuxquestions.org/questions/linux-newbie-8/bash-command-for-removing-special-characters-from-string-644828/ releasefolder=`echo ${version//[-._]/}` releasefolder=gs$releasefolder$versionextra if [ "$os" == "Linux" ]; then source ./setup-env.sh # 64 bit or 32 bit linux vm # http://stackoverflow.com/questions/229551/string-contains-in-bash if [[ $arch == *64 ]]; then currmachine+="64" #/bin/mount --bind /proc /opt/lsb-buildenv-x86_64/proc #chroot /opt/lsb-buildenv-x86_64 #else #/bin/mount --bind /proc /opt/lsb-buildenv-ia32/proc #chroot /opt/lsb-buildenv-ia32 fi export PATH="${linuxpath}/release-kits/bin:$PATH" #echo "PATH : $PATH" cd "${linuxpath}/snapshots" elif [ "$os" == "Darwin" ]; then kernel_release_ver=`uname -r` if [[ $kernel_release_ver == 12.5* ]]; then # toro is 12.5.0 currmachine+="MountainLion" export PATH=$toro_relkit_path/bin:$PATH elif [[ $kernel_release_ver == 9.8* ]]; then # rata is 9.8.0 currmachine+="Leopard" export PATH="${rata_relkit_path}/bin:$PATH" fi cd "${darwinpath}/snapshots" else # not a known OS echo "Unknown OS $os. Cannot generate release-binary. Exitting." echo "" exit fi mkdir $releasefolder cd $releasefolder # create the rk properties file propfile="rk$majorversion" propfile+="-build.properties" touch $propfile echo "version:$version" > $propfile # http://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash # boolean operators: http://www.tldp.org/LDP/abs/html/ops.html if [ -n "$versionextra" ] && [ "$versionextra" != "" ]; then echo "version-extra:$versionextra" >> $propfile fi # os = Linux|Darwin. We wouldn't be here if the os was windows # if GS2, add property pointing to server.exe if [ "$majorversion" == "2" ]; then echo "server.exe.location:http://www.greenstone.org/caveat-emptor/latest-server.exe" >> $propfile fi # Add in architecture, if 64-bit # http://stackoverflow.com/questions/229551/string-contains-in-bash if [[ $arch == *64 ]]; then echo "x64:true" >> $propfile fi # add an empty line echo "" >> $propfile # run `rk3` or `rk2` from the releasefolder `rk$majorversion`