From: N. Brouard Date: Tue, 25 Oct 2005 12:23:03 +0000 (+0000) Subject: (Module): Creates a dmg disk for MaC OS/X X-Git-Tag: imach-099s7~548 X-Git-Url: https://henry.ined.fr/git/?a=commitdiff_plain;h=688856ab84a80f6bec72c596bdbf4a9b921ad0b6;p=.git (Module): Creates a dmg disk for MaC OS/X --- diff --git a/src/createdmg.sh b/src/createdmg.sh new file mode 100755 index 0000000..559a59e --- /dev/null +++ b/src/createdmg.sh @@ -0,0 +1,43 @@ +#!/bin/bash +set -x +# +# Creates a disk image (dmg) on Mac OS X from the command line. +# usage: +# mkdmg +# +# Where is the name to use for the mounted image, is the version +# number of the volume and is where the contents to put on the dmg are. +# +# The result will be a file called -.dmg + +if [ $# != 3 ]; then + echo "usage: mkdmg.sh volname vers srcdir" + exit 0 +fi + +VOL="$1" +VER="$2" +FILES="$3" + +DMG="tmp-$VOL.dmg" + +# create temporary disk image and format, ejecting when done +#SIZE=`du -sk ${FILES} | sed -n '/^[0-9]*/s/([0-9]*).*/\1/p'` +SIZE=`du -sk ${FILES} | sed -n 's/^\([0-9]*\).*/\1/p'` +echo SIZE=$SIZE +SIZE=$((${SIZE}/1000+1)) +hdiutil create "$DMG" -megabytes ${SIZE} -ov -type UDIF +DISK=`hdid -nomount "$DMG" | sed -ne ' /Apple_partition_scheme/ s|^/dev/\([^ ]*\).*$|\1|p'` +newfs_hfs -v "$VOL" /dev/r${DISK}s2 +hdiutil eject $DISK + +# mount and copy files onto volume +hdid "$DMG" +cp -R "${FILES}"/* "/Volumes/$VOL" +hdiutil eject $DISK +osascript -e "tell application "Finder" to eject disk "$VOL"" && + +# convert to compressed image, delete temp image +rm -f "${VOL}-${VER}.dmg" +hdiutil convert "$DMG" -format UDZO -o "${VOL}-${VER}.dmg" +rm -f "$DMG"