What is a DMG file and how do I open it?
The DMG format is a mirror file on a Mac system, or a compressed file, if you use a PC and don't have Mac OS X for X86, don't bother. If you are using an Apple or a Mac OS X for X86 on your PC, double-click the file on your Mac system to unlock it, and if you want to burn the file to a DVD, use Toast to burn the file to a disc: Dmg=>disc image
The command line creates the DMG
Automatically get software version number
The code is as follows |
Copy Code |
App_name= "Soulver" version=$ (/usr/libexec/plistbuddy-c print:cfbundleshortversionstring: "${app_name}.app/contents/info.plist") Dmg_background_img= "Background.png" Vol_name= "${app_name} ${version}" dmg_tmp= "${VOL_NAME}-TEMP.DMG" Dmg_final= "${VOL_NAME}.DMG" Staging_dir= "./install" Create DMG # Clean folder Rm-rf "${staging_dir}" "${dmg_tmp}" "${dmg_final}" # Create folder, copy, Compute mkdir-p "${staging_dir}" CP -RPF "${app_name}.app" "${staging_dir}" size= ' du-sh ' ${staging_dir} ' | sed ' s/([0-9.] *) M (. *)/1/' ' size= ' echo ' ${size} + 1.0 ' | bc | awk ' {print int ($1+0.5)} ' ' # Fault-Tolerant handling If [$-ne 0]; then &N bsp; echo "Error:cannot compute size of staging dir" exit Fi # Create temporary DMG file Hdiutil creat E-srcfolder "${staging_dir}"-volname "${vol_name}"-fs hfs+ -fsargs "-C c=64,a=16,e =16 "-format udrw-size ${size}m" ${dmg_tmp} " echo" Created dmg: ${dmg_tmp} " Set DMG device=$ (Hdiutil attach-readwrite-noverify "${dmg_tmp}" | Egrep ' ^/dev/' | Sed 1q | awk ' {print '} ') Sleep 2 # Add soft links to the applications directory echo "Add link To/applications" Pushd/volumes/"${vol_name}" Ln-s/applications popd # Copy background picture Mkdir/volumes/"${vol_name}"/.background CP "${dmg_background_img}"/volumes/"${vol_name}"/.background/ # Set a series of window properties using AppleScript Echo ' Tell Application "Finder" Tell disk "' ${vol_name} '" Open Set current view of container windows 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 {400, 100, 938, 432} Set Viewoptions to the icon view options of container window Set arrangement of viewoptions to not arranged Set icon size of Viewoptions to 72 Set background picture of viewoptions to file ". Background: ' ${dmg_background_img} '" Set position of item "' ${app_name} '. APP" of container window to {160, 195} Set position of item "Applications" of container window to {360, 195} Close Open Update without registering applications Delay 2 End Tell End Tell ' | Osascript Sync # Uninstall Hdiutil detach "${device}" Compress DMG echo "Creating compressed Image" Hdiutil convert "${dmg_tmp}"-format Udzo-imagekey zlib-level=9-o "${dmg_final}" # Clean Folder Rm-rf "${dmg_tmp}" Rm-rf "${staging_dir}" Echo ' Done. ' Exit |