Changeset 25744


Ignore:
Timestamp:
11/12/20 16:43:32 (4 years ago)
Author:
jdquinn
Message:

CHG: Build, packaging, and testing scripts for reconfigured macOS binaries.

Location:
issm/trunk-jpl
Files:
6 deleted
2 copied
2 moved

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/trunk-jpl/jenkins/pine_island-mac-binaries-matlab

    r25741 r25744  
    99#       should always be a one-time build.
    1010#
     11
    1112ISSM_CONFIG='\
    1213        --prefix=${ISSM_DIR} \
     
    1617        --disable-dependency-tracking \
    1718        --with-matlab-dir=${MATLAB_PATH} \
    18         --with-fortran-lib="/usr/local/Cellar/gcc/10.2.0/lib/gcc/10/libgfortran.a /usr/local/Cellar/gcc/10.2.0/lib/gcc/10/libquadmath.a /usr/local/Cellar/gcc/10.2.0/lib/gcc/10/gcc/x86_64-apple-darwin15/10.2.0/libgcc.a" \
     19        --with-fortran-lib="/usr/local/Cellar/gcc/10.2.0/lib/gcc/10/libgfortran.a /usr/local/Cellar/gcc/10.2.0/lib/gcc/10/libquadmath.a /usr/local/Cellar/gcc/10.2.0/lib/gcc/10/gcc/x86_64-apple-darwin19/10.2.0/libgcc.a" \
    1920        --with-mpi-include=${ISSM_DIR}/externalpackages/petsc/install/include \
    2021        --with-mpi-libflags="-L${ISSM_DIR}/externalpackages/petsc/install/lib -lmpi -lmpicxx -lmpifort" \
     
    2324        --with-scalapack-dir=${ISSM_DIR}/externalpackages/petsc/install \
    2425        --with-mumps-dir=${ISSM_DIR}/externalpackages/petsc/install \
     26        --with-hdf5-dir=${ISSM_DIR}/externalpackages/petsc/install \
    2527        --with-petsc-dir=${ISSM_DIR}/externalpackages/petsc/install \
     28        --with-gsl-dir=${ISSM_DIR}/externalpackages/gsl/install \
     29        --with-boost-dir=${ISSM_DIR}/externalpackages/boost/install \
     30        --with-dakota-dir=${ISSM_DIR}/externalpackages/dakota/install \
    2631        --with-triangle-dir=${ISSM_DIR}/externalpackages/triangle/install \
    2732        --with-chaco-dir=${ISSM_DIR}/externalpackages/chaco/install \
     
    4348        autotools       install.sh
    4449        cmake           install.sh
    45         petsc           install-3.14-mac-static.sh
     50        petsc           install-3.12-mac-static.sh
     51        gsl                     install-static.sh
     52        boost           install-1.7-mac-static.sh
     53        dakota          install-6.2-mac-static.sh
     54        netcdf          install-4.7-mac-parallel-static.sh
     55        proj            install-6.2-static.sh
     56        gdal            install-3-netcdf-static.sh
     57        gshhg           install.sh
     58        gmt                     install-6-mac-static.sh
     59        gmsh            install-4-mac-static.sh
    4660        triangle        install-mac-static.sh
    4761        chaco           install.sh
     
    6074#               compilation
    6175#
    62 NUMCPUS_INSTALL=1
     76NUMCPUS_INSTALL=4
    6377
    6478# Number of CPUs used in the nightly runs
  • TabularUnified issm/trunk-jpl/packagers/mac/package-issm-mac-binaries-matlab.sh

    r25741 r25744  
    11#!/bin/bash
    22
    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/pine_island-mac-binaries.
    7 #
     3################################################################################
     4# To be used after running,
     5#
     6#       ${ISSM_DIR}/jenkins/jenkins.sh ${ISSM_DIR}/jenkins/pine_island-mac-binaries-matlab
     7#
     8# in the context of a Jenkins project.
     9#
     10# When no runtime errors occur, performs the following:
     11# - Checks resulting executables and libraries against test suite.
     12# - Packages and compresses executables and libraries.
     13# - Commits compressed package to SVN repository to be signed by JPL
     14#       Cybersecurity.
     15# - Retrieves signed package and transmits it to ISSM Web site for
     16#       distribution.
     17#
     18# To skip tests, run with -s/--skiptests option.
     19#
     20# Debugging:
     21# - Relies on a very tight handshake with project on remote JPL Cybersecurity
     22#       Jenkins server. Debugging may be perfomed locally by running,
     23#
     24#               packagers/mac/sign-issm-mac-binaries-matlab.sh
     25#
     26#       with Apple Developer credentials.
     27# - Removing stdout/stderr redirections to null device (> /dev/null 2>&1) can
     28#       help debug potential SVN issues.
     29#
     30# NOTE:
     31# - Assumes that 'issm-binaries-user' and 'issm-binaries-pass' are set up in
     32#       the 'Bindings' section under a 'Username and password (separated)' binding
     33#       (requires 'Credentials Binding Plugin').
     34# - For local debugging, the aformentioned credentials can be hardcoded into
     35#       the 'USERNAME' and 'PASSWORD' constants below.
     36################################################################################
     37
     38# From https://developer.apple.com/documentation/macos-release-notes/macos-catalina-10_15-release-notes,
     39#
     40#       Command line tool support for Subversion — including svn, git-svn, and
     41#       related commands — is no longer provided by Xcode. (50266910)
     42#
     43# which results in,
     44#
     45#       svn: error: The subversion command line tools are no longer provided by
     46#       Xcode.
     47#
     48# when calling svn, even when subversion is installed via Homebrew and its path
     49# is available in PATH.
     50#
     51shopt -s expand_aliases
     52alias svn='/usr/local/bin/svn'
     53
     54## Override certain other aliases
     55#
     56alias grep=$(which grep)
    857
    958## Constants
    1059#
    11 MATLAB_NROPTIONS="'exclude',[IdFromString('Dakota'),125,126,435,701,702,703]"
     60
     61MATLAB_NROPTIONS="'benchmark','all','exclude',[125,126,234,235,418,420,435,444,445,701,702,703,1101,1102,1103,1104,1105,1106,1107,1108,1109,1110,1201,1202,1203,1204,1205,1206,1207,1208,1301,1302,1303,1304,1401,1402,1601,1602,2006,2020,2021,2051,2052,2053,3001:3200,3201,3202,3300,3480,3481,4001,4002,4003]" # NOTE: Combination of test suites from basic, Dakota, and Solid Earth builds, with tests that require a restart and those that require the JVM excluded
    1262MATLAB_PATH="/Applications/MATLAB_R2018a.app"
    13 PACKAGE="ISSM" # Name of directory to copy distributable files to
    14 TARBALL_NAME="issm-mac"
    15 TARBALL="${TARBALL_NAME}.tar.gz"
     63NOTARIZATION_LOGFILE="notarization.log"
     64PASSWORD=$env:issm-binaries-pass
     65PKG="ISSM-macOS-MATLAB" # Name of directory to copy distributable files to
     66SIGNED_REPO_COPY="./signed"
     67SIGNED_REPO_URL="https://issm.ess.uci.edu/svn/issm-binaries/mac/matlab/signed"
     68SIGNING_CHECK_PERIOD=60 # seconds
     69SIGNING_LOCK_FILE="signing.lock"
     70UNSIGNED_REPO_COPY="./unsigned"
     71UNSIGNED_REPO_URL="https://issm.ess.uci.edu/svn/issm-binaries/mac/matlab/unsigned"
     72USERNAME=$env:issm-binaries-user
     73
     74COMPRESSED_PKG="${PKG}.zip"
    1675
    1776## Environment
     
    1978export PATH="${ISSM_DIR}/bin:$(getconf PATH)" # Ensure that we pick up binaries from 'bin' directory rather than 'externalpackages'
    2079
    21 # Check if MATLAB exists
    22 if ! [ -d ${MATLAB_PATH} ]; then
    23         echo "${MATLAB_PATH} does not point to a MATLAB installation! Please modify MATLAB_PATH variable in $(basename $0) and try again."
     80## Parse options
     81#
     82skip_tests=0
     83transfer_only=0
     84while [[ "$#" -gt 0 ]]; do
     85    case $1 in
     86        -s|--skiptests) skip_tests=1; shift ;;
     87        -t|--transferonly) transfer_only=1; shift ;;
     88        *) echo "Unknown parameter passed: $1"; exit 1 ;;
     89    esac
     90    shift
     91done
     92
     93if [ ${transfer_only} -eq 0 ]; then
     94        # Check if MATLAB exists
     95        if ! [ -d ${MATLAB_PATH} ]; then
     96                echo "${MATLAB_PATH} does not point to a MATLAB installation! Please modify MATLAB_PATH variable in $(basename $0) and try again."
     97                exit 1
     98        fi
     99
     100        # Clean up from previous packaging (not necessary for single builds on Jenkins,
     101        # but useful when testing packaging locally)
     102        echo "Cleaning up existing assets"
     103        cd ${ISSM_DIR}
     104        rm -rf ${PKG} ${COMPRESSED_PKG} ${SIGNED_REPO_COPY} ${UNSIGNED_REPO_COPY}
     105        mkdir ${PKG}
     106
     107        # Check out copy of SVN repository for signed macOS packages
     108        #
     109        # NOTE: Get empty copy because we do not want to have to check out package from
     110        #               previous signing.
     111        #
     112        echo "Checking out copy of repository for signed packages"
     113        svn co \
     114                --username ${USERNAME} \
     115                --password ${PASSWORD} \
     116                --depth empty \
     117                ${SIGNED_REPO_URL} \
     118                ${SIGNED_REPO_COPY} > /dev/null 2>&1
     119
     120        # If lock file exists, a signing build is still in process by JPL Cybersecurity
     121        svn up ${SIGNED_REPO_COPY}/${SIGNING_LOCK_FILE} > /dev/null 2>&1
     122        if [[ -f ${SIGNED_REPO_COPY}/${SIGNING_LOCK_FILE} ]]; then
     123                echo "Previous signing job still in process by JPL Cybersecurity. Please try again later."
     124                exit 1
     125        fi
     126
     127        # Add required binaries and libraries to package and modify them where needed
     128        cd ${ISSM_DIR}/bin
     129
     130        echo "Modify generic"
     131        cat generic_static.m | sed -e "s/generic_static/generic/g" > generic.m
     132
     133        echo "Moving MPICH binaries to bin/"
     134        if [ -f ${ISSM_DIR}/externalpackages/petsc/install/bin/mpiexec ]; then
     135                cp ${ISSM_DIR}/externalpackages/petsc/install/bin/mpiexec .
     136                cp ${ISSM_DIR}/externalpackages/petsc/install/bin/hydra_pmi_proxy .
     137        elif [ -f ${ISSM_DIR}/externalpackages/mpich/install/bin/mpiexec ]; then
     138                cp ${ISSM_DIR}/externalpackages/mpich/install/bin/mpiexec .
     139                cp ${ISSM_DIR}/externalpackages/mpich/install/bin/hydra_pmi_proxy .
     140        else
     141                echo "MPICH not found"
     142                exit 1
     143        fi
     144
     145        echo "Moving GDAL binaries to bin/"
     146        if [ -f ${ISSM_DIR}/externalpackages/gdal/install/bin/gdal-config ]; then
     147                cp ${ISSM_DIR}/externalpackages/gdal/install/bin/gdalsrsinfo .
     148                cp ${ISSM_DIR}/externalpackages/gdal/install/bin/gdaltransform .
     149        else
     150                echo "GDAL not found"
     151                exit 1
     152        fi
     153
     154        echo "Moving GMT binaries to bin/"
     155        if [ -f ${ISSM_DIR}/externalpackages/gmt/install/bin/gmt-config ]; then
     156                cp ${ISSM_DIR}/externalpackages/gmt/install/bin/gmt .
     157                cp ${ISSM_DIR}/externalpackages/gmt/install/bin/gmtselect .
     158        else
     159                echo "GMT not found"
     160                exit 1
     161        fi
     162
     163        echo "Moving Gmsh binaries to bin/"
     164        if [ -f ${ISSM_DIR}/externalpackages/gmsh/install/bin/gmsh ]; then
     165                cp ${ISSM_DIR}/externalpackages/gmsh/install/bin/gmsh .
     166        else
     167                echo "Gmsh not found"
     168                exit 1
     169        fi
     170
     171        # Run tests
     172        if [ ${skip_tests} -eq 0 ]; then
     173                echo "Running tests"
     174                cd ${ISSM_DIR}/test/NightlyRun
     175                rm matlab.log 2> /dev/null
     176
     177                # Run tests, redirecting output to logfile and suppressing output to console
     178                ${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
     179
     180                # Check that MATLAB did not exit in error
     181                matlabExitCode=`echo $?`
     182                matlabExitedInError=`grep -E "Activation cannot proceed|license|Error" matlab.log | wc -l`
     183
     184                if [[ ${matlabExitCode} -ne 0 || ${matlabExitedInError} -ne 0 ]]; then
     185                        echo "----------MATLAB exited in error!----------"
     186                        cat matlab.log
     187                        echo "-----------End of matlab.log-----------"
     188
     189                        # Clean up execution directory
     190                        rm -rf ${ISSM_DIR}/execution/*
     191
     192                        exit 1
     193                fi
     194
     195                # Check that all tests passed
     196                numTestsFailed=`cat matlab.log | grep -c -e "FAILED|ERROR"`
     197
     198                if [[ ${numTestsFailed} -ne 0 ]]; then
     199                        echo "One or more tests FAILED"
     200                        exit 1
     201                else
     202                        echo "All tests PASSED"
     203                fi
     204        else
     205                echo "Skipping tests"
     206        fi
     207
     208        # Create package
     209        cd ${ISSM_DIR}
     210        svn cleanup --remove-ignored --remove-unversioned test # Clean up test directory (before copying to package)
     211        echo "Copying assets to package: ${PKG}"
     212        cp -rf bin examples lib scripts test ${PKG}/
     213        echo "Cleaning up unneeded/unwanted files"
     214        rm -f ${PKG}/bin/generic_static.* # Remove static versions of generic cluster classes
     215        rm -f ${PKG}/lib/*.a # Remove static libraries from package
     216        rm -f ${PKG}/lib/*.la # Remove libtool libraries from package
     217        rm -rf ${PKG}/test/SandBox # Remove testing sandbox from package
     218
     219        # Compress package
     220        echo "Compressing package"
     221        ditto -ck --sequesterRsrc --keepParent ${PKG} ${COMPRESSED_PKG}
     222
     223        # Commit lock file to repository for signed packages
     224        echo "Committing lock file to repository for signed packages"
     225        touch ${SIGNED_REPO_COPY}/${SIGNING_LOCK_FILE}
     226        svn add ${SIGNED_REPO_COPY}/${SIGNING_LOCK_FILE} > /dev/null 2>&1
     227        svn commit --message "ADD: New lock file" ${SIGNED_REPO_COPY} > /dev/null 2>&1
     228
     229        # Save current working copy revision number
     230        svn up ${SIGNED_REPO_COPY} > /dev/null 2>&1
     231        CURRENT_REV=$(svn info --show-item last-changed-revision ${SIGNED_REPO_COPY})
     232
     233        # Check out copy of SVN repository for unsigned macOS packages
     234        echo "Checking out copy of repository for unsigned packages"
     235        svn co \
     236                --username ${USERNAME} \
     237                --password ${PASSWORD} \
     238                ${UNSIGNED_REPO_URL} \
     239                ${UNSIGNED_REPO_COPY} > /dev/null 2>&1
     240
     241        # Commit new compressed package to repository for unsigned binaries
     242        #
     243        # NOTE: This will not work if, for any reason, the checksum on the compressed
     244        #               package is unchanged.
     245        #
     246        echo "Committing package to repository for unsigned packages"
     247        cp ${COMPRESSED_PKG} ${UNSIGNED_REPO_COPY}
     248        svn add ${UNSIGNED_REPO_COPY}/${COMPRESSED_PKG} > /dev/null 2>&1
     249        svn commit --message "CHG: New unsigned package" ${UNSIGNED_REPO_COPY} > /dev/null 2>&1
     250
     251        # Check status of signing
     252        echo "Checking progress of signing..."
     253        IN_PROCESS=1
     254        SUCCESS=0
     255
     256        while [ ${IN_PROCESS} -eq 1 ]; do
     257                echo "...in progress still; checking again in ${SIGNING_CHECK_PERIOD} seconds."
     258                sleep ${SIGNING_CHECK_PERIOD}
     259                svn up ${SIGNED_REPO_COPY} > /dev/null 2>&1
     260                NEW_REV=$(svn info --show-item last-changed-revision ${SIGNED_REPO_COPY})
     261
     262                if [ ${NEW_REV} -ne ${CURRENT_REV} ]; then
     263                        IN_PROCESS=0
     264
     265                        svn up ${SIGNED_REPO_COPY}/${NOTARIZATION_LOGFILE} > /dev/null 2>&1
     266                        svn up ${SIGNED_REPO_COPY}/${COMPRESSED_PKG} > /dev/null 2>&1
     267
     268                        # No error, so check status
     269                        STATUS=$(grep 'Status:' ${SIGNED_REPO_COPY}/${NOTARIZATION_LOGFILE} | sed -e 's/[[:space:]]*Status: //')
     270                        if [[ "${STATUS}" == "success" ]]; then
     271                                echo 'Notarization successful!'
     272
     273                                # Set flag indicating notarization was successful
     274                                SUCCESS=1
     275                        else
     276                                echo 'Notarization failed!'
     277                        fi
     278                fi
     279        done
     280else # transfer_only == 1
     281        # Assume that previous build resulted in successful signing of package but
     282        # that transfer to ISSM Web site failed and user built this project again
     283        # with -t/--transferonly option.
     284        SUCCESS=1
     285fi
     286
     287# Handle result of signing
     288if [ ${SUCCESS} -eq 1 ]; then
     289        # Transfer signed package to ISSM Web site
     290        echo 'Transferring signed package to ISSM Web site'
     291        scp -i ~/.ssh/pine_island_to_ross ${SIGNED_REPO_COPY}/${COMPRESSED_PKG} jenkins@ross.ics.uci.edu:/var/www/html/${COMPRESSED_PKG}
     292
     293        if [ $? -ne 0 ]; then
     294                echo "Transfer failed! Verify connection then build this project again (with -t/--transferonly option to skip testing and signing)."
     295                exit 1
     296        fi
     297else
     298        echo '----------------------- Contents of notarization logfile -----------------------'
     299        cat ${SIGNED_REPO_COPY}/${NOTARIZATION_LOGFILE}
     300        echo '--------------------------------------------------------------------------------'
     301
    24302        exit 1
    25303fi
    26 
    27 # Clean up from previous packaging
    28 echo "Cleaning up existing assets"
    29 cd ${ISSM_DIR}
    30 rm -rf ${PACKAGE}
    31 mkdir ${PACKAGE}
    32 
    33 # Add/modify required binaries and libraries
    34 cd ${ISSM_DIR}/bin
    35 
    36 echo "Modify generic"
    37 cat generic_static.m | sed -e "s/generic_static/generic/g" > generic.m
    38 
    39 echo "Moving MPICH binaries to bin/"
    40 if [ -f ${ISSM_DIR}/externalpackages/petsc/install/bin/mpiexec ]; then
    41         cp ${ISSM_DIR}/externalpackages/petsc/install/bin/mpiexec .
    42         cp ${ISSM_DIR}/externalpackages/petsc/install/bin/hydra_pmi_proxy .
    43 elif [ -f ${ISSM_DIR}/externalpackages/mpich/install/bin/mpiexec ]; then
    44         cp ${ISSM_DIR}/externalpackages/mpich/install/bin/mpiexec .
    45         cp ${ISSM_DIR}/externalpackages/mpich/install/bin/hydra_pmi_proxy .
    46 else
    47         echo "MPICH not found"
    48         exit 1
    49 fi
    50 
    51 # Run tests
    52 echo "Running tests"
    53 cd ${ISSM_DIR}/test/NightlyRun
    54 
    55 # Check that MATLAB tests run
    56 echo "Running MATLAB tests"
    57 
    58 rm matlab.log 2> /dev/null
    59 
    60 # Run MATLAB tests redirecting output to logfile and suppressing output to console
    61 ${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
    62 
    63 # Check that MATLAB did not exit in error
    64 matlabExitCode=`echo $?`
    65 matlabExitedInError=`grep -E "Activation cannot proceed|license|Error" matlab.log | wc -l`
    66 
    67 if [[ ${matlabExitCode} -ne 0 || ${matlabExitedInError} -ne 0 ]]; then
    68         echo "----------MATLAB exited in error!----------"
    69         cat matlab.log
    70         echo "-----------End of matlab.log-----------"
    71 
    72         # Clean up execution directory
    73         rm -rf ${ISSM_DIR}/execution/*
    74 
    75         exit 1
    76 fi
    77 
    78 # Check that all MATLAB tests passed
    79 numMatlabTestsFailed=`cat matlab.log | grep -c -e "FAILED|ERROR"`
    80 
    81 if [[ ${numMatlabTestsFailed} -ne 0 ]]; then
    82         echo "One or more MATLAB tests FAILED"
    83         exit 1
    84 else
    85         echo "All MATLAB tests PASSED"
    86 fi
    87 
    88 # Create tarball
    89 cd ${ISSM_DIR}
    90 rm -f ${TARBALL}
    91 svn cleanup --remove-ignored --remove-unversioned test # Clean up test directory (before copying to package)
    92 echo "Copying assets to package: ${PACKAGE}"
    93 cp -rf bin examples lib scripts test ${PACKAGE}/
    94 echo "Cleaning up unneeded/unwanted files"
    95 rm -f ${PACKAGE}/bin/generic_static.* # Remove static versions of generic cluster classes
    96 rm -f ${PACKAGE}/lib/*.a # Remove static libraries from package (we only need MEX-files)
    97 rm -f ${PACKAGE}/lib/*.la # Remove libtool libraries from package
    98 rm -rf ${PACKAGE}/test/SandBox # Remove testing sandbox from package
    99 echo "Creating tarball: ${TARBALL_NAME}"
    100 tar -czf ${TARBALL} ${PACKAGE}
    101 ls -lah ${ISSM_DIR}/${TARBALL}
    102 
    103 echo "Transferring binaries to ISSM Web site"
    104 scp -i ~/.ssh/pine_island_to_ross ${TARBALL} jenkins@ross.ics.uci.edu:/var/www/html/${TARBALL}
    105 
    106 if [ $? -ne 0 ]; then
    107         echo "FAILED: Manually check connection"
    108         exit 1
    109 fi
  • TabularUnified issm/trunk-jpl/packagers/mac/sign-issm-mac-binaries-matlab.sh

    r25741 r25744  
    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/pine_island-mac-binaries.
    7 #
    8 
    9 ## Constants
    10 #
    11 MATLAB_NROPTIONS="'exclude',[IdFromString('Dakota'),125,126,435,701,702,703]"
    12 MATLAB_PATH="/Applications/MATLAB_R2018a.app"
    13 PACKAGE="ISSM" # Name of directory to copy distributable files to
    14 TARBALL_NAME="issm-mac"
    15 TARBALL="${TARBALL_NAME}.tar.gz"
    16 
    17 ## Environment
    18 #
    19 export PATH="${ISSM_DIR}/bin:$(getconf PATH)" # Ensure that we pick up binaries from 'bin' directory rather than 'externalpackages'
    20 
    21 # Check if MATLAB exists
    22 if ! [ -d ${MATLAB_PATH} ]; then
    23         echo "${MATLAB_PATH} does not point to a MATLAB installation! Please modify MATLAB_PATH variable in $(basename $0) and try again."
     1# From https://developer.apple.com/documentation/macos-release-notes/macos-catalina-10_15-release-notes,
     2#
     3#       Command line tool support for Subversion — including svn, git-svn, and
     4#       related commands — is no longer provided by Xcode. (50266910)
     5#
     6# which results in,
     7#
     8#       svn: error: The subversion command line tools are no longer provided by
     9#       Xcode.
     10#
     11# when calling svn, even when subversion is installed via Homebrew and its path
     12# is available in PATH.
     13#
     14shopt -s expand_aliases
     15alias svn='/usr/local/bin/svn'
     16
     17## Override certain other aliases
     18#
     19alias cp=$(which cp)
     20alias grep=$(which grep)
     21
     22AD_IDENTITY="**********"
     23AD_USERNAME="**********"
     24ALTOOL_PASSWORD="@keychain:**********"
     25ASC_PROVIDER="**********"
     26NOTARIZATION_CHECK_ATTEMPTS=60
     27NOTARIZATION_CHECK_PERIOD=60
     28NOTARIZATION_LOGFILE="notarization.log"
     29NOTARIZATION_LOGFILE_PATH="."
     30PKG="ISSM-macOS-MATLAB"
     31PRIMARY_BUNDLE_ID="**********.issm.matlab"
     32SIGNED_REPO_COPY="./signed"
     33SIGNED_REPO_URL="https://issm.ess.uci.edu/svn/issm-binaries/mac/matlab/signed"
     34SIGNING_LOCK_FILE="signing.lock"
     35SUCCESS_LOGFILE="${SIGNED_REPO_COPY}/success.log"
     36UNSIGNED_REPO_COPY="./unsigned"
     37UNSIGNED_REPO_URL="https://issm.ess.uci.edu/svn/issm-binaries/mac/matlab/unsigned"
     38
     39COMPRESSED_PKG="${PKG}.zip"
     40
     41# Clean up from previous packaging (not necessary for single builds on Jenkins,
     42# but useful when testing packaging locally)
     43echo 'Cleaning up existing assets'
     44rm -rf ${PKG} ${COMPRESSED_PKG} ${NOTARIZATION_LOGFILE_PATH}/${NOTARIZATION_LOGFILE} ${SIGNED_REPO_COPY} ${UNSIGNED_REPO_COPY}
     45mkdir ${PKG}
     46
     47# Check out copy of SVN repository for unsigned macOS packages
     48echo 'Checking out copy of SVN respository for unsigned packages'
     49svn co \
     50        --username ${USERNAME} \
     51        --password ${PASSWORD} \
     52        ${UNSIGNED_REPO_URL} \
     53        ${UNSIGNED_REPO_COPY}
     54
     55# Uncompress package
     56echo 'Uncompressing package'
     57ditto -xk ${UNSIGNED_REPO_COPY}/${COMPRESSED_PKG} .
     58
     59# Clear extended attributes on all files
     60xattr -cr ${PKG}
     61
     62# Build list of executables
     63EXECUTABLES=$(\
     64        echo ${PKG}/bin/mpiexec; \
     65        echo ${PKG}/bin/hydra_pmi_proxy; \
     66        echo ${PKG}/bin/gdalsrsinfo; \
     67        echo ${PKG}/bin/gdaltransform; \
     68        echo ${PKG}/bin/gmt; \
     69        echo ${PKG}/bin/gmtselect; \
     70        echo ${PKG}/bin/gmsh; \
     71        find ${PKG} -type f -name *.exe; \
     72        find ${PKG} -type f -name *.mexmaci64; \
     73)
     74
     75# Sign all executables in package
     76echo 'Signing all executables in package'
     77codesign -s ${AD_IDENTITY} --timestamp --options=runtime ${EXECUTABLES}
     78
     79# NOTE: Skipping signature validation because this is not a true package nor app
     80
     81# Compress signed package
     82echo 'Compressing signed package'
     83ditto -ck --sequesterRsrc --keepParent ${PKG} ${COMPRESSED_PKG}
     84
     85# Submit compressed package for notarization
     86echo 'Submitting signed package for notarization'
     87xcrun altool --notarize-app --primary-bundle-id ${PRIMARY_BUNDLE_ID} --username ${AD_USERNAME} --password ${ALTOOL_PASSWORD} --asc-provider ${ASC_PROVIDER} --file ${COMPRESSED_PKG} &> ${NOTARIZATION_LOGFILE_PATH}/${NOTARIZATION_LOGFILE}
     88
     89# Sleep until notarization request response is received
     90echo 'Waiting for notarizaion request response'
     91while [[ ! -f ${NOTARIZATION_LOGFILE_PATH}/${NOTARIZATION_LOGFILE} || ! -z $(find ${NOTARIZATION_LOGFILE_PATH} -empty -name ${NOTARIZATION_LOGFILE}) ]]; do
     92        sleep 30
     93done
     94
     95echo 'Notarizaion request response received'
     96
     97# Check if UUID exists in response
     98HAS_UUID=$(grep 'RequestUUID = ' ${NOTARIZATION_LOGFILE_PATH}/${NOTARIZATION_LOGFILE}) # NOTE: Checking for "RequestUUID = " because "RequestUUID" shows up in some error messages
     99if [[ -z "${HAS_UUID}" ]]; then
     100        echo 'Notarization failed!'
     101        echo '----------------------- Contents of notarization logfile -----------------------'
     102        cat ${NOTARIZATION_LOGFILE_PATH}/${NOTARIZATION_LOGFILE}
     103        echo '--------------------------------------------------------------------------------'
     104
     105        # Clean up
     106        rm -rf ${PKG} ${COMPRESSED_PKG}
     107
    24108        exit 1
    25109fi
    26110
    27 # Clean up from previous packaging
    28 echo "Cleaning up existing assets"
    29 cd ${ISSM_DIR}
    30 rm -rf ${PACKAGE}
    31 mkdir ${PACKAGE}
    32 
    33 # Add/modify required binaries and libraries
    34 cd ${ISSM_DIR}/bin
    35 
    36 echo "Modify generic"
    37 cat generic_static.m | sed -e "s/generic_static/generic/g" > generic.m
    38 
    39 echo "Moving MPICH binaries to bin/"
    40 if [ -f ${ISSM_DIR}/externalpackages/petsc/install/bin/mpiexec ]; then
    41         cp ${ISSM_DIR}/externalpackages/petsc/install/bin/mpiexec .
    42         cp ${ISSM_DIR}/externalpackages/petsc/install/bin/hydra_pmi_proxy .
    43 elif [ -f ${ISSM_DIR}/externalpackages/mpich/install/bin/mpiexec ]; then
    44         cp ${ISSM_DIR}/externalpackages/mpich/install/bin/mpiexec .
    45         cp ${ISSM_DIR}/externalpackages/mpich/install/bin/hydra_pmi_proxy .
     111# Get UUID from notarization request response
     112UUID=$(echo ${HAS_UUID} | sed 's/[[:space:]]*RequestUUID = //')
     113echo "UUID: ${UUID}"
     114
     115# Check notarization status
     116#
     117# NOTE: Currently, this checks if notarization was successful, but we are not
     118#               able to staple notarization as this is not a true package nor app and,
     119#               at the very least, MATLAB Mex files cannot be stapled. As such, clients
     120#               will not be able to clear Gatekeeper if they are offline.
     121#
     122echo 'Checking notarization status'
     123SUCCESS=0
     124for ATTEMPT in $(seq 1 ${NOTARIZATION_CHECK_ATTEMPTS}); do
     125        echo "    Attempt #${ATTEMPT}..."
     126        xcrun altool --notarization-info ${UUID} --username ${AD_USERNAME} --password ${ALTOOL_PASSWORD} &> ${NOTARIZATION_LOGFILE_PATH}/${NOTARIZATION_LOGFILE}
     127        if [[ -f ${NOTARIZATION_LOGFILE_PATH}/${NOTARIZATION_LOGFILE} && -z $(find ${NOTARIZATION_LOGFILE_PATH} -empty -name ${NOTARIZATION_LOGFILE}) ]]; then
     128
     129                # First, check if there is an error
     130                ERROR_CHECK=$(grep 'Error' ${NOTARIZATION_LOGFILE_PATH}/${NOTARIZATION_LOGFILE})
     131                if [[ ! -z "${ERROR_CHECK}" ]]; then
     132                        break
     133                fi
     134
     135                # No error, so check status
     136                STATUS=$(grep 'Status:' ${NOTARIZATION_LOGFILE_PATH}/${NOTARIZATION_LOGFILE} | sed -e 's/[[:space:]]*Status: //')
     137                if [[ "${STATUS}" == "success" ]]; then
     138                        # Staple notarization to all elements of package that were previously signed
     139                        #xcrun stapler staple ${EXECUTABLES} # NOTE: Fails with "Stapler is incapable of working with MATLAB Mex files."
     140
     141                        # Validate stapling of notarization
     142                        #xcrun stapler validation ${EXECUTABLES} # NOTE: Skipping notarization stapling validation because this is not a true package nor app
     143
     144                        # Compress signed and notarized package
     145                        ditto -ck --sequesterRsrc --keepParent ${PKG} ${COMPRESSED_PKG}
     146
     147                        # Set flag indicating notarization was successful
     148                        SUCCESS=1
     149
     150                        break
     151                elif [[ "${STATUS}" == "in progress" ]]; then
     152                        echo "    ...in progress still; checking again in ${NOTARIZATION_CHECK_PERIOD} seconds."
     153                        sleep ${NOTARIZATION_CHECK_PERIOD}
     154                elif [[ "${STATUS}" == "invalid" ]]; then
     155                        break
     156                fi
     157        else
     158                if [ $ATTEMPT -lt ${NOTARIZATION_CHECK_ATTEMPTS} ]; then
     159                        echo "    ...not ready yet; checking again in ${NOTARIZATION_CHECK_PERIOD} seconds."
     160                        sleep ${NOTARIZATION_CHECK_PERIOD}
     161                else
     162                        echo '    ...maximum attempts reached, but no response, or something else went wrong.'
     163                        echo '    If contents of notarization status check logfile appear to be valid, increase NOTARIZATION_CHECK_ATTEMPTS and run again.'
     164                        break
     165                fi
     166        fi
     167done
     168
     169# Check out copy of SVN repository for signed macOS packages
     170echo 'Checking out copy of SVN respository for signed packages'
     171svn co \
     172        --username ${USERNAME} \
     173        --password ${PASSWORD} \
     174        ${SIGNED_REPO_URL} \
     175        ${SIGNED_REPO_COPY}
     176
     177# Copy notarization file to repository for signed binaries
     178cp ${NOTARIZATION_LOGFILE_PATH}/${NOTARIZATION_LOGFILE} ${SIGNED_REPO_COPY}
     179svn add ${SIGNED_REPO_COPY}/${NOTARIZATION_LOGFILE} > /dev/null 2>&1
     180
     181# Remove lock file from repository for signed binaries
     182svn delete ${SIGNED_REPO_COPY}/${SIGNING_LOCK_FILE} > /dev/null 2>&1
     183
     184if [ ${SUCCESS} -eq 1 ]; then
     185        echo 'Notarization successful!'
     186
     187        # Copy signed package to repository for signed binaries
     188        cp ${COMPRESSED_PKG} ${SIGNED_REPO_COPY}
     189        svn add ${SIGNED_REPO_COPY}/${COMPRESSED_PKG} > /dev/null 2>&1
     190
     191        # Commit changes
     192        svn commit --message "CHG: New signed package (success)" ${SIGNED_REPO_COPY}
    46193else
    47         echo "MPICH not found"
     194        echo 'Notarization failed!'
     195        echo '----------------------- Contents of notarization logfile -----------------------'
     196        cat ${NOTARIZATION_LOGFILE_PATH}/${NOTARIZATION_LOGFILE}
     197        echo '--------------------------------------------------------------------------------'
     198
     199        # Commit changes
     200        svn commit --message "CHG: New signed package (failure)" ${SIGNED_REPO_COPY}
     201
    48202        exit 1
    49203fi
    50 
    51 # Run tests
    52 echo "Running tests"
    53 cd ${ISSM_DIR}/test/NightlyRun
    54 
    55 # Check that MATLAB tests run
    56 echo "Running MATLAB tests"
    57 
    58 rm matlab.log 2> /dev/null
    59 
    60 # Run MATLAB tests redirecting output to logfile and suppressing output to console
    61 ${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
    62 
    63 # Check that MATLAB did not exit in error
    64 matlabExitCode=`echo $?`
    65 matlabExitedInError=`grep -E "Activation cannot proceed|license|Error" matlab.log | wc -l`
    66 
    67 if [[ ${matlabExitCode} -ne 0 || ${matlabExitedInError} -ne 0 ]]; then
    68         echo "----------MATLAB exited in error!----------"
    69         cat matlab.log
    70         echo "-----------End of matlab.log-----------"
    71 
    72         # Clean up execution directory
    73         rm -rf ${ISSM_DIR}/execution/*
    74 
    75         exit 1
    76 fi
    77 
    78 # Check that all MATLAB tests passed
    79 numMatlabTestsFailed=`cat matlab.log | grep -c -e "FAILED|ERROR"`
    80 
    81 if [[ ${numMatlabTestsFailed} -ne 0 ]]; then
    82         echo "One or more MATLAB tests FAILED"
    83         exit 1
    84 else
    85         echo "All MATLAB tests PASSED"
    86 fi
    87 
    88 # Create tarball
    89 cd ${ISSM_DIR}
    90 rm -f ${TARBALL}
    91 svn cleanup --remove-ignored --remove-unversioned test # Clean up test directory (before copying to package)
    92 echo "Copying assets to package: ${PACKAGE}"
    93 cp -rf bin examples lib scripts test ${PACKAGE}/
    94 echo "Cleaning up unneeded/unwanted files"
    95 rm -f ${PACKAGE}/bin/generic_static.* # Remove static versions of generic cluster classes
    96 rm -f ${PACKAGE}/lib/*.a # Remove static libraries from package (we only need MEX-files)
    97 rm -f ${PACKAGE}/lib/*.la # Remove libtool libraries from package
    98 rm -rf ${PACKAGE}/test/SandBox # Remove testing sandbox from package
    99 echo "Creating tarball: ${TARBALL_NAME}"
    100 tar -czf ${TARBALL} ${PACKAGE}
    101 ls -lah ${ISSM_DIR}/${TARBALL}
    102 
    103 echo "Transferring binaries to ISSM Web site"
    104 scp -i ~/.ssh/pine_island_to_ross ${TARBALL} jenkins@ross.ics.uci.edu:/var/www/html/${TARBALL}
    105 
    106 if [ $? -ne 0 ]; then
    107         echo "FAILED: Manually check connection"
    108         exit 1
    109 fi
  • TabularUnified issm/trunk-jpl/packagers/mac/test-issm-mac-binaries-matlab.sh

    r25741 r25744  
    11#!/bin/bash
    22
    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/pine_island-mac-binaries.
     3# This script is intended to test ISSM macOS MATLAB binaries downloaded to a
     4# user-end machine.
     5#
     6# NOTE: Tarball must already exist in INSTALL_DIR
    77#
    88
    9 ## Constants
    10 #
    11 MATLAB_NROPTIONS="'exclude',[IdFromString('Dakota'),125,126,435,701,702,703]"
     9INSTALL_DIR=~/Downloads
     10MATLAB_NROPTIONS="'benchmark','all','exclude',[125,126,234,235,418,420,435,444,445,701,702,703,1101,1102,1103,1104,1105,1106,1107,1108,1109,1110,1201,1202,1203,1204,1205,1206,1207,1208,1301,1302,1303,1304,1401,1402,1601,1602,2006,2020,2021,2051,2052,2053,3001:3200,3201,3202,3300,3480,3481,4001,4002,4003]" # NOTE: Combination of test suites from basic, Dakota, and Solid Earth builds, with tests that require a restart and those that require the JVM excluded
    1211MATLAB_PATH="/Applications/MATLAB_R2018a.app"
    13 PACKAGE="ISSM" # Name of directory to copy distributable files to
    14 TARBALL_NAME="issm-mac"
    15 TARBALL="${TARBALL_NAME}.tar.gz"
     12PKG="ISSM-macOS-MATLAB"
    1613
    17 ## Environment
    18 #
    19 export PATH="${ISSM_DIR}/bin:$(getconf PATH)" # Ensure that we pick up binaries from 'bin' directory rather than 'externalpackages'
     14COMPRESSED_PKG="${PKG}.zip"
    2015
    21 # Check if MATLAB exists
    22 if ! [ -d ${MATLAB_PATH} ]; then
    23         echo "${MATLAB_PATH} does not point to a MATLAB installation! Please modify MATLAB_PATH variable in $(basename $0) and try again."
    24         exit 1
    25 fi
     16export ISSM_DIR="${INSTALL_DIR}/${PKG}"
     17export PATH="${PATH}:${ISSM_DIR}/bin:${ISSM_DIR}/scripts"
    2618
    27 # Clean up from previous packaging
    28 echo "Cleaning up existing assets"
    29 cd ${ISSM_DIR}
    30 rm -rf ${PACKAGE}
    31 mkdir ${PACKAGE}
    32 
    33 # Add/modify required binaries and libraries
    34 cd ${ISSM_DIR}/bin
    35 
    36 echo "Modify generic"
    37 cat generic_static.m | sed -e "s/generic_static/generic/g" > generic.m
    38 
    39 echo "Moving MPICH binaries to bin/"
    40 if [ -f ${ISSM_DIR}/externalpackages/petsc/install/bin/mpiexec ]; then
    41         cp ${ISSM_DIR}/externalpackages/petsc/install/bin/mpiexec .
    42         cp ${ISSM_DIR}/externalpackages/petsc/install/bin/hydra_pmi_proxy .
    43 elif [ -f ${ISSM_DIR}/externalpackages/mpich/install/bin/mpiexec ]; then
    44         cp ${ISSM_DIR}/externalpackages/mpich/install/bin/mpiexec .
    45         cp ${ISSM_DIR}/externalpackages/mpich/install/bin/hydra_pmi_proxy .
    46 else
    47         echo "MPICH not found"
    48         exit 1
    49 fi
    50 
    51 # Run tests
    52 echo "Running tests"
    53 cd ${ISSM_DIR}/test/NightlyRun
     19cd ${INSTALL_DIR}
     20rm -rf ${PKG}
     21tar -zxvf ${COMPRESSED_PKG}
     22cd ${PKG}/test/NightlyRun
    5423
    5524# Check that MATLAB tests run
    5625echo "Running MATLAB tests"
    57 
    5826rm matlab.log 2> /dev/null
    5927
    6028# Run MATLAB tests redirecting output to logfile and suppressing output to console
    61 ${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
     29${MATLAB_PATH}/bin/matlab -nosplash -nodesktop -nojvm -r "try, addpath ../../bin; addpath ../../lib; runme(${MATLAB_NROPTIONS}); exit; catch me,fprintf('%s',getReport(me)); exit; end" -logfile matlab.log &> /dev/null
    6230
    6331# Check that MATLAB did not exit in error
    6432matlabExitCode=`echo $?`
    65 matlabExitedInError=`grep -E "Activation cannot proceed|license|Error" matlab.log | wc -l`
     33matlabExitedInError=`grep -E "Activation cannot proceed|license|Error|Warning: Name is nonexistent or not a directory" matlab.log | wc -l`
    6634
    6735if [[ ${matlabExitCode} -ne 0 || ${matlabExitedInError} -ne 0 ]]; then
    6836        echo "----------MATLAB exited in error!----------"
    6937        cat matlab.log
     38        echo
    7039        echo "-----------End of matlab.log-----------"
    71 
    72         # Clean up execution directory
    73         rm -rf ${ISSM_DIR}/execution/*
    74 
    7540        exit 1
    7641fi
     
    8550        echo "All MATLAB tests PASSED"
    8651fi
    87 
    88 # Create tarball
    89 cd ${ISSM_DIR}
    90 rm -f ${TARBALL}
    91 svn cleanup --remove-ignored --remove-unversioned test # Clean up test directory (before copying to package)
    92 echo "Copying assets to package: ${PACKAGE}"
    93 cp -rf bin examples lib scripts test ${PACKAGE}/
    94 echo "Cleaning up unneeded/unwanted files"
    95 rm -f ${PACKAGE}/bin/generic_static.* # Remove static versions of generic cluster classes
    96 rm -f ${PACKAGE}/lib/*.a # Remove static libraries from package (we only need MEX-files)
    97 rm -f ${PACKAGE}/lib/*.la # Remove libtool libraries from package
    98 rm -rf ${PACKAGE}/test/SandBox # Remove testing sandbox from package
    99 echo "Creating tarball: ${TARBALL_NAME}"
    100 tar -czf ${TARBALL} ${PACKAGE}
    101 ls -lah ${ISSM_DIR}/${TARBALL}
    102 
    103 echo "Transferring binaries to ISSM Web site"
    104 scp -i ~/.ssh/pine_island_to_ross ${TARBALL} jenkins@ross.ics.uci.edu:/var/www/html/${TARBALL}
    105 
    106 if [ $? -ne 0 ]; then
    107         echo "FAILED: Manually check connection"
    108         exit 1
    109 fi
Note: See TracChangeset for help on using the changeset viewer.