source: sasview/build_tools/dmgpack.sh @ 77e9ac6

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 77e9ac6 was 369ac54, checked in by ajj, 9 years ago

Attempt to add bundling to dmg for mac build

  • Property mode set to 100755
File size: 2.1 KB
Line 
1#! /bin/bash
2
3# dmgpack volume [file|dir]+
4#
5#    Copy a group of files/directories to a compressed disk image.
6#    The resulting image is stored in volume.dmg.
7#
8#    Files are copied with 'ditto' to preserve resource forks.  For
9#    convenience we also call FixupResourceForks after copying.  This
10#    allows you to use /Developer/Tools/SplitFork on your tree and
11#    manipulate it with CVS, tar, etc.  Don't forget the -kb option
12#    when adding or committing app and ._app files to CVS!
13#
14#    This command will fail if a volume of the given name is already
15#    mounted.  It could also fail if the size of the resource forks
16#    is large compared to the size of the data forks. Change the
17#    scale factor internally from 11/10 to a more appropriate number
18#    if it complains it is running out of space.
19#
20#    It is possible to add a license agreement to a dmg file.  See
21#    the "Software License Agreements for UDIFs" sdk available at
22#    http://developer.apple.com/sdk/index.html
23
24test $# -lt 2 && echo "usage: $0 diskname [file|dir]+" && exit 1
25#set -x
26NAME="${1%.dmg}" ; shift
27DISK=/tmp/dmgpack$$.dmg
28COMPRESSED="$NAME.dmg"
29VOLUME="$NAME"
30
31# compute needed image size; scale it by 10%
32SIZE=$(du -ck "$@" | tail -1 | sed -e 's/ *total//')
33SIZE=$(echo $SIZE*11/10 | bc)
34test $SIZE -lt 4200 && SIZE=4200
35
36# create the disk
37rm -f $DISK
38hdiutil create -size ${SIZE}k $DISK -layout NONE
39
40# create a file system on the disk; last line of output is
41# the device on which the disk was attached.
42DEVICE=$(hdiutil attach $DISK -nomount | tail -1)
43newfs_hfs -v "$VOLUME" $DEVICE
44
45# mount the file system
46mkdir $DISK-mount
47mount -t hfs $DEVICE $DISK-mount || (echo "mount $DISK-mount failed" && exit 1)
48
49# copy stuff to the disk and fixup resource forks
50for f in "$@"; do
51    f=${f%/}            ;# strip trailing /
52    dest="$DISK-mount/${f##*/}"
53    ditto -rsrc "$f" "$dest" 
54    test -d "$f" && /System/Library/CoreServices/FixupResourceForks "$dest"
55done
56
57# eject the disk
58umount $DISK-mount
59rmdir $DISK-mount
60hdiutil eject $DEVICE
61
62# compress the disk and make it read only
63rm -f "$COMPRESSED"
64hdiutil convert -format UDZO $DISK -imagekey zlib-level=9 -o "$COMPRESSED"
65rm -f $DISK
Note: See TracBrowser for help on using the repository browser.