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