1 | #!/bin/bash
|
---|
2 |
|
---|
3 |
|
---|
4 | ## Constants
|
---|
5 | #
|
---|
6 | LIBGFORTRAN="/usr/lib/x86_64-linux-gnu/libgfortran.so.5.0.0" # Important that this is the library itself
|
---|
7 | LIBGFORTRAN_DIST="${ISSM_DIR}/lib/libgfortran.so.5" # Important the file name matches the SONAME entry in the binaries and other shared libraries which link to it
|
---|
8 | MATLAB_NROPTIONS="'exclude',[IdFromString('Dakota'),125,126]" # Exclude Dakota tests and any tests with transient solutions that require a restart
|
---|
9 | MATLAB_PATH="/usr/local/MATLAB/R2019b"
|
---|
10 | PACKAGE="ISSM" # Name of directory to copy distributable files to
|
---|
11 | TARBALL_NAME="issm-linux"
|
---|
12 | TARBALL="${TARBALL_NAME}.tar.gz"
|
---|
13 |
|
---|
14 | # Clean up from previous packaging
|
---|
15 | echo "Cleaning up existing assets"
|
---|
16 | cd ${ISSM_DIR}
|
---|
17 | rm -rf ${PACKAGE}
|
---|
18 | mkdir ${PACKAGE}
|
---|
19 |
|
---|
20 | # Add/modify required binaries and libraries
|
---|
21 | cd ${ISSM_DIR}/bin
|
---|
22 |
|
---|
23 | echo "Modify generic"
|
---|
24 | cat generic_static.m | sed -e "s/generic_static/generic/g" > generic.m
|
---|
25 |
|
---|
26 | echo "Moving MPICH binaries to bin/"
|
---|
27 | if [ -f ${ISSM_DIR}/externalpackages/petsc/install/bin/mpiexec ]; then
|
---|
28 | cp ${ISSM_DIR}/externalpackages/petsc/install/bin/mpiexec .
|
---|
29 | cp ${ISSM_DIR}/externalpackages/petsc/install/bin/hydra_pmi_proxy .
|
---|
30 | elif [ -f ${ISSM_DIR}/externalpackages/mpich/install/bin/mpiexec ]; then
|
---|
31 | cp ${ISSM_DIR}/externalpackages/mpich/install/bin/mpiexec .
|
---|
32 | cp ${ISSM_DIR}/externalpackages/mpich/install/bin/hydra_pmi_proxy .
|
---|
33 | else
|
---|
34 | echo "MPICH not found"
|
---|
35 | exit 1
|
---|
36 | fi
|
---|
37 |
|
---|
38 | echo "Moving libgfortran to lib/"
|
---|
39 | cp ${LIBGFORTRAN} ${LIBGFORTRAN_DIST} 2> /dev/null
|
---|
40 |
|
---|
41 | # Run tests
|
---|
42 | echo "Running tests"
|
---|
43 | cd ${ISSM_DIR}/test/NightlyRun
|
---|
44 |
|
---|
45 | # Check that MATLAB tests run
|
---|
46 | echo "Running MATLAB tests"
|
---|
47 |
|
---|
48 | rm matlab.log 2> /dev/null
|
---|
49 |
|
---|
50 | # Run MATLAB tests redirecting output to logfile and suppressing output to console
|
---|
51 | ${MATLAB_PATH}/bin/matlab -nojvm -nosplash -r "try, addpath ${ISSM_DIR}/bin ${ISSM_DIR}/lib; runme(${MATLAB_NROPTIONS}); exit; catch me,fprintf('%s',getReport(me)); exit; end" -logfile matlab.log &> /dev/null
|
---|
52 |
|
---|
53 | # Check that MATLAB did not exit in error
|
---|
54 | matlabExitCode=`echo $?`
|
---|
55 | matlabExitedInError=`grep -E "Activation cannot proceed|license" matlab.log | wc -l`
|
---|
56 |
|
---|
57 | if [[ ${matlabExitCode} -ne 0 || ${matlabExitedInError} -ne 0 ]]; then
|
---|
58 | echo "----------MATLAB exited in error!----------"
|
---|
59 | cat matlab.log
|
---|
60 | echo "-----------End of matlab.log-----------"
|
---|
61 |
|
---|
62 | # Clean up execution directory
|
---|
63 | rm -rf ${ISSM_DIR}/execution/*
|
---|
64 |
|
---|
65 | exit 1
|
---|
66 | fi
|
---|
67 |
|
---|
68 | # Check that all MATLAB tests passed
|
---|
69 | numMatlabTestsFailed=`cat matlab.log | grep -c -e "FAILED|ERROR"`
|
---|
70 |
|
---|
71 | if [[ ${numMatlabTestsFailed} -ne 0 ]]; then
|
---|
72 | echo "One or more MATLAB tests FAILED"
|
---|
73 | exit 1;
|
---|
74 | else
|
---|
75 | echo "All MATLAB tests PASSED"
|
---|
76 | fi
|
---|
77 |
|
---|
78 | # Create tarball
|
---|
79 | cd ${ISSM_DIR}
|
---|
80 | rm -f ${TARBALL}
|
---|
81 | svn cleanup --remove-ignored --remove-unversioned test # Clean up test directory (before copying to package)
|
---|
82 | echo "Copying assets to package: ${PACKAGE}"
|
---|
83 | cp -rf bin examples lib scripts test ${PACKAGE}/
|
---|
84 | echo "Cleaning up unneeded/unwanted files"
|
---|
85 | rm -f ${PACKAGE}/bin/generic_static.* # Remove static versions of generic cluster classes
|
---|
86 | rm -f ${PACKAGE}/lib/*.a # Remove static libraries from package
|
---|
87 | rm -f ${PACKAGE}/lib/*.la # Remove libtool libraries from package
|
---|
88 | echo "Creating tarball: ${TARBALL_NAME}"
|
---|
89 | tar -czf ${TARBALL} ${PACKAGE}
|
---|
90 | ls -lah ${ISSM_DIR}/${TARBALL}
|
---|
91 |
|
---|
92 | echo "Shipping binaries to website"
|
---|
93 |
|
---|
94 | # We're using public key authentication method to upload the tarball The
|
---|
95 | # following lines check to see if the SSH Agent is running. If not, then it is
|
---|
96 | # started and relevant information is forwarded to a script.
|
---|
97 | pgrep "ssh-agent" > /dev/null
|
---|
98 | if [ $? -ne 0 ]; then
|
---|
99 | echo "SSH Agent is not running. Starting it..."
|
---|
100 | ssh-agent > ~/.ssh/agent.sh
|
---|
101 | else
|
---|
102 | echo "SSH Agent is running..."
|
---|
103 | fi
|
---|
104 |
|
---|
105 | source ~/.ssh/agent.sh
|
---|
106 | ssh-add ~/.ssh/debian_linux-vm-to-ross
|
---|
107 |
|
---|
108 | scp ${TARBALL} ross.ics.uci.edu:/var/www/html/${TARBALL}
|
---|
109 |
|
---|
110 | if [ $? -ne 0 ]; then
|
---|
111 | echo "The upload failed."
|
---|
112 | echo "Perhaps the SSH Agent was started by some other means."
|
---|
113 | echo "Try killing the agent and running again."
|
---|
114 | fi
|
---|