Skip to content

Commit

Permalink
dmg stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
danemadsen committed Jul 4, 2024
1 parent 47c0fc9 commit 097dfd8
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 224 deletions.
Binary file added .github/assets/maid.dmg
Binary file not shown.
111 changes: 12 additions & 99 deletions .github/scripts/create_dmg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,112 +4,25 @@ set -e

APP_NAME="maid"
APP_DIR="build/macos/Build/Products/Release/${APP_NAME}.app"
DMG_DIR="dmg"
DMG_TEMPLATE="./.github/assets/maid.dmg"
DMG_OUTPUT="./dmg/${APP_NAME}.dmg"
TMP_MOUNT="/tmp/Maid"
DMG_BACKGROUND_IMG="./media/dmg.png"
WINX=0
WINY=0
WINW=700
WINH=1000
ICON_SIZE=64
TEXT_SIZE=12

# Create the dmg and app directories if they do not exist
mkdir -p ${DMG_DIR}
# Create the dmg directory if it does not exist
mkdir -p "$(dirname ${DMG_OUTPUT})"
mkdir -p ${TMP_MOUNT}

# Create temporary DMG
hdiutil create ${DMG_DIR}/${APP_NAME}_tmp.dmg -volname "${APP_NAME}" -srcfolder "${APP_DIR}" -ov -format UDRW
# Mount the template DMG
hdiutil attach ${DMG_TEMPLATE} -mountpoint ${TMP_MOUNT} -nobrowse -noverify -noautoopen

# Mount the temporary DMG
hdiutil attach ${DMG_DIR}/${APP_NAME}_tmp.dmg -mountpoint ${TMP_MOUNT}
# Replace the TARGET file with maid.app
rm -rf "${TMP_MOUNT}/TARGET"
cp -R "${APP_DIR}" "${TMP_MOUNT}/maid.app"

# Copy background image
mkdir -p ${TMP_MOUNT}/.background
cp ${DMG_BACKGROUND_IMG} ${TMP_MOUNT}/.background/feature.png

# Create a symbolic link to the Applications folder
ln -s /Applications ${TMP_MOUNT}/Applications

# AppleScript to set DMG properties
osascript <<EOF
on run
tell application "Finder"
tell disk "${APP_NAME}"
open
set theXOrigin to ${WINX}
set theYOrigin to ${WINY}
set theWidth to ${WINW}
set theHeight to ${WINH}
set theBottomRightX to (theXOrigin + theWidth)
set theBottomRightY to (theYOrigin + theHeight)
set dsStore to "\"" & "/Volumes/${APP_NAME}/.DS_Store\""
tell container window
set current view to icon view
set toolbar visible to false
set statusbar visible to false
set the bounds to {theXOrigin, theYOrigin, theBottomRightX, theBottomRightY}
set statusbar visible to false
end tell
set opts to the icon view options of container window
tell opts
set icon size to ${ICON_SIZE}
set text size to ${TEXT_SIZE}
set arrangement to not arranged
end tell
set background picture of opts to file ".background:feature.png"
-- Positioning
set position of item "${APP_NAME}.app" of container window to {150, 50}
set position of item "Applications" of container window to {150, 300}
close
open
-- Force saving of the size
delay 1
tell container window
set statusbar visible to false
set the bounds to {theXOrigin, theYOrigin, theBottomRightX - 10, theBottomRightY - 10}
end tell
end tell
delay 1
tell disk "${APP_NAME}"
tell container window
set statusbar visible to false
set the bounds to {theXOrigin, theYOrigin, theBottomRightX, theBottomRightY}
end tell
end tell
--give the finder some time to write the .DS_Store file
delay 3
set waitTime to 0
set ejectMe to false
repeat while ejectMe is false
delay 1
set waitTime to waitTime + 1
if (do shell script "[ -f " & dsStore & " ]; echo $?") = "0" then set ejectMe to true
end repeat
log "waited " & waitTime & " seconds for .DS_Store to be created."
end tell
end run
EOF

# Unmount the temporary DMG
# Unmount the template DMG
hdiutil detach ${TMP_MOUNT}

# Convert to final DMG
hdiutil convert ${DMG_DIR}/${APP_NAME}_tmp.dmg -format UDZO -o ${DMG_DIR}/${APP_NAME}.dmg

# Remove temporary DMG
rm ${DMG_DIR}/${APP_NAME}_tmp.dmg
# Create the final DMG from the modified template
hdiutil convert ${DMG_TEMPLATE} -format UDZO -o ${DMG_OUTPUT}

echo "DMG creation completed successfully!"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,4 @@ app.*.symbols

.vscode/
docs/.~lock.API-Compatability.ods#
dmg/maid_tmp.dmg
Binary file removed dmg/maid_tmp.dmg
Binary file not shown.
Binary file removed media/dmg.png
Binary file not shown.
125 changes: 0 additions & 125 deletions media/dmg.svg

This file was deleted.

0 comments on commit 097dfd8

Please sign in to comment.