From df31d1e67a6f54c9ab50444cb4bad7d5656c4d8d Mon Sep 17 00:00:00 2001 From: idk Date: Wed, 1 Feb 2023 23:08:16 +0000 Subject: [PATCH] automatically set signing keys to first available cert sha256 fingerprint if they aren't set when the script runs, warn user if this happens --- build.sh | 35 +++++++++++++++++++++-------------- config.example.sh | 10 +++------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/build.sh b/build.sh index 55a6ae2..96c398d 100755 --- a/build.sh +++ b/build.sh @@ -26,24 +26,31 @@ if [ "$JAVA" -lt "16" ]; then exit 1 fi -if [ -z "${I2P_SIGNER}" ]; then - echo "I2P_SIGNER variable not set, can't sign. Script will terminate after unsigned app-image generation" -fi - -if [ -z ${I2P_VERSION} ]; then - echo "I2P_VERSION not set, aborting" - exit 1 -fi - -if [ -z ${I2P_BUILD_NUMBER} ]; then - echo "please set the I2P_BUILD_NUMBER variable to some integer >= 1" - exit 1 -fi - if [ -z ${JAVA_HOME} ]; then JAVA_HOME=$(/usr/libexec/java_home) fi +if [ -z "$I2P_SIGNER" ]; then + I2P_SIGNER=$(security find-identity -v -p codesigning | cut -d ' ' -f 3) + echo "Warning: using automatically configured signer ID, make sure this is the one you want: $I2P_SIGNER" + echo "continuing in 10 seconds" + sleep 10s +fi +if [ -z "$I2P_CODE_SIGNER" ]; then + I2P_CODE_SIGNER=$(security find-identity -v -p codesigning | cut -d ' ' -f 3) + echo "Warning: using automatically configured signer ID, make sure this is the one you want: $I2P_CODE_SIGNER" + echo "continuing in 10 seconds" + sleep 10s +fi +if [ -z "$I2P_SIGNER_USERPHRASE" ]; then + I2P_SIGNER_USERPHRASE=$(security find-identity -v -p codesigning | cut -d ' ' -f 3) + echo "Warning: using automatically configured signer ID, make sure this is the one you want: $I2P_SIGNER_USERPHRASE" + echo "continuing in 10 seconds" + sleep 10s +fi + + + echo "JAVA_HOME is $JAVA_HOME" echo "cleaning" diff --git a/config.example.sh b/config.example.sh index 639e832..16cf3c8 100644 --- a/config.example.sh +++ b/config.example.sh @@ -13,19 +13,13 @@ # Uncomment/Edit this line to include the build number in the config file # I2P_BUILD_NUMBER=1 -if [ -z $I2P_VERSION ]; then - I2P_VERSION=2.1.0 -fi -if [ -z $I2P_BUILD_NUMBER ]; then - I2P_BUILD_NUMBER=1 -fi - if [ -z $I2P_SIGNER ]; then # This is the team ID of the Apple account associated with the app. It is used to sign the DMG. # it is a unique ID which is a short, random-looking string. # OR # the sha256 fingerprint of the cert(recommended) echo "I2P_SIGNER not set, signing will not work" + I2P_SIGNER=$(security find-identity -v -p codesigning | cut -d ' ' -f 3) fi if [ -z $I2P_CODE_SIGNER ]; then # This is the code signing ID of the team associated with the Apple Account. it is used to sign the libraries. @@ -33,6 +27,7 @@ if [ -z $I2P_CODE_SIGNER ]; then # OR # the sha256 fingerprint of the cert(recommended) echo "I2P_CODE_SIGNER not set, signing will not work" + I2P_CODE_SIGNER_USERPHRASE=$(security find-identity -v -p codesigning | cut -d ' ' -f 3) fi if [ -z "$I2P_SIGNER_USERPHRASE" ]; then # This is an the phrase identifying the third party developer(I2P) in the following form: @@ -40,5 +35,6 @@ if [ -z "$I2P_SIGNER_USERPHRASE" ]; then # OR # the sha256 fingerprint of the cert(recommended) echo "I2P_SIGNER_USERPHRASE not set, signing will not work" + I2P_SIGNER_USERPHRASE=$(security find-identity -v -p codesigning | cut -d ' ' -f 3) fi