1 | #!/bin/bash
|
---|
2 |
|
---|
3 |
|
---|
4 | # Script to test, package, and transfer distributable to ISSM Web site.
|
---|
5 | # Corresponds with build generated by configuration in
|
---|
6 | # $ISSM_DIR/jenkins/ross-debian_linux-binaries.
|
---|
7 | #
|
---|
8 |
|
---|
9 | ## Constants
|
---|
10 | #
|
---|
11 | LIBGFORTRAN="/usr/lib/x86_64-linux-gnu/libgfortran.so.5.0.0" # Important that this is the library itself
|
---|
12 | 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
|
---|
13 | MATLAB_NROPTIONS="'exclude',[IdFromString('Dakota')]"
|
---|
14 | MATLAB_PATH="/usr/local/MATLAB/R2019b"
|
---|
15 | PACKAGE="ISSM" # Name of directory to copy distributable files to
|
---|
16 | TARBALL_NAME="issm-linux"
|
---|
17 | TARBALL="${TARBALL_NAME}.tar.gz"
|
---|
18 |
|
---|
19 | ## Environment
|
---|
20 | #
|
---|
21 | export PATH="${ISSM_DIR}/bin:$(getconf PATH)" # Ensure that we pick up binaries from 'bin' directory rather than 'externalpackages'
|
---|
22 |
|
---|
23 | # Check if MATLAB exists
|
---|
24 | if ! [ -d ${MATLAB_PATH} ]; then
|
---|
25 | echo "${MATLAB_PATH} does not point to a MATLAB installation! Please modify MATLAB_PATH variable in $(basename $0) and try again."
|
---|
26 | exit 1
|
---|
27 | fi
|
---|
28 |
|
---|
29 | # Clean up from previous packaging
|
---|
30 | echo "Cleaning up existing assets"
|
---|
31 | cd ${ISSM_DIR}
|
---|
32 | rm -rf ${PACKAGE}
|
---|
33 | mkdir ${PACKAGE}
|
---|
34 |
|
---|
35 | # Add/modify required binaries and libraries
|
---|
36 | cd ${ISSM_DIR}/bin
|
---|
37 |
|
---|
38 | echo "Modify generic"
|
---|
39 | cat generic_static.m | sed -e "s/generic_static/generic/g" > generic.m
|
---|
40 |
|
---|
41 | echo "Moving MPICH binaries to bin/"
|
---|
42 | if [ -f ${ISSM_DIR}/externalpackages/petsc/install/bin/mpiexec ]; then
|
---|
43 | cp ${ISSM_DIR}/externalpackages/petsc/install/bin/mpiexec .
|
---|
44 | cp ${ISSM_DIR}/externalpackages/petsc/install/bin/hydra_pmi_proxy .
|
---|
45 | elif [ -f ${ISSM_DIR}/externalpackages/mpich/install/bin/mpiexec ]; then
|
---|
46 | cp ${ISSM_DIR}/externalpackages/mpich/install/bin/mpiexec .
|
---|
47 | cp ${ISSM_DIR}/externalpackages/mpich/install/bin/hydra_pmi_proxy .
|
---|
48 | else
|
---|
49 | echo "MPICH not found"
|
---|
50 | exit 1
|
---|
51 | fi
|
---|
52 |
|
---|
53 | echo "Moving libgfortran to lib/"
|
---|
54 | cp ${LIBGFORTRAN} ${LIBGFORTRAN_DIST} 2> /dev/null
|
---|
55 |
|
---|
56 | # Run tests
|
---|
57 | echo "Running tests"
|
---|
58 | cd ${ISSM_DIR}/test/NightlyRun
|
---|
59 |
|
---|
60 | # Check that MATLAB tests run
|
---|
61 | echo "Running MATLAB tests"
|
---|
62 |
|
---|
63 | rm matlab.log 2> /dev/null
|
---|
64 |
|
---|
65 | # Run MATLAB tests redirecting output to logfile and suppressing output to console
|
---|
66 | ${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
|
---|
67 |
|
---|
68 | # Check that MATLAB did not exit in error
|
---|
69 | matlabExitCode=`echo $?`
|
---|
70 | matlabExitedInError=`grep -E "Activation cannot proceed|license|Error" matlab.log | wc -l`
|
---|
71 |
|
---|
72 | if [[ ${matlabExitCode} -ne 0 || ${matlabExitedInError} -ne 0 ]]; then
|
---|
73 | echo "----------MATLAB exited in error!----------"
|
---|
74 | cat matlab.log
|
---|
75 | echo "-----------End of matlab.log-----------"
|
---|
76 |
|
---|
77 | # Clean up execution directory
|
---|
78 | rm -rf ${ISSM_DIR}/execution/*
|
---|
79 |
|
---|
80 | exit 1
|
---|
81 | fi
|
---|
82 |
|
---|
83 | # Check that all MATLAB tests passed
|
---|
84 | numMatlabTestsFailed=`cat matlab.log | grep -c -e "FAILED|ERROR"`
|
---|
85 |
|
---|
86 | if [[ ${numMatlabTestsFailed} -ne 0 ]]; then
|
---|
87 | echo "One or more MATLAB tests FAILED"
|
---|
88 | exit 1
|
---|
89 | else
|
---|
90 | echo "All MATLAB tests PASSED"
|
---|
91 | fi
|
---|
92 |
|
---|
93 | # Create tarball
|
---|
94 | cd ${ISSM_DIR}
|
---|
95 | rm -f ${TARBALL}
|
---|
96 | svn cleanup --remove-ignored --remove-unversioned test # Clean up test directory (before copying to package)
|
---|
97 | echo "Copying assets to package: ${PACKAGE}"
|
---|
98 | cp -rf bin examples lib scripts test ${PACKAGE}/
|
---|
99 | echo "Cleaning up unneeded/unwanted files"
|
---|
100 | rm -f ${PACKAGE}/bin/generic_static.* # Remove static versions of generic cluster classes
|
---|
101 | rm -f ${PACKAGE}/lib/*.a # Remove static libraries from package
|
---|
102 | rm -f ${PACKAGE}/lib/*.la # Remove libtool libraries from package
|
---|
103 | rm -rf ${PACKAGE}/test/SandBox # Remove testing sandbox from package
|
---|
104 | echo "Creating tarball: ${TARBALL_NAME}"
|
---|
105 | tar -czf ${TARBALL} ${PACKAGE}
|
---|
106 | ls -lah ${ISSM_DIR}/${TARBALL}
|
---|
107 |
|
---|
108 | echo "Transferring binaries to ISSM Web site"
|
---|
109 | scp -i ~/.ssh/debian_linux-vm_to_ross ${TARBALL} jenkins@ross.ics.uci.edu:/var/www/html/${TARBALL}
|
---|
110 |
|
---|
111 | if [ $? -ne 0 ]; then
|
---|
112 | echo "FAILED: Manually check connection"
|
---|
113 | exit 1
|
---|
114 | fi
|
---|