JAL-4428 added the signing and stapling scripts - not yet integrated with JAL-4421
authorJim Procter <jprocter@dundee.ac.uk>
Thu, 6 Jun 2024 10:47:20 +0000 (11:47 +0100)
committerJim Procter <jprocter@dundee.ac.uk>
Thu, 6 Jun 2024 10:47:20 +0000 (11:47 +0100)
utils/osx_signing/sign_dmg.sh [new file with mode: 0755]
utils/osx_signing/staple_dmg.sh [new file with mode: 0755]

diff --git a/utils/osx_signing/sign_dmg.sh b/utils/osx_signing/sign_dmg.sh
new file mode 100755 (executable)
index 0000000..1b3973c
--- /dev/null
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+if [[ "$GITDIR" == "" ]]; then
+    GITDIR=~/uod-development/jalview-builds/git/jalview
+fi;
+
+if [[ "$DEVELOPERID" == "" ]]; then
+    DEVELOPERID="Developer ID"
+fi;
+
+if [[ "$TMPDMG" == "" ]]; then
+    TMPDMG="signingDMG"
+fi;
+
+echo APPNAME $APPNAME like Jalview Test
+echo doing ARCH $ARCH
+echo using entitlements from $GITDIR
+echo using key $DEVELOPERID
+
+FAPPNAME="${APPNAME/ /\\ }"
+FAPPNAMEESC="${APPNAME/ /\\\\\\ }"
+FWAPP="${APPNAME/ [A-Za-z]*/}"
+ARCHNAME="${APPNAME// /_}-${APPVER//\./_}-macos-$ARCH-java_$JVER"
+DMGNAME="${APPNAME/ /_}-${APPVER//\./_}-macos-$ARCH-java_$JVER.dmg"
+VOLNAME="${APPNAME// /_}\\ Installer\\ \\(${APPVER//\./_}\\ $ARCH\\ $JVER\\)"
+VLNAME="${APPNAME// /_} Installer (${APPVER//\./_} $ARCH $JVER)"
+BORINGVLNAME="${APPNAME} Installer"
+
+
+
+echo "will mount $DMGNAME as $VOLNAME"
+if [[ -d $TMPDMG ]]; then
+       echo "'$TMPDMG' is in the way. Please delete it or set TMPDMG"
+       exit 1;
+fi
+
+if [[ -f $DMGNAME ]]; then
+    hdiutil attach $DMGNAME
+    ditto /Volumes/${FWAPP}* $TMPDMG
+    hdiutil eject /Volumes/${FWAPP}*
+    mkdir -p unsigned
+    mv -v $DMGNAME unsigned/
+    echo Moved $DMGNAME to unsigned/$DMGNAME
+    codesign  --remove-signature --force --deep -vvvv -s "Developer ID" --options runtime --entitlements $GITDIR/utils/osx_signing/entitlements.txt $TMPDMG/${FWAPP}*.app/Contents/Resources/app/jre/Contents/MacOS/libjli.dylib 
+
+    codesign  --verify --deep -v ./$TMPDMG/${FWAPP}*.app/Contents/Resources/app/jre/Contents/MacOS/libjli.dylib 
+
+    codesign --remove-signature --force --deep -vvvv -s "Developer ID" --options runtime --entitlements $GITDIR/utils/osx_signing/entitlements.txt  $TMPDMG/${FWAPP}*.app/Contents/MacOS/JavaApplicationStub
+
+    hdiutil create -megabytes 260 -srcfolder ./$TMPDMG -volname "$BORINGVLNAME" $ARCHNAME.dmg
+
+    codesign --force --deep -vvvv -s "Developer ID" --options runtime --entitlements $GITDIR/utils/osx_signing/entitlements.txt $ARCHNAME.dmg
+
+    codesign --deep -vvvv $ARCHNAME.dmg
+    
+    rm -Rf $TMPDMG
+else
+    echo Can\'t find $DMGNAME - dit you set APPNAME APPVER ARCH and JVER correctly ?
+fi
+
diff --git a/utils/osx_signing/staple_dmg.sh b/utils/osx_signing/staple_dmg.sh
new file mode 100755 (executable)
index 0000000..0eb24dc
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+if [[ "$GITDIR" == "" ]]; then
+    GITDIR=~/uod-development/jalview-builds/git/jalview
+fi;
+
+
+if [[ "$DEVELOPERID" == "" ]]; then
+    DEVELOPERID="Developer ID"
+fi;
+
+if [[ "$TMPDMG" == "" ]]; then
+    TMPDMG="staplingDMG"
+fi;
+
+
+echo APPNAME $APPNAME like Jalview Test
+echo doing ARCH $ARCH
+echo using entitlements from $GITDIR
+
+FAPPNAME="${APPNAME/ /\\ }"
+FAPPNAMEESC="${APPNAME/ /\\\\\\ }"
+FWAPP="${APPNAME/ [A-Za-z]*/}"
+ARCHNAME="${APPNAME// /_}-${APPVER//\./_}-macos-$ARCH-java_$JVER"
+DMGNAME="${APPNAME/ /_}-${APPVER//\./_}-macos-$ARCH-java_$JVER.dmg"
+VOLNAME="${APPNAME// /_}\\ Installer\\ \\(${APPVER//\./_}\\ $ARCH\\ $JVER\\)"
+VLNAME="${APPNAME// /_} Installer (${APPVER//\./_} $ARCH $JVER)"
+BORINGVLNAME="${APPNAME} Installer"
+echo "will mount $DMGNAME as $VOLNAME"
+
+if [[ -d $TMPDMG ]]; then
+       echo "'$TMPDMG' is in the way. Please delete it or set TMPDMG"
+       exit 1;
+fi
+
+if [[ -f $DMGNAME ]]; then
+    hdiutil attach $DMGNAME
+    ditto /Volumes/${FWAPP}* $TMPDMG
+    hdiutil eject /Volumes/${FWAPP}*
+    xcrun stapler staple $TMPDMG/${FWAPP}*.app
+    mkdir -p stapled
+    hdiutil create -megabytes 240 -srcfolder $TMPDMG -volname "$BORINGVLNAME" stapled/$DMGNAME
+    codesign --force --deep -vvvv -s "$DEVELOPERID" --options runtime --entitlements ${GITDIR}/utils/osx_signing/entitlements.txt stapled/$DMGNAME
+    codesign --deep -vvvv stapled/$DMGNAME
+       echo "Stapled DMG is in stapled/$DMGNAME"
+    rm -Rf $TMPDMG    
+else
+    echo Can\'t find $DMGNAME - dit you set APPNAME APPVER ARCH and JVER correctly ?
+fi
+