From d7513114bef4a00c1b5133382d45b6b35a8e6e9c Mon Sep 17 00:00:00 2001 From: idk Date: Wed, 1 Feb 2023 23:23:14 +0000 Subject: [PATCH] fix every single shellcheck error --- build.sh | 50 +++++++++++++++++++++++------------------------ clean.sh | 6 +++--- config.example.sh | 7 ++----- release.sh | 10 +++++----- 4 files changed, 35 insertions(+), 38 deletions(-) diff --git a/build.sh b/build.sh index 96c398d..61078b2 100755 --- a/build.sh +++ b/build.sh @@ -1,15 +1,15 @@ #!/bin/bash set -e -if [ -z $I2P_VERSION ]; then +if [ -z "$I2P_VERSION" ]; then I2P_VERSION=2.1.0 fi -if [ -z $I2P_BUILD_NUMBER ]; then +if [ -z "$I2P_BUILD_NUMBER" ]; then I2P_BUILD_NUMBER=1 fi if [ -f config.sh ]; then - . config.sh + . "config.sh" fi # old javas output version to stderr and don't support --version @@ -26,7 +26,7 @@ if [ "$JAVA" -lt "16" ]; then exit 1 fi -if [ -z ${JAVA_HOME} ]; then +if [ -z "${JAVA_HOME}" ]; then JAVA_HOME=$(/usr/libexec/java_home) fi @@ -88,7 +88,7 @@ cd "$HERE" mkdir build echo "compiling custom launcher and update processor" -cp $I2P_JARS/*.jar build +cp "$I2P_JARS"/*.jar build cd java javac -d ../build -classpath ../build/i2p.jar:../build/router.jar net/i2p/router/MacLauncher.java net/i2p/update/*.java cd "$HERE" @@ -104,18 +104,18 @@ cd .. echo "compiling native lib" cc -v -Wl,-lobjc -mmacosx-version-min=10.9 -I"$JAVA_HOME/include" -I"$JAVA_HOME/include/darwin" -Ic -o build/libMacLauncher.jnilib -shared c/net_i2p_router_MacLauncher.c -if [ -z $I2P_SIGNER ]; then +if [ -z "$I2P_SIGNER" ]; then echo "I2P_SIGNER is unset, not proceeding to sign jbigi libs" - cp $I2P_JARS/jbigi.jar build + cp "$I2P_JARS"/jbigi.jar build else echo "signing jbigi libs" mkdir jbigi - cp $I2P_JARS/jbigi.jar jbigi + cp "$I2P_JARS"/jbigi.jar jbigi cd jbigi unzip jbigi.jar for lib in *.jnilib; do - codesign --force -s $I2P_SIGNER -v $lib - jar uf jbigi.jar $lib + codesign --force -s "$I2P_SIGNER" -v "$lib" + jar uf jbigi.jar "$lib" done cp jbigi.jar ../build cd .. @@ -125,7 +125,7 @@ echo "preparing to invoke jpackage for I2P version $I2P_VERSION build $I2P_BUILD cp "$I2P_PKG/Start I2P Router.app/Contents/Resources/i2p.icns" build/I2P.icns cp "$I2P_PKG/Start I2P Router.app/Contents/Resources/i2p.icns" build/I2P-volume.icns -cp $I2P_PKG/LICENSE.txt build +cp "$I2P_PKG/LICENSE.txt" build cat resources/License-JRE-snippet.txt >> build/LICENSE.txt cp resources/I2P-background.tiff build @@ -149,44 +149,44 @@ jpackage --name I2P \ --input build --main-jar launcher.jar --main-class net.i2p.router.MacLauncher echo "adding pkg-temp to resources" -cp -R $I2P_PKG/* I2P.app/Contents/Resources +cp -R "$I2P_PKG"/* I2P.app/Contents/Resources for i in i2prouter lib locale man wrapper.config eepget runplain.sh postinstall.sh osid; do rm -rf I2P.app/Contents/Resources/$i done -cp $HERE/resources/GPLv2+CE.txt I2P.app/Contents/Resources/licenses/LICENSE-JRE.txt -cp $I2P_PKG/licenses/* I2P.app/Contents/Resources/licenses/ -cp $HERE/build/libMacLauncher.jnilib I2P.app/Contents/Resources -if [ $ARCH == "arm64" ]; then - cp $HERE/resources/router.config.arm64 I2P.app/Contents/Resources/router.config +cp "$HERE"/resources/GPLv2+CE.txt I2P.app/Contents/Resources/licenses/LICENSE-JRE.txt +cp "$I2P_PKG"/licenses/* I2P.app/Contents/Resources/licenses/ +cp "$HERE"/build/libMacLauncher.jnilib I2P.app/Contents/Resources +if [ "$ARCH" == "arm64" ]; then + cp "$HERE/resources/router.config.arm64" I2P.app/Contents/Resources/router.config else - cp $HERE/resources/router.config I2P.app/Contents/Resources + cp "$HERE/resources/router.config" I2P.app/Contents/Resources fi -cp $HERE/resources/*.crt I2P.app/Contents/Resources/certificates/router +cp "$HERE"/resources/*.crt I2P.app/Contents/Resources/certificates/router -if [ -z $I2P_SIGNER ]; then +if [ -z "$I2P_SIGNER" ]; then echo "I2P_SIGNER is unset, not proceeding to signing phase" exit 0 fi -if [ -z $I2P_CODE_SIGNER ]; then +if [ -z "$I2P_CODE_SIGNER" ]; then echo "I2P_CODE_SIGNER is unset, not proceeding to signing phase" exit 0 fi echo "signing the runtime libraries" -find I2P.app -name *.dylib -exec codesign --force -s $I2P_SIGNER -v '{}' \; -find I2P.app -name *.jnilib -exec codesign --force -s $I2P_CODE_SIGNER -v '{}' \; +find I2P.app -name "*.dylib" -exec codesign --force -s "$I2P_SIGNER" -v '{}' \; +find I2P.app -name "*.jnilib" -exec codesign --force -s "$I2P_CODE_SIGNER" -v '{}' \; echo "signing the bundle" codesign --force -d --deep -f \ --options=runtime \ --entitlements resources/entitlements.xml \ - -s $I2P_SIGNER \ + -s "$I2P_SIGNER" \ --verbose=4 \ I2P.app -jpackage --name I2P --app-image I2P.app --app-version $I2P_VERSION \ +jpackage --name I2P --app-image I2P.app --app-version "$I2P_VERSION" \ --verbose --temp tmp \ --license-file build/LICENSE.txt \ --mac-sign \ diff --git a/clean.sh b/clean.sh index 9fba7a9..14df1f4 100755 --- a/clean.sh +++ b/clean.sh @@ -15,6 +15,6 @@ rm -rfv \ prngseed.rnd \ router.config \ wrapper.log \ - *.jar \ - *.exe \ - *.dmg + ./*.jar \ + ./*.exe \ + ./*.dmg diff --git a/config.example.sh b/config.example.sh index 16cf3c8..ebdaab1 100644 --- a/config.example.sh +++ b/config.example.sh @@ -13,21 +13,19 @@ # Uncomment/Edit this line to include the build number in the config file # I2P_BUILD_NUMBER=1 -if [ -z $I2P_SIGNER ]; then +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 +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. # it is a unique ID which is a short, random-looking string. # 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: @@ -35,6 +33,5 @@ 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 diff --git a/release.sh b/release.sh index 312be81..1bfed94 100644 --- a/release.sh +++ b/release.sh @@ -1,19 +1,19 @@ #! /usr/bin/env sh -I2P_DATE=`date +%Y-%m-%d` +I2P_DATE=$(date +%Y-%m-%d) -if [ -z ${I2P_OS} ]; then +if [ -z "${I2P_OS}" ]; then I2P_OS=mac fi -if [ -z ${I2P_BRANCH} ]; then +if [ -z "${I2P_BRANCH}" ]; then I2P_BRANCH=beta fi -if [ -z ${I2P_DOWNLOAD} ]; then +if [ -z "${I2P_DOWNLOAD}" ]; then echo "\$I2P_DOWNLOAD is not set, an HTTP download will not be added to releases.json" sleep 5s fi -if [ -z ${I2P_VERSION} ]; then +if [ -z "${I2P_VERSION}" ]; then echo "\$I2P_VERSION not set, aborting" exit 1 fi