[23295] | 1 | #!/bin/bash
|
---|
| 2 |
|
---|
[24311] | 3 | MATLAB_PATH="/cygdrive/c/Programs/MATLAB/R2015a"
|
---|
| 4 | PACKAGE="ISSM" # Name of directory to copy distributable files to
|
---|
[23385] | 5 | TARBALL_NAME='ISSM-Win10-64'
|
---|
| 6 | TARBALL=$TARBALL_NAME.tar.gz
|
---|
[23304] | 7 |
|
---|
[23303] | 8 | # Source Windows environment
|
---|
| 9 | source $ISSM_DIR/externalpackages/windows/windows_environment.sh
|
---|
[23298] | 10 |
|
---|
[23385] | 11 | # Clean up from previous packaging
|
---|
| 12 | echo "Cleaning up existing assets"
|
---|
| 13 | cd $ISSM_DIR
|
---|
[24311] | 14 | rm -rf $PACKAGE
|
---|
| 15 | mkdir $PACKAGE
|
---|
[23385] | 16 |
|
---|
| 17 | # Add/modify required binaries
|
---|
| 18 | cd $ISSM_DIR/bin
|
---|
| 19 |
|
---|
[23298] | 20 | echo "Making generic_static.m work like generic.m"
|
---|
| 21 | cat generic_static.m | sed -e "s/generic_static/generic/g" > generic.m
|
---|
| 22 |
|
---|
| 23 | echo "Copying scripts from /src to /bin"
|
---|
[23295] | 24 | rm $ISSM_DIR/bin/*.m
|
---|
[23298] | 25 | find $ISSM_DIR/src/m -name '*.m' | xargs cp -t $ISSM_DIR/bin
|
---|
[23295] | 26 |
|
---|
[23364] | 27 | echo "Copying gmsh to bin"
|
---|
| 28 | if [ -f ../externalpackages/gmsh/install/gmsh.exe ]; then
|
---|
[24311] | 29 | cp ../externalpackages/gmsh/install/gmsh.exe ./gmsh.exe
|
---|
[23364] | 30 | else
|
---|
| 31 | echo "gmsh not found"
|
---|
| 32 | fi
|
---|
| 33 |
|
---|
[24311] | 34 | # Copy gmt to package
|
---|
[23385] | 35 | # NOTE: The following assumes the precompiled version of gmt
|
---|
| 36 | echo "Moving gmt to externalpackages"
|
---|
| 37 | if [ -f $ISSM_DIR/externalpackages/gmt/install/bin/gmt ]; then
|
---|
[24311] | 38 | mkdir $ISSM_DIR/$PACKAGE/externalpackages
|
---|
| 39 | mkdir $ISSM_DIR/$PACKAGE/externalpackages/gmt
|
---|
| 40 | cp -a $ISSM_DIR/externalpackages/gmt/install $ISSM_DIR/$PACKAGE/externalpackages/gmt/install
|
---|
[23385] | 41 | else
|
---|
| 42 | echo "gmt not found"
|
---|
| 43 | fi
|
---|
| 44 |
|
---|
[23298] | 45 | # Check that test 101 runs
|
---|
| 46 | cd $ISSM_DIR/test/NightlyRun
|
---|
| 47 | rm matlab.log
|
---|
[23303] | 48 | $MATLAB_PATH/bin/matlab -nodisplay -nosplash -r "try, addpath $ISSM_DIR_WIN/bin $ISSM_DIR_WIN/lib; runme('id',101); exit; catch me,fprintf('%s',getReport(me)); exit; end" -logfile matlab.log
|
---|
[23295] | 49 |
|
---|
[23313] | 50 | # Wait until MATLAB closes
|
---|
| 51 | sleep 5
|
---|
| 52 | pid=$(ps aux -W | grep MATLAB | awk '{printf("%s\n","MATLAB");}')
|
---|
| 53 | while [ -n "$pid" ]
|
---|
| 54 | do
|
---|
[23312] | 55 | pid=$(ps aux -W | grep MATLAB | awk '{printf("%s\n","MATLAB");}')
|
---|
[23313] | 56 | sleep 1
|
---|
| 57 | done
|
---|
[23312] | 58 |
|
---|
[23298] | 59 | if [[ $(cat matlab.log | grep -c SUCCESS) -lt 10 ]]; then
|
---|
| 60 | echo "test101 FAILED"
|
---|
| 61 | exit 1;
|
---|
| 62 | else
|
---|
| 63 | echo "test101 passed"
|
---|
| 64 | fi
|
---|
[23295] | 65 |
|
---|
[23298] | 66 | # Create tarball
|
---|
[23385] | 67 | echo "Creating tarball: ${TARBALL_NAME}"
|
---|
| 68 | cd $ISSM_DIR
|
---|
| 69 | rm -f $TARBALL
|
---|
[24311] | 70 | cp -rf bin lib test examples scripts $PACKAGE/
|
---|
[23295] | 71 |
|
---|
[23385] | 72 | # Create link to gmt from bin
|
---|
| 73 | # NOTE: It is important that we are in the destination dir when sym linking so that the path is relative
|
---|
[24311] | 74 | if [ -f $ISSM_DIR/$PACKAGE/externalpackages/gmt/bin/gmt ]; then
|
---|
| 75 | cd $ISSM_DIR/$PACKAGE/bin
|
---|
| 76 | ln -s ../externalpackages/gmt/bin/gmt.exe ./gmt.exe
|
---|
[23385] | 77 | fi
|
---|
| 78 |
|
---|
[23298] | 79 | cd $ISSM_DIR
|
---|
[24311] | 80 | tar -czf $TARBALL $PACKAGE
|
---|
[23385] | 81 | ls -lah $TARBALL
|
---|
[23295] | 82 |
|
---|
[23326] | 83 | # Ship binaries to website
|
---|
| 84 | echo "Shipping binaries to website"
|
---|
[23298] | 85 |
|
---|
[23326] | 86 | # We're using public key authentication method to upload the tarball The
|
---|
| 87 | # following lines check to see if the SSH Agent is running. If not, then it is
|
---|
| 88 | # started and relevant information is forwarded to a script.
|
---|
| 89 | pgrep "ssh-agent" > /dev/null
|
---|
| 90 |
|
---|
| 91 | if [ $? -ne 0 ]; then
|
---|
| 92 | echo "SSH agent is not running. Starting it..."
|
---|
| 93 | ssh-agent > ~/.ssh/agent.sh
|
---|
| 94 | else
|
---|
| 95 | echo "SSH agent is running..."
|
---|
| 96 | fi
|
---|
| 97 |
|
---|
| 98 | source ~/.ssh/agent.sh
|
---|
| 99 | ssh-add ~/.ssh/win_bins-geidi_prime_to_ross
|
---|
| 100 |
|
---|
[23385] | 101 | scp $TARBALL jenkins@ross.ics.uci.edu:/var/www/html/$TARBALL
|
---|
[23326] | 102 |
|
---|
| 103 | if [ $? -ne 0 ]; then
|
---|
| 104 | echo "The upload failed."
|
---|
| 105 | echo "Perhaps the SSH agent was started by some other means."
|
---|
| 106 | echo "Try killing the agent and running again."
|
---|
| 107 | fi
|
---|