|
1 | 1 | #!/bin/bash
|
2 |
| -if [[ $# -ne 3 && $# -ne 2 ]]; then |
3 |
| - cat <<EOF |
4 |
| -Usage: |
| 2 | +USAGE="Usage: |
5 | 3 |
|
6 |
| - $0 RCP_FILE OUTPUT_DIR [JDK_FILE] |
| 4 | +$0 -r <rcp_file> -o <output_dir> [-j <jdk_file>] [-p <password keychain> -k <keychain> -i <sign identity>] |
7 | 5 |
|
8 | 6 | 1. Extracts RCP_FILE into OUTPUT_DIR
|
9 | 7 | 2. Creates symlinks Contents/bin/*.dylib -> *.jnilib
|
10 |
| -3. If JDK_FILE is given, extracts JDK_FILE under Contents/jre/ |
| 8 | +3. If JDK_FILE is given extracts JDK_FILE under Contents/jre/ |
11 | 9 | 4. Builds help indices using hiutil if help is present under Contents/Resources/
|
12 | 10 | 5. Sets executable permissions on Contents/MacOS/* and appropriate Contents/bin/ files
|
13 |
| -
|
| 11 | +6. If given, signs the application with the passed SIGN_PW, SIGN_KEY_CHAIN and SIGN_IDENTITY |
14 | 12 | IMPORTANT: All arguments must use absolute paths because the script changes the current directory several times!
|
15 |
| -EOF |
16 |
| - exit 1 |
17 |
| -fi |
18 |
| - |
| 13 | +" |
19 | 14 | set -o errexit # Exit immediately on any error
|
20 | 15 |
|
21 |
| -# Arguments |
22 |
| -RCP_FILE="$1" |
23 |
| -OUTPUT_DIR="$2" |
24 |
| -JDK_FILE="$3" |
| 16 | +# Parse arguments |
| 17 | +while getopts ":r:o:j:p:k:i:h" option; |
| 18 | +do |
| 19 | + case "${option}" in |
| 20 | + r) RCP_FILE="$OPTARG";; |
| 21 | + o) OUTPUT_DIR="$OPTARG";; |
| 22 | + j) JDK_FILE="$OPTARG";; |
| 23 | + p) SIGN_PW="$OPTARG";; |
| 24 | + k) SIGN_KEY_CHAIN="$OPTARG";; |
| 25 | + i) SIGN_IDENTITY="$OPTARG";; |
| 26 | + h) echo "$USAGE" |
| 27 | + exit 0;; |
| 28 | + \?) echo "illegal option: -$OPTARG usage: $0 -r <rcp_file> -o <output_dir> [-j <jdk_file>] [-p <password keychain> -k <keychain> -i <sign identity>]" >&2 |
| 29 | + exit 1;; |
| 30 | + :) echo "option: -$OPTARG requires an argument" >&2 |
| 31 | + exit 1;; |
| 32 | + esac |
| 33 | +done |
| 34 | +shift $((OPTIND -1)) #remove options that have already been handled from $@ |
| 35 | + |
| 36 | +if [[ -z "$RCP_FILE" || -z "$OUTPUT_DIR" ]]; then |
| 37 | + echo "$USAGE" |
| 38 | + exit 1 |
| 39 | +fi |
25 | 40 |
|
26 | 41 | echo "Unzipping $RCP_FILE to $OUTPUT_DIR..."
|
27 | 42 | unzip -q -o "$RCP_FILE" -d "$OUTPUT_DIR"
|
@@ -71,13 +86,20 @@ if [[ -d "$HELP_DIR" ]]; then
|
71 | 86 | hiutil -Cagvf "$HELP_DIR/search.helpindex" "$HELP_DIR"
|
72 | 87 | fi
|
73 | 88 |
|
74 |
| -# Make sure JetBrainsMacApplication.p12 is imported into local KeyChain |
75 |
| -#security unlock-keychain -p <password> /Users/builduser/Library/Keychains/login.keychain |
76 |
| -#codesign -v --deep -s "Developer ID Application: JetBrains" "$OUTPUT_DIR/$BUILD_NAME" |
77 |
| -#echo "signing is done" |
78 |
| -#echo "check sign" |
79 |
| -#codesign -v "$OUTPUT_DIR/$BUILD_NAME" -vvvvv |
80 |
| -#echo "check sign done" |
| 89 | +# Make sure your certificate is imported into local KeyChain |
| 90 | +if [[ -n "$SIGN_PW" && -n "$SIGN_KEY_CHAIN" && -n "$SIGN_IDENTITY" ]]; then |
| 91 | + echo "Signing application $BUILD_NAME" |
| 92 | + echo "key chain: $SIGN_KEY_CHAIN" |
| 93 | + echo "sign identity: $SIGN_IDENTITY" |
| 94 | + security unlock-keychain -p $SIGN_PW $SIGN_KEY_CHAIN |
| 95 | + codesign -v --deep -s "$SIGN_IDENTITY" "$OUTPUT_DIR/$BUILD_NAME" |
| 96 | + echo "signing is done" |
| 97 | + echo "check sign" |
| 98 | + codesign -v "$OUTPUT_DIR/$BUILD_NAME" -vvvvv |
| 99 | + echo "check sign done" |
| 100 | +else |
| 101 | + echo "for signing the application $BUILD_NAME: SIGN_PW, SIGN_KEY_CHAIN and SIGN_IDENTITY needs to be provided" |
| 102 | +fi |
81 | 103 |
|
82 | 104 | chmod a+x "$CONTENTS"/MacOS/*
|
83 | 105 | chmod a+x "$CONTENTS"/bin/*.py
|
|
0 commit comments