[25886] | 1 | #!/bin/bash
|
---|
| 2 |
|
---|
| 3 | ################################################################################
|
---|
| 4 | # Wrapper script to build, package, send for signing, and transfer to ISSM Web
|
---|
[25893] | 5 | # site ISSM distributable package for macOS with Python API.
|
---|
[25886] | 6 | #
|
---|
| 7 | # Normally, we would put this directly into the project configuration under
|
---|
| 8 | # 'Build' -> 'Excute shell', but becasue it is a bit more involved, it is a
|
---|
| 9 | # good idea to version it.
|
---|
| 10 | #
|
---|
| 11 | # When no failures/errors occur, performs the following:
|
---|
| 12 | # - Builds ISSM according to configuration.
|
---|
[25896] | 13 | # - Packages executables and libraries.
|
---|
[25886] | 14 | # - Runs test suite against package.
|
---|
| 15 | # - Commits compressed package to repository to be signed by JPL Cybersecurity.
|
---|
| 16 | # - Retrieves signed package and transmits it to ISSM Web site for
|
---|
| 17 | # distribution.
|
---|
| 18 | #
|
---|
| 19 | # Options:
|
---|
| 20 | # -b/--skipbuild Skip ISSM compilation.
|
---|
| 21 | # -r/--resign Skip ISSM compilation and packaging. Use to retrigger
|
---|
| 22 | # signing/notarization if it fails but build and package
|
---|
| 23 | # are valid.
|
---|
| 24 | # -s/--skiptests Skip ISSM compilation and testing during packaging
|
---|
[25896] | 25 | # step. Use if packaging fails for some reason but build
|
---|
| 26 | # is valid.
|
---|
[25886] | 27 | # -t/--transferonly Transfer package to ISSM Web site only. Use if transfer
|
---|
| 28 | # fails for some reason to skip building, packaging, and
|
---|
| 29 | # signing.
|
---|
| 30 | # -u/--unlock Remove lock file from signed package repository. Use if
|
---|
| 31 | # build is aborted to allow for subsequent fresh build.
|
---|
| 32 | #
|
---|
| 33 | # Debugging:
|
---|
| 34 | # - Relies on a very tight handshake with project on remote JPL Cybersecurity
|
---|
| 35 | # Jenkins server. Debugging may be perfomed locally by running,
|
---|
| 36 | #
|
---|
[25893] | 37 | # packagers/mac/sign-issm-mac-binaries-python.sh
|
---|
[25886] | 38 | #
|
---|
| 39 | # with "ISSM_BINARIES_USER" and "ISSM_BINARIES_PASS" hardcoded to Apple
|
---|
| 40 | # Developer credentials.
|
---|
| 41 | # - Removing stdout/stderr redirections to null device (> /dev/null 2>&1) can
|
---|
| 42 | # help debug potential SVN issues.
|
---|
| 43 | #
|
---|
| 44 | # NOTE:
|
---|
| 45 | # - Use only *one* of the above options at a time, and make sure it is removed
|
---|
| 46 | # again after a single run.
|
---|
| 47 | # - Builds will fail when any of the above options are used on a clean
|
---|
| 48 | # workspace. For example, if 'Source Code Management' -> 'Check-out Strategy'
|
---|
| 49 | # select menu is set to "Always check out a fresh copy".
|
---|
| 50 | # - Assumes that "ISSM_BINARIES_USER" and "ISSM_BINARIES_PASS" are set up in
|
---|
| 51 | # the 'Bindings' section under a 'Username and password (separated)' binding
|
---|
| 52 | # (requires 'Credentials Binding Plugin') with 'Credentials' select menu set
|
---|
| 53 | # to "jenkins/****** (SVN repository for ISSM binaries)".
|
---|
| 54 | ################################################################################
|
---|
| 55 |
|
---|
| 56 | ## Constants
|
---|
| 57 | #
|
---|
[25893] | 58 | PKG="ISSM-macOS-Python" # Name of directory to copy distributable files to
|
---|
[25886] | 59 | SIGNED_REPO_COPY="./signed"
|
---|
[25893] | 60 | SIGNED_REPO_URL="https://issm.ess.uci.edu/svn/issm-binaries/mac/python/signed"
|
---|
[25886] | 61 |
|
---|
| 62 | COMPRESSED_PKG="${PKG}.zip"
|
---|
| 63 |
|
---|
| 64 | ## Environment
|
---|
| 65 | #
|
---|
| 66 | export COMPRESSED_PKG
|
---|
| 67 | export PKG
|
---|
| 68 | export SIGNED_REPO_COPY
|
---|
| 69 | export SIGNED_REPO_URL
|
---|
| 70 |
|
---|
| 71 | ## Parse options
|
---|
| 72 | #
|
---|
[25891] | 73 | if [ $# -gt 1 ]; then
|
---|
[25889] | 74 | echo "Can use only one option at a time"
|
---|
[25886] | 75 | exit 1
|
---|
| 76 | fi
|
---|
| 77 |
|
---|
| 78 | # NOTE: We could do this with binary switching (i.e. 0011 to sign and transfer,
|
---|
| 79 | # but the following is self-documenting).
|
---|
| 80 | #
|
---|
| 81 | build=1
|
---|
| 82 | package=1
|
---|
| 83 | sign=1
|
---|
| 84 | transfer=1
|
---|
| 85 |
|
---|
| 86 | if [ $# -eq 1 ]; then
|
---|
| 87 | case $1 in
|
---|
| 88 | -b|--skipbuild) build=0; shift ;;
|
---|
| 89 | -r|--resign) build=0; package=0; ;;
|
---|
| 90 | -s|--skiptests) build=0; ;;
|
---|
| 91 | -t|--transferonly) build=0; package=0; sign=0; ;;
|
---|
| 92 | -u|--unlock) build=0; package=0; transfer=0; ;;
|
---|
| 93 | *) echo "Unknown parameter passed: $1"; exit 1 ;;
|
---|
| 94 | esac
|
---|
| 95 | fi
|
---|
| 96 |
|
---|
| 97 | # Build
|
---|
| 98 | if [ ${build} -eq 1 ]; then
|
---|
[25893] | 99 | ./jenkins/jenkins.sh ./jenkins/pine_island-mac-binaries-python
|
---|
[25900] | 100 |
|
---|
[25903] | 101 | if [ $? -ne 0 ]; then
|
---|
[25900] | 102 | exit 1
|
---|
| 103 | fi
|
---|
[25886] | 104 | fi
|
---|
| 105 |
|
---|
| 106 | # Package
|
---|
| 107 | if [ ${package} -eq 1 ]; then
|
---|
[25893] | 108 | ./packagers/mac/package-issm-mac-binaries-python.sh $1
|
---|
[25903] | 109 |
|
---|
| 110 | if [ $? -ne 0 ]; then
|
---|
| 111 | exit 1
|
---|
| 112 | fi
|
---|
[26762] | 113 |
|
---|
| 114 | shift # Clear $1 so that it is not passed to commit_for_signing script
|
---|
[25886] | 115 | fi
|
---|
| 116 |
|
---|
| 117 | # Commit for signing
|
---|
| 118 | if [ ${sign} -eq 1 ]; then
|
---|
[25893] | 119 | ./packagers/mac/commit_for_signing-issm-mac-binaries-python.sh $1
|
---|
[25903] | 120 |
|
---|
| 121 | if [ $? -ne 0 ]; then
|
---|
| 122 | exit 1
|
---|
| 123 | fi
|
---|
[25886] | 124 | fi
|
---|
| 125 |
|
---|
| 126 | # Transfer distributable package to ISSM Web site
|
---|
| 127 | if [ ${transfer} -eq 1 ]; then
|
---|
[25893] | 128 | ./packagers/mac/transfer-issm-mac-binaries.sh
|
---|
[25903] | 129 |
|
---|
| 130 | if [ $? -ne 0 ]; then
|
---|
| 131 | exit 1
|
---|
| 132 | fi
|
---|
[25886] | 133 | fi
|
---|
| 134 |
|
---|