Skip to content

Commit

Permalink
Adding tools for packaging the application
Browse files Browse the repository at this point in the history
Added a script for building a *.dmg out of the *.app folder produced by ADL.
  • Loading branch information
ciacob committed Feb 20, 2024
1 parent 4e9db4b commit 12869e2
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dist/macOs--dmg-tools/mac-dmg-image.psd
Git LFS file not shown
67 changes: 67 additions & 0 deletions dist/macOs--dmg-tools/make-dmg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/sh

die () {
echo >&2 "$@"
exit 1
}

# Check for proper number of args
[ "$#" -eq 4 ] || die "Usage: ./make-dmg.sh source-folder background-picture title size-in-kb"

# Check if both source folder and background-image exist
ls "$1" >/dev/null 2>&1 && echo "FOUND source folder $1" || die "Source folder $1 NOT found"
ls "$2" >/dev/null 2>&1 && echo "FOUND background picture $2" || die "Background picture $2 NOT found"

# Store arguments under better names
source=$1
bgpic=$2
bgpicname=$(basename ${bgpic})
title=$3
size=$4

# Create a disk image and attach (mount) it
hdiutil create -srcfolder "${source}" -volname "${title}" -fs HFS+ \
-fsargs "-c c=64,a=16,e=16" -format UDRW -size ${size}k pack.temp.dmg
device=$(hdiutil attach -readwrite -noverify -noautoopen "pack.temp.dmg" | \
egrep '^/dev/' | sed 1q | awk '{print $1}')
sleep 5

echo "Created and attached device: ${device}"

# Copy the background image on the attached image
mkdir /Volumes/"${title}"/.background/
cp ${bgpic} /Volumes/"${title}"/.background/${bgpicname}

# Generate some applescript to setup the visuals of the disk image
echo '
tell application "Finder"
tell disk "'${title}'"
open
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 theViewOptions to the icon view options of container window
set arrangement of theViewOptions to not arranged
set icon size of theViewOptions to 256
set background picture of theViewOptions to file ".background:'${bgpicname}'"
make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"}
set position of item "'${title}'" of container window to {148, 204}
set position of item "Applications" of container window to {521, 204}
close
open
update without registering applications
delay 5
end tell
end tell
' | osascript

# Set the disk image to readonly and compress it
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"
rm -f pack.temp.dmg

#EOF
28 changes: 28 additions & 0 deletions dist/macOs--dmg-tools/tmp/Info.plist.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleAllowMixedLocalizations</key>
<true/>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>LSMinimumSystemVersion</key>
<string>10.6</string>
<key>LSRequiresCarbon</key>
<true/>
<key>CFBundleIdentifier</key>
<string>ro.ciacob.maidens</string>
<key>CFBundleGetInfoString</key>
<string>1.2.265, Claudius Tiberiu Iacob</string>
<key>CFBundleShortVersionString</key>
<string>1.2.265</string>
<key>NSHumanReadableCopyright</key>
<string>Claudius Tiberiu Iacob</string>
<key>CFBundleExecutable</key>
<string>MAIDENS</string>
<key>CFBundleIconFile</key>
<string>maidens-application-icon.icns</string>
</dict>
</plist>
4 changes: 4 additions & 0 deletions dist/macOs--dmg-tools/tmp/sizes-and-positions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
background size: 700 x 394
icons size: 256
program icon position: x=148, y=204 (from icon center) OR x=20, y=76 (from icon's top left corner)
program icon position: x=521, y=204 (from icon center) OR x=393, y=76 (from icon's top left corner)

0 comments on commit 12869e2

Please sign in to comment.