How do I set the Finder view options on a .dmg file that I am creating?
Answer: <LJ-CUT text=" --More--( 5%) ">
- Create a writable .dmg file, and set your Finder view options the way you like.
- Unmount that .dmg.
- Remount it.
- Save a copy of its .DS_Store file.
(You have to do this dance because Finder only flushes changes out to the .DS_Store files when unmounting, or when you log out.)
To build your final .dmg file:
- Creating a "staging" directory and populate it with your files.
- Copy your saved .DS_Store file into the staging directory.
- hdiutil makehybrid -hfs -hfs-volume-name NAME -hfs-openfolder STAGING STAGING -o TMP.dmg
- hdiutil convert -format UDZO TMP.dmg -o FINAL.dmg
You should be able to do that in one step, but that doesn't work. If you don't do "makehybrid" first, and then convert it to a compressed format, Finder will ignore some of your view settings (like icons/list/columns).
A useful tool is Mozilla's "pkg-dmg" script: it supports creation of .dmg files that show a license agreement when mounted, and a bunch of other things. To download it:
- cvs -d :pserver:firstname.lastname@example.org:/cvsroot co mozilla/build/package/mac_osx