JAL-3393 Made an all-in-one script to create the DS_Store from scratch (has to be...
authorBen Soares <b.soares@dundee.ac.uk>
Fri, 11 Mar 2022 01:54:19 +0000 (01:54 +0000)
committerBen Soares <b.soares@dundee.ac.uk>
Fri, 11 Mar 2022 01:54:19 +0000 (01:54 +0000)
doc/README-DMG_creation.md
utils/channels/release/images/jalview_dmg_DS_Store
utils/install4j/install4j9_template.install4j
utils/install4j/mk_ds_store.sh [new file with mode: 0755]
utils/install4j/set_relative_dmg_background_image.applescript [deleted file]

index dff74bb..5ad5e8d 100644 (file)
@@ -1,6 +1,23 @@
 # Information for making the DMG
 
-## How to make the DS_Store file needed for the DMG prettification
+## New method to make the DS_Store file from scratch (on a Mac)
+
+```
+./utils/install4j/mk_ds_store.sh
+```
+
+A script that creates a new DMG with the top level items to be found in a Jalview Installer DMG, mounts the volume, then uses an AppleScript to adjust the background image, size and position of the icons, and appearance of the Finder window.
+
+The .DS_Store is then copied out of the volume by the script, the volume unmounted, and all files (in /tmp) tidied up.
+
+To use it, the NAME (of the application, without the `.app` extension) should be set in the script (set to "Jalview"), and the background image that you want to use should be copied to your working directory as `background.png`.
+
+Once it is run (only works on a Mac with osascript) it will leave a file Jalview_Installer-DS_Store in your working directory.
+
+
+## Old manual method (possibly instructive)
+
+### How to make the DS_Store file needed for the DMG prettification
 
 > ALSO SEE https://www.ej-technologies.com/resources/install4j/help/doc/concepts/dmgStyling.html
 
@@ -24,32 +41,42 @@ open temp_rw.dmg
 open /Volumes/Jalview\ Installer
 ```
 
-Then manually position/resize icons, extend size of Finder window, etc so that the Finder window looks how you want it.
-You can use the
-
+Run the AppleScript which is needed to set a relative path for the background image which you can ensure is in the volume:
+```
+mkdir -p /Volumes/Jalview\ Installer/.background
+cp utils/channels/release/images/jalview_dmg_background.png /Volumes/Jalview\ Installer/.background/jalview_dmg_background.png
+/usr/bin/osascript utils/install4j/set_relative_dmg_background_image.applescript "Jalview Installer"
 ```
-cp /Volumes/Jalview\ Installer/.DS_Store ./DS_Store_N
+(when copying the background image, always put it in the volume as `.background/jalview_dmg_background.png` as that is the relative path we want in the DS_Store.
 
+Then manually position/resize icons, extend size of Finder window, etc so that the Finder window looks how you want it. Some of this is now done by the above AppleScript.
+Wait a few seconds to allow the `.DS_Store file` to update.
+You can now use the `.DS_Store` file and unmount the RW volume.
+```
+cp /Volumes/Jalview\ Installer/.DS_Store ./utils/channel/release/images/jalview_dmg_DS_Store
 umount /Volumes/Jalview\ Installer
 ```
 
-## Background image
+### Background image
 
 See file `README-DMG_background_image_creation.md` on how to create the background image.
 
-## Adding the background image
+### Adding the background image
 
-See https://www.ej-technologies.com/resources/install4j/help/doc/concepts/dmgStyling.html which describes how to add the background image to your DMG file
-using macOS Finder.
+#### update 2022-03-10
+> NEW METHOD: The background image setting now gets added as a relative path with the AppleScript.
+> OLD METHOD: See https://www.ej-technologies.com/resources/install4j/help/doc/concepts/dmgStyling.html which describes how to add the background image to your DMG file using macOS Finder.
+> 
+> Adding the background image in this way sets a full path from `/` in the `.DS_Store`, meaning the DMG Volume name cannot change (or if it does then the background image isn't found and so not displayed).
+> It should now be set (only needs to be done once) to a relative path, e.g. `.background/jalview_dmg_background.png` using the AppleScript in `utils/install4j/set_relative_dmg_background_image.applescript` with, e.g.
+> ` /usr/bin/osascript ./set_relative_dmg_background_image.applescript Jalview\ Installer\ \(2.11.2.0\) `
+> which has to be done when the temporary volume is mounted in read-write (UDRW) mode.
 
-### update 2022-03-10
-Adding the background image in this way sets a full path from `/` in the `.DS_Store`, meaning the DMG Volume name cannot change (or if it does then the background image isn't found and so not displayed).
-It should now be set (only needs to be done once) to a relative path, e.g. `.background/jalview_dmg_background.png` using the AppleScript in `utils/install4j/set_relative_dmg_background_image.applescript` with, e.g.
-```
-/usr/bin/osascript ./applescript.applescript Jalview\ Installer\ \(2.11.2.0\)
-```
+## Future development
 
 Worth exploring further:
-* https://github.com/create-dmg/create-dmg
+* https://github.com/create-dmg/create-dmg  [This was main resource for the new script]
 * and the AppleScript on https://stackoverflow.com/questions/96882/how-do-i-create-a-nice-looking-dmg-for-mac-os-x-using-command-line-tools
 to script precise placement of icons over background image.
+* https://miloserdov.org/?p=3867
+* https://www.npmjs.com/package/create-dmg
index d9ad296..006f829 100644 (file)
Binary files a/utils/channels/release/images/jalview_dmg_DS_Store and b/utils/channels/release/images/jalview_dmg_DS_Store differ
index a6d0893..2b252ff 100644 (file)
@@ -1450,7 +1450,7 @@ ${compiler:JALVIEW_APPLICATION_NAME} will now launch.</property>
       <jreBundle jreBundleSource="none" />
       <topLevelFiles>
         <symlink name="&quot; &quot;" target="/Applications" />
-        <file name=".background/jalview_dmg_background.png" file="${compiler:JALVIEW_DIR}/${compiler:MACOS_DMG_BG_IMAGE}" />
+        <file name=".background/background.png" file="${compiler:JALVIEW_DIR}/${compiler:MACOS_DMG_BG_IMAGE}" />
         <file name=".DS_Store" file="${compiler:JALVIEW_DIR}/${compiler:MACOS_DMG_DS_STORE}" />
         <file name="${compiler:JALVIEW_APPLICATION_NAME}.app/Contents/Resources/Jalview-File.icns" file="${compiler:JALVIEW_DIR}/${compiler:INSTALL4J_UTILS_DIR}/Jalview-File.icns" />
         <file name="${compiler:JALVIEW_APPLICATION_NAME}.app/Contents/Resources/jvl_file.icns" file="${compiler:JALVIEW_DIR}/${compiler:INSTALL4J_UTILS_DIR}/jvl_file.icns" />
diff --git a/utils/install4j/mk_ds_store.sh b/utils/install4j/mk_ds_store.sh
new file mode 100755 (executable)
index 0000000..d08249f
--- /dev/null
@@ -0,0 +1,93 @@
+#!/usr/bin/env bash
+
+NAME="Jalview"
+
+TMPNAME="${NAME// /_}_Installer"
+APPNAME="${NAME}.app"
+DMG="${TMPNAME}.dmg"
+
+WDIR=$(pwd)
+cd /tmp
+mkdir -p "$TMPNAME"
+cd "$TMPNAME"
+mkdir "$APPNAME"
+ln -s /Applications " "
+mkdir .background
+mkdir .fseventsd
+cp "${WDIR}/background.png" .background/background.png
+cd /tmp
+[ -e "$DMG" ] && rm "$DMG"
+hdiutil create -volname "$TMPNAME" -srcfolder "$TMPNAME" -size 1m -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW "$DMG"
+open "$DMG"
+
+sleep 1
+
+VOL="/Volumes/${TMPNAME}"
+#osascript "${WDIR}/set_ds_store.applescript" "$TMPNAME" "$APPNAME"
+osascript - "$TMPNAME" "$APPNAME" <<EOF
+on run {volumeName, appName}
+       tell application "Finder"
+               tell disk (volumeName as string)
+                       open
+                       
+                       set theXOrigin to 10
+                       set theYOrigin to 60
+                       set theWidth to 480
+                       set theHeight to 300
+                       
+                       set theBottomRightX to (theXOrigin + theWidth)
+                       set theBottomRightY to (theYOrigin + theHeight)
+                       
+                       tell container window
+                               set current view to icon view
+                               set toolbar visible to false
+                               set statusbar visible to false
+                               set pathbar visible to false
+                               set bounds to {theXOrigin, theYOrigin, theBottomRightX, theBottomRightY + 220}
+                               set statusbar visible to false
+                               set position of every item to {100, theBottomRightY + 150}
+                       end tell
+                       
+                       set opts to the icon view options of container window
+                       tell opts
+                               set icon size to 76
+                               set text size to 14
+                               set label position to bottom    
+                               set arrangement to not arranged
+                       end tell
+                       
+                       set background picture of opts to file ".background:background.png"
+                       
+                       set position of item (appName as string) to {133, 124}
+                       set position of item " " to {336, 124}
+
+                       tell container window
+                               set bounds to {theXOrigin, theYOrigin, theBottomRightX, theBottomRightY}
+                       end tell
+                       
+                       close
+                       open
+
+                       update every item
+               end tell
+       end tell
+end run
+EOF
+
+DSSTORE="${VOL}/.DS_Store"
+until [ -e "$DSSTORE" ] && grep background.png "$DSSTORE"; do
+  sleep 1
+  echo "Waiting for \"$DSSTORE\" to update"
+done
+
+SAVED_DSSTORE="${TMPNAME}-DS_Store"
+cp "$DSSTORE" "${WDIR}/${SAVED_DSSTORE}"
+echo "Created new .DS_Store as \"$SAVED_DSSTORE\""
+
+umount "$VOL"
+cd /tmp
+rm "$DMG"
+rm -r "/tmp/${TMPNAME}"
+
+cd "$WDIR"
+
diff --git a/utils/install4j/set_relative_dmg_background_image.applescript b/utils/install4j/set_relative_dmg_background_image.applescript
deleted file mode 100644 (file)
index 1e9cbd2..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-on run (volumeName)
-       tell application "Finder"
-               tell disk (volumeName as string)
-                       open
-
-                       set dsStore to "\"" & "/Volumes/" & volumeName & "/" & ".DS_STORE\""
-                       set opts to the icon view options of container window                   
-                       set background picture of opts to file ".background:jalview_dmg_background.png"
-                       
-               end tell
-       end tell
-end run
\ No newline at end of file