Skip to content

Commit

Permalink
Updated packaging scripts
Browse files Browse the repository at this point in the history
-- Decided to create a disk image file twice in size as the *.app file it will carry, to provide extra dead-room for whatever might be needed.
-- Changed the "get-dir-size.sh" script to only return the exact computed size with no ado.
-- Removed the PNG. It appears macOS does just fine with PSD files, at least the Big Sur version does, which is already pretty old.
-- Updated the background image to better cope with various sizes of the dmg window. Also moved instructions at the top, in order not to overlap the icon labels.
-- Added code in "make-dmg.sh" that moves created *.dmg file under ./OUT/...dmg
-- Gave up trying to set a custom icon on the DMG. Too much effort for nothing.
  • Loading branch information
ciacob committed Feb 21, 2024
1 parent 523ff19 commit 017e034
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 16 deletions.
Binary file added dist/macOs--dmg-tools/OUT/maidens-disk-image.dmg
Binary file not shown.
4 changes: 2 additions & 2 deletions dist/macOs--dmg-tools/build-dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ app_name=$(basename "$app_folder" .app)
# Step 3: Make a temporary copy of the application icon
cp "$app_folder/Contents/Resources/${app_name}-application-icon.icns" "./${app_name}-application-icon.icns"

# Step 4: Calculate the size of the .app folder
size_kb=$(./get-dir-size.sh "$app_folder")
# Step 4: Calculate the size of the .app folder and double it to provide a reasonable quota for our virtual disk
size_kb=$(($(./get-dir-size.sh "$app_folder") * 2))

# Step 5: Build the DMG
./make-dmg.sh "$app_folder" "$2" "$app_name" "$size_kb" "./${app_name}-application-icon.icns"
Expand Down
6 changes: 2 additions & 4 deletions dist/macOs--dmg-tools/get-dir-size.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@ if [ ! -d "$dir" ]; then
exit 1
fi

# Calculate the size of the directory in kilobytes
size_kb=$(du -sk "$dir" | cut -f1)

echo "Size of '$dir': ${size_kb} KB"
# Calculate the size of the directory in kilobytes and print only the size
du -sk "$dir" | cut -f1
Binary file removed dist/macOs--dmg-tools/mac-dmg-image.png
Binary file not shown.
4 changes: 2 additions & 2 deletions dist/macOs--dmg-tools/mac-dmg-image.psd
Git LFS file not shown
13 changes: 5 additions & 8 deletions dist/macOs--dmg-tools/make-dmg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ echo "Created and attached device: ${device}"
mkdir /Volumes/"${title}"/.background/
cp ${bgpic} /Volumes/"${title}"/.background/${bgpicname}

# Copy the custom icon into the root of the DMG and rename it to .VolumeIcon.icns
cp "${icon}" /Volumes/"${title}"/.VolumeIcon.icns


# Generate some applescript to setup the visuals of the disk image
echo '
tell application "Finder"
Expand All @@ -47,7 +43,7 @@ echo '
set current view of container window to icon view
set toolbar visible of container window to false
set statusbar visible of container window to false
set the bounds of container window to {100, 100, 800, 494}
set the bounds of container window to {100, 100, 800, 600}
set theViewOptions to the icon view options of container window
set arrangement of theViewOptions to not arranged
set icon size of theViewOptions to 256
Expand All @@ -68,10 +64,11 @@ chmod -Rf go-w /Volumes/"${title}"
sync
sync
hdiutil detach ${device}
hdiutil convert "pack.temp.dmg" -format UDZO -imagekey zlib-level=9 -o "${title} Image"
hdiutil convert "pack.temp.dmg" -format UDZO -imagekey zlib-level=9 -o "${title}-disk-image"
rm -f pack.temp.dmg

# Set the custom icon for the DMG file
SetFile -a C "${title} Image.dmg"
# Copy resulting *.dmg file to ./OUT (create folder if not already existing)
mkdir -p -m 777 ./OUT || die "Could not create OUT directory"
mv -f ./"${title}-disk-image.dmg" ./OUT/"${title}-disk-image.dmg"

#EOF

0 comments on commit 017e034

Please sign in to comment.