1 | #!/bin/bash
|
---|
2 |
|
---|
3 | MATLAB_PATH="/cygdrive/c/Programs/MATLAB/R2015a"
|
---|
4 | PACKAGE="ISSM" # Name of directory to copy distributable files to
|
---|
5 | TARBALL_NAME='ISSM-Win10-64'
|
---|
6 | TARBALL=$TARBALL_NAME.tar.gz
|
---|
7 |
|
---|
8 | # Source Windows environment
|
---|
9 | source $ISSM_DIR/externalpackages/windows/windows_environment.sh
|
---|
10 |
|
---|
11 | # Clean up from previous packaging
|
---|
12 | echo "Cleaning up existing assets"
|
---|
13 | cd $ISSM_DIR
|
---|
14 | rm -rf $PACKAGE
|
---|
15 | mkdir $PACKAGE
|
---|
16 |
|
---|
17 | # Add/modify required binaries
|
---|
18 | cd $ISSM_DIR/bin
|
---|
19 |
|
---|
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"
|
---|
24 | rm $ISSM_DIR/bin/*.m
|
---|
25 | find $ISSM_DIR/src/m -name '*.m' | xargs cp -t $ISSM_DIR/bin
|
---|
26 |
|
---|
27 | echo "Copying gmsh to bin"
|
---|
28 | if [ -f ../externalpackages/gmsh/install/gmsh.exe ]; then
|
---|
29 | cp ../externalpackages/gmsh/install/gmsh.exe ./gmsh.exe
|
---|
30 | else
|
---|
31 | echo "gmsh not found"
|
---|
32 | fi
|
---|
33 |
|
---|
34 | # Copy gmt to package
|
---|
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
|
---|
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
|
---|
41 | else
|
---|
42 | echo "gmt not found"
|
---|
43 | fi
|
---|
44 |
|
---|
45 | # Check that test 101 runs
|
---|
46 | cd $ISSM_DIR/test/NightlyRun
|
---|
47 | rm matlab.log
|
---|
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
|
---|
49 |
|
---|
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
|
---|
55 | pid=$(ps aux -W | grep MATLAB | awk '{printf("%s\n","MATLAB");}')
|
---|
56 | sleep 1
|
---|
57 | done
|
---|
58 |
|
---|
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
|
---|
65 |
|
---|
66 | # Create tarball
|
---|
67 | echo "Creating tarball: ${TARBALL_NAME}"
|
---|
68 | cd $ISSM_DIR
|
---|
69 | rm -f $TARBALL
|
---|
70 | cp -rf bin lib test examples scripts $PACKAGE/
|
---|
71 |
|
---|
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
|
---|
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
|
---|
77 | fi
|
---|
78 |
|
---|
79 | cd $ISSM_DIR
|
---|
80 | tar -czf $TARBALL $PACKAGE
|
---|
81 | ls -lah $TARBALL
|
---|
82 |
|
---|
83 | # Ship binaries to website
|
---|
84 | echo "Shipping binaries to website"
|
---|
85 |
|
---|
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 |
|
---|
101 | scp $TARBALL jenkins@ross.ics.uci.edu:/var/www/html/$TARBALL
|
---|
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
|
---|