Annotation of imach/distributions/osx/createdmg.sh, revision 1.1

1.1     ! brouard     1: #!/bin/bash
        !             2: set -x
        !             3: #
        !             4: # Creates a disk image (dmg) on Mac OS X from the command line.
        !             5: # usage:
        !             6: #    mkdmg <volname> <vers> <srcdir>
        !             7: #
        !             8: # Where <volname> is the name to use for the mounted image, <vers> is the version
        !             9: # number of the volume and <srcdir> is where the contents to put on the dmg are.
        !            10: #
        !            11: # The result will be a file called <volname>-<vers>.dmg
        !            12: 
        !            13: if [ $# != 3 ]; then
        !            14:  echo "usage: mkdmg.sh volname vers srcdir"
        !            15:  exit 0
        !            16: fi
        !            17: 
        !            18: VOL="$1"
        !            19: VER="$2"
        !            20: FILES="$3"
        !            21: 
        !            22: DMG="tmp-$VOL.dmg"
        !            23: 
        !            24: # create temporary disk image and format, ejecting when done
        !            25: #SIZE=`du -sk ${FILES} | sed -n '/^[0-9]*/s/([0-9]*).*/\1/p'`
        !            26: SIZE=`du -sk ${FILES} | sed -n 's/^\([0-9]*\).*/\1/p'`
        !            27: echo SIZE=$SIZE
        !            28: SIZE=$((${SIZE}/1000+1))
        !            29: hdiutil create "$DMG" -megabytes ${SIZE} -ov -type UDIF
        !            30: DISK=`hdid -nomount "$DMG" | sed -ne ' /Apple_partition_scheme/ s|^/dev/\([^ ]*\).*$|\1|p'`
        !            31: newfs_hfs -v "$VOL" /dev/r${DISK}s2
        !            32: hdiutil eject $DISK
        !            33: 
        !            34: # mount and copy files onto volume
        !            35: hdid "$DMG"
        !            36: cp -R "${FILES}"/* "/Volumes/$VOL"
        !            37: hdiutil eject $DISK
        !            38: osascript -e "tell application "Finder" to eject disk "$VOL"" && 
        !            39: 
        !            40: # convert to compressed image, delete temp image
        !            41: rm -f "${VOL}-${VER}.dmg"
        !            42: hdiutil convert "$DMG" -format UDZO -o "${VOL}-${VER}.dmg"
        !            43: rm -f "$DMG"

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>