Created
September 19, 2019 22:57
-
-
Save staticfloat/62369d705f265c0b35ff8888b2e1d76c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
set -x | |
if [[ -z "$MACOS_CODESIGN_IDENTITY" ]]; then | |
echo "ERROR: Must export MACOS_CODESIGN_IDENTITY" > &2 | |
exit 1 | |
fi | |
# detach anything that's old | |
hdiutil detach /Volumes/Julia-* || true | |
# Mount target dmg, storing modifications in shadow file; find all disk names: | |
DISKS="$(hdiutil attach -owners on "$1" -fs HFS+ -shadow | awk '{ print $1 }' | grep -E '/dev/disk\d+$' | sort | uniq)" | |
# Codesign the app | |
codesign -s "$MACOS_CODESIGN_IDENTITY" --deep -v /Volumes/Julia*/Julia*.app | |
# Create "new" DMG from mounted disk | |
hdiutil create "${1%.*}-new.dmg" -size 1t -fs HFS+ -ov -volname "Julia" -imagekey zlib-level=9 -srcfolder /Volumes/Julia*/ | |
# Unmount the disks | |
for DISK in ${DISKS}; do | |
hdiutil detach "${DISK}" || true | |
done | |
# cleanup | |
mv "${1%.*}-new.dmg" "$1" | |
rm -f "$1.shadow" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment