Skip to content

Commit 8f6a2ba

Browse files
committed
Make the macOS DMG much nicer
1 parent f90563e commit 8f6a2ba

File tree

3 files changed

+82
-8
lines changed

3 files changed

+82
-8
lines changed

packaging/macos/dmg-background.png

8.38 KB
Loading

packaging/macos/dmg-background.svg

Lines changed: 23 additions & 0 deletions
Loading

scripts/codesign_and_notarize.sh

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sudo xcode-select -s /Applications/Xcode.app/
44

55
SIGNER="Developer ID Application: Meltytech, LLC (Y6RX44QG2G)"
66
find ~/Desktop/Shotcut.app -type d -name __pycache__ -exec rm -r {} \+
7-
find ~/Desktop/Shotcut.app/Contents \( -name '*.o' -or -name '*.a' -or -name '*.dSYM' \) -exec rm {} \;
7+
find ~/Desktop/Shotcut.app/Contents \( -name '*.o' -or -name '*.a' -or -name '*.dSYM' \) -exec rm -rf {} \;
88
xattr -cr ~/Desktop/Shotcut.app
99

1010
# Strip any pre-existing signatures so we can overwrite (Qt SDK, etc.)
@@ -37,14 +37,65 @@ codesign --options=runtime --timestamp --force --verbose --sign "$SIGNER" \
3737
codesign --verify --deep --strict --verbose=4 ~/Desktop/Shotcut.app
3838
spctl -a -t exec -vv ~/Desktop/Shotcut.app
3939

40+
# Create DMG with custom background and layout
4041
TMP=$(mktemp -d)
41-
mv ~/Desktop/Shotcut.app $TMP
42-
ln -s /Applications $TMP
43-
cp ../COPYING $TMP
44-
rm ~/Desktop/shotcut-macos-${VERSION}.dmg
45-
hdiutil create -srcfolder $TMP -volname Shotcut -format UDBZ -size 1500m \
46-
~/Desktop/shotcut-macos-${VERSION}.dmg
47-
rm -rf $TMP
42+
DMGDIR="$TMP/dmg"
43+
mkdir -p "$DMGDIR/.background"
44+
45+
# Move app and create Applications symlink
46+
mv ~/Desktop/Shotcut.app "$DMGDIR/"
47+
ln -s /Applications "$DMGDIR/Applications"
48+
49+
# Copy background image
50+
cp ../packaging/macos/dmg-background.png "$DMGDIR/.background/"
51+
52+
# Create initial DMG (writable)
53+
rm -f ~/Desktop/shotcut-macos-${VERSION}.dmg
54+
rm -f ~/Desktop/shotcut-macos-${VERSION}-temp.dmg
55+
hdiutil create -srcfolder "$DMGDIR" -volname Shotcut -format UDRW -size 1500m -fs HFS+ \
56+
~/Desktop/shotcut-macos-${VERSION}-temp.dmg
57+
58+
# Mount the temporary DMG
59+
device=$(hdiutil attach -readwrite -noverify ~/Desktop/shotcut-macos-${VERSION}-temp.dmg | \
60+
egrep '^/dev/' | sed 1q | awk '{print $1}')
61+
62+
# Wait for mount
63+
sleep 2
64+
65+
# Run AppleScript to set up the DMG window
66+
osascript > /dev/null <<EOF
67+
tell application "Finder"
68+
tell disk "Shotcut"
69+
open
70+
set current view of container window to icon view
71+
set toolbar visible of container window to false
72+
set statusbar visible of container window to false
73+
set the bounds of container window to {400, 100, 1000, 500}
74+
set viewOptions to the icon view options of container window
75+
set arrangement of viewOptions to not arranged
76+
set icon size of viewOptions to 72
77+
set background picture of viewOptions to file ".background:dmg-background.png"
78+
set position of item "Shotcut.app" of container window to {150, 180}
79+
set position of item "Applications" of container window to {450, 180}
80+
close
81+
open
82+
update without registering applications
83+
delay 2
84+
end tell
85+
end tell
86+
EOF
87+
88+
# Unmount the DMG
89+
hdiutil detach "${device}"
90+
sleep 2
91+
92+
# Convert to compressed read-only DMG
93+
hdiutil convert ~/Desktop/shotcut-macos-${VERSION}-temp.dmg \
94+
-format UDBZ -o ~/Desktop/shotcut-macos-${VERSION}.dmg
95+
96+
# Clean up
97+
rm -f ~/Desktop/shotcut-macos-${VERSION}-temp.dmg
98+
rm -rf "$TMP"
4899

49100
./notarize.sh ~/Desktop/shotcut-macos-${VERSION}.dmg
50101
./staple.sh ~/Desktop/shotcut-macos-${VERSION}.dmg

0 commit comments

Comments
 (0)