move JACK audio backend to its own folder and adjust build system to reflect that...
[ardour.git] / tools / osx_packaging / osx_build
1 #!/bin/bash
2
3 # script for pulling together a MacOSX app bundle.
4
5 GTKSTACK_ROOT=$HOME/gtk/inst
6 ARDOURSTACK_ROOT=$HOME/a3/inst
7 BUILD_ROOT=../../build
8
9 # where harvid and xjadeo binaries are cached
10 if test -z "$CACHEDIR" -o ! -d "$CACHEDIR"; then
11         CACHEDIR=`pwd`
12 fi
13
14 SAE=
15 MIXBUS=
16 WITH_HARVID=
17 WITH_LADSPA=1
18 STRIP=1
19 PRINT_SYSDEPS=
20 WITH_NLS=
21
22 while [ $# -gt 0 ] ; do
23     echo "arg = $1"
24     case $1 in
25
26         #
27         # top level build targets
28         #
29
30         --sae) WITH_NLS= ; 
31                SAE=1 ; 
32                WITH_LADSPA=1; 
33                STRIP= ; 
34                PRODUCT_PKG_DIR=ArdourSAE ; 
35                APPNAME=Ardour ;
36                shift ;;
37         --mixbus) MIXBUS=1; 
38                   WITH_NLS=1 ; 
39                   SAE= ; 
40                   WITH_LADSPA=; 
41                   STRIP= ; 
42                   PRODUCT_PKG_DIR=MixBus;
43                   APPNAME=Mixbus ;
44                   shift ;;
45         --public) WITH_NLS= ; 
46                   SAE= ; 
47                   WITH_LADSPA=1; 
48                   STRIP= ; 
49                   PRODUCT_PKG_DIR=Ardour;
50                   APPNAME=Ardour ;
51                   shift ;;
52         --allinone) SAE= ; 
53                     WITH_NLS= ; 
54                     WITH_LADSPA=1; 
55                     STRIP= ; 
56                     PRODUCT_PKG_DIR=Ardour ;
57                     shift ;;
58         --test) SAE= ; WITH_LADSPA=; STRIP= ; shift ;;
59
60         #
61         # specific build flags
62         #
63
64         --harvid) WITH_HARVID=1 ; shift ;;
65         --noladspa) WITH_LADSPA= ; shift ;;
66         --nostrip) STRIP= ; shift ;;
67         --sysdeps) PRINT_SYSDEPS=1; shift ;;
68         --nls) WITH_NLS=1 ; shift ;;
69     esac
70 done
71
72 if test -z "$PRODUCT_PKG_DIR" -o -z "$APPNAME"; then
73         echo "application or product-name was not specified"
74         exit 1
75 fi
76
77 . ../define_versions.sh
78 echo "Version is $release_version / $revision"
79 info_string="$version built on `hostname` by `whoami` on `date`"
80 echo "Info string is $info_string"
81
82 # setup directory structure
83
84 APPDIR=${APPNAME}.app
85 APPROOT=$APPDIR/Contents
86 Frameworks=$APPROOT/lib
87 Resources=$APPROOT/Resources
88 #
89 # Since this is OS X, don't try to distinguish between etc and shared
90 # (machine dependent and independent data) - just put everything
91 # into Resources.
92
93 Shared=$Resources
94 Etc=$Resources
95 Locale=$Resources/locale
96 #
97 # Bundled Plugins live in a top level folder
98
99 Plugins=$APPROOT/Plugins
100 Surfaces=$Frameworks/surfaces
101 Panners=$Frameworks/panners
102 MidiMaps=$Shared/midi_maps
103 ExportFormats=$Shared/export
104 Templates=$Shared/templates
105 PatchFiles=$Shared/patchfiles
106 MackieControl=$Shared/mcp
107
108 if [ x$PRINT_SYSDEPS != x ] ; then
109 #
110 # print system dependencies
111 #
112
113     for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Plugins/*.so ; do 
114         if ! file $file | grep -qs Mach-O ; then
115             continue
116         fi
117         otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)" 
118     done | sort | uniq
119     exit 0
120 fi
121
122 echo "Removing old $APPDIR tree ..."
123
124 rm -rf $APPDIR
125
126 echo "Building new app directory structure ..."
127
128 # only bother to make the longest paths
129
130 mkdir -p $APPROOT/MacOS
131 mkdir -p $APPROOT/Resources
132 mkdir -p $Plugins
133 mkdir -p $Surfaces
134 mkdir -p $Panners
135 mkdir -p $MidiMaps
136 mkdir -p $ExportFormats
137 mkdir -p $Templates
138 mkdir -p $Frameworks/modules
139 mkdir -p $Etc
140 mkdir -p $MackieControl
141
142 # maybe set variables
143 env=""
144 if test x$SAE != x ; then
145     appname="Ardour3/SAE"
146     env="$env<key>ARDOUR_SAE</key><string>true</string>"
147     #
148     # current default for SAE version is German keyboard layout without a keypad
149     #
150     env="$env<key>ARDOUR_KEYBOARD_LAYOUT</key><string>de-nokeypad</string>"
151     env="$env<key>ARDOUR_UI_CONF</key><string>ardour3_ui_sae.conf</string>"
152     env="$env<key>ARDOUR3_UI_RC</key><string>ardour3_ui_dark_sae.rc</string>"
153 elif test x$MIXBUS != x ; then
154     appname="Ardour3/Mixbus"
155     env="$env<key>ARDOUR_MIXBUS</key><string>true</string>"
156     #
157     # current default for MIXBUS version is US keyboard layout without a keypad
158     #
159     env="$env<key>ARDOUR_KEYBOARD_LAYOUT</key><string>us-nokeypad</string>"
160     env="$env<key>ARDOUR_UI_CONF</key><string>ardour3_ui.conf</string>"
161     env="$env<key>ARDOUR3_UI_RC</key><string>ardour3_ui_dark.rc</string>"
162 else
163     appname="Ardour3"
164 fi
165
166 #
167 # if we're not going to bundle JACK, make sure we can find
168 # jack in the places where it might be
169 #
170
171 env="$env<key>PATH</key><string>/usr/local/bin:/opt/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>"
172 env="$env<key>DYLIB_FALLBACK_LIBRARY_PATH</key><string>/usr/local/lib:/opt/lib</string>"
173
174 env="<key>LSEnvironment</key><dict>$env<key>ARDOUR_BUNDLED</key><string>true</string></dict>"
175
176 # edit plist
177 sed -e "s?@ENV@?$env?g" \
178     -e "s?@VERSION@?$release_version/$revision?g" \
179     -e "s?@INFOSTRING@?$info_string?g" < Info.plist.in > Info.plist
180 # and plist strings
181 sed -e "s?@APPNAME@?$appname?" \
182     -e "s?@ENV@?$env?g" \
183     -e "s?@VERSION@?$release_version/$revision?g" \
184     -e "s?@INFOSTRING@?$info_string?g" < InfoPlist.strings.in > Resources/InfoPlist.strings || exit 1
185
186 # copy static files
187
188 cp Info.plist $APPROOT
189 cp -R Resources $APPROOT
190
191 #
192 # if we build a bundle without jack, then
193 # make the Ardour3 executable a helper
194 # script that checks to see if JACK is
195 # installed.
196 #
197
198 cp startup_script $APPROOT/MacOS/Ardour3
199 chmod 775 $APPROOT/MacOS/Ardour3
200 MAIN_EXECUTABLE=Ardour3.bin
201
202 echo "Copying ardour executable ...."
203 cp $BUILD_ROOT/gtk2_ardour/ardour-$release_version $APPROOT/MacOS/$MAIN_EXECUTABLE
204 if test x$SAE != x ; then
205     # cp $BUILD_ROOT/gtk2_ardour/evtest $APPROOT/MacOS/gtkevents
206     cp  Ardour3-SAE.icns $Resources/appIcon.icns
207 elif test x$MIXBUS != x ; then
208     cp  Mixbus.icns $Resources/appIcon.icns
209 else
210     cp  Ardour3.icns $Resources/appIcon.icns
211 fi
212 cp  typeArdour.icns $Resources/
213 if test x$STRIP != x ; then
214     strip $APPROOT/MacOS/Ardour3
215 fi
216
217 # copy locale files
218 if test x$WITH_NLS != x ; then
219     echo "NLS support ..."
220     echo "I hope you remembered to run scons msgupdate!"
221     LINGUAS=
222     for file in $BUILD_ROOT/gtk2_ardour/*.mo 
223     do
224         lang=`basename $file | sed 's/\.mo//'`
225         mkdir -p $Locale/$lang/LC_MESSAGES
226         cp $file $Locale/$lang/LC_MESSAGES/gtk2_ardour.mo
227         LINGUAS="$LINGUAS $lang"
228     done
229     for file in $BUILD_ROOT/libs/ardour/*.mo 
230     do
231         lang=`basename $file | sed 's/\.mo//'`
232         mkdir -p $Locale/$lang/LC_MESSAGES
233         cp $file $Locale/$lang/LC_MESSAGES/libardour.mo
234     done
235     for l in $LINGUAS
236     do
237       if [ -d $GTKSTACK_ROOT/share/locale/$l ] ; then
238           echo "Copying GTK i18n files for $l..."
239           cp -r $GTKSTACK_ROOT/share/locale/$l $Locale
240       else
241           # try with just the language spec
242           just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
243           if [ -d $GTKSTACK_ROOT/share/locale/$just_lang ] ; then
244               echo "Copying GTK i18n files for $l..."
245               cp -r $GTKSTACK_ROOT/share/locale/$just_lang $Locale
246           fi
247       fi
248     done
249 else
250     echo "Skipping NLS support"
251 fi
252
253 #
254 # Copy stuff that may be dynamically loaded
255
256
257 cp -R $GTKSTACK_ROOT/etc/* $Etc
258 echo "Copying all Pango modules ..."
259 cp -R $GTKSTACK_ROOT/lib/pango/1.6.0/modules/*.so $Frameworks/modules
260 echo "Copying all GDK Pixbuf loaders ..."
261 cp -R $GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/loaders/*.so $Frameworks/modules
262 # charset alias file
263 cp -R $GTKSTACK_ROOT/lib/charset.alias $Resources
264
265 # generate new Pango module file
266 cat > pangorc <<EOF 
267 [Pango]
268 ModulesPath=$GTKSTACK_ROOT/lib/pango/1.6.0/modules
269 EOF
270 env PANGO_RC_FILE=pangorc $GTKSTACK_ROOT/bin/pango-querymodules | sed "s?$GTKSTACK_ROOT/lib/pango/1.6.0/modules/?@executable_path/../lib/modules/?" > $Resources/pango.modules
271 rm pangorc
272
273 # generate a new GDK pixbufs loaders file
274 gdk-pixbuf-query-loaders | sed "s?$GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/loaders/?@executable_path/../lib/modules/?" > $Resources/gdk-pixbuf.loaders
275
276 # We rely on clearlooks, so include a version from our own build tree
277 # this one is special - we will set GTK_PATH to $Frameworks/gtkengines
278
279 GTK_ENGINE_DIR=$Frameworks/gtkengines/engines
280 mkdir -p $GTK_ENGINE_DIR
281
282 echo "Copying GTK engines ..."
283 cp $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.dylib $Frameworks
284 (cd $GTK_ENGINE_DIR && ln -s ../../libclearlooks.dylib . && ln -s ../../libclearlooks.dylib libclearlooks.so)
285
286 cp $GTKSTACK_ROOT/lib/gtk-2.0/2.10.0/engines/libpixmap.so $Frameworks
287 (cd $GTK_ENGINE_DIR && ln -s ../../libpixmap.so)
288
289
290 if test x$WITH_LADSPA != x ; then
291     if test x$SAE != x ; then
292         plugdir=sae_ladspa
293     elif test x$MIXBUS != x ; then
294         plugdir=mixbus_ladspa
295     else
296         plugdir=ladspa
297     fi
298     if [ -d $plugdir -a "x$(ls $plugdir)" != x ] ; then 
299         echo "Copying `ls $plugdir | wc -l` plugins ..."
300         cp -r $plugdir/* $Plugins
301     fi
302 fi
303
304 # Control Surface shared libraries
305 cp $BUILD_ROOT/libs/surfaces/*/libardour_*.dylib $Surfaces
306 cp $BUILD_ROOT/libs/surfaces/control_protocol/libardourcp*.dylib $Frameworks
307
308 # Panners
309 cp $BUILD_ROOT/libs/panners/*/lib*.dylib $Panners
310
311
312 # Export Formats/Presets
313 for f in $BUILD_ROOT/../export/*.preset $BUILD_ROOT/../export/*.format ; do 
314     cp "$f" $ExportFormats ; 
315 done
316
317 # Session and Route templates
318 #for f in $BUILD_ROOT/../templates/* ; do 
319 #    if [ -d "$f" ] ; then
320 #        cp -r "$f" $Templates ; 
321 #    fi
322 #done
323
324 # MidiMaps
325 # got to be careful with names here
326 for x in $BUILD_ROOT/../midi_maps/*.map ; do
327     cp "$x" $MidiMaps
328 done
329
330 # MIDNAM Patch Files
331 # got to be careful with names here
332 for x in $BUILD_ROOT/../patchfiles/*.midnam ; do
333     cp "$x" $PatchFiles
334 done
335
336 # MackieControl data
337 # got to be careful with names here
338 for x in $BUILD_ROOT/../mcp/*.device $BUILD_ROOT/../mcp/*.profile ; do
339     cp "$x" $MackieControl
340 done
341
342 # VAMP plugins that we use
343 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.dylib $Frameworks
344
345 # Suil modules
346 cp $ARDOURSTACK_ROOT/lib/suil-0/lib* $Frameworks
347
348 while [ true ] ; do 
349     missing=false
350     for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Panners/*.dylib $Surfaces/*.dylib $Plugins/*.so ; do 
351         if ! file $file | grep -qs Mach-O ; then
352             continue
353         fi
354         deps=`otool -L $file | awk '{print $1}' | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | grep -v 'libjack\.'`
355         # echo -n "."
356         for dep in $deps ; do
357             base=`basename $dep`
358             if ! test -f $Frameworks/$base; then
359                 if echo $dep | grep -sq '^libs' ; then
360                     cp $BUILD_ROOT/$dep $Frameworks
361                 else
362                     cp $dep $Frameworks
363                 fi
364                 missing=true
365             fi
366         done
367     done
368     if test x$missing = xfalse ; then
369         # everything has been found
370         break
371     fi
372 done
373 echo
374
375 echo "Copying other stuff to $APPDIR  ..."
376
377 #cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings  $Resources
378
379 cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings  $Resources
380 cp ../../gtk2_ardour/mixer.bindings $Resources
381 cp ../../gtk2_ardour/step_editing.bindings $Resources
382 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Resources
383
384 if test x$SAE != x ; then
385     cp $BUILD_ROOT/gtk2_ardour/SAE-de-keypad.bindings  $Resources
386     cp $BUILD_ROOT/gtk2_ardour/SAE-de-nokeypad.bindings  $Resources
387     cp $BUILD_ROOT/gtk2_ardour/SAE-us-keypad.bindings  $Resources
388     cp $BUILD_ROOT/gtk2_ardour/SAE-us-nokeypad.bindings  $Resources
389     cp $BUILD_ROOT/ardour_system_sae.rc $Resources/ardour_system.rc
390     echo cp $BUILD_ROOT/ardour_system_sae.rc $Resources/ardour_system.rc
391     cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml
392     echo cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml
393 else
394     cp ../../ardour_system.rc $Resources/ardour_system.rc
395     cp ../../instant.xml $Resources/instant.xml
396     echo cp ../../instant.xml $Resources/instant.xml
397 fi
398 cp ../../gtk2_ardour/ardour3_ui_default.conf $Resources
399 cp ../../gtk2_ardour/ardour3_ui_default.conf $Resources/ardour3_ui.conf
400 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_light.rc $Resources
401 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_dark.rc $Resources
402
403 cp -r ../../gtk2_ardour/icons $Resources
404 cp -r ../../gtk2_ardour/pixmaps $Resources
405
406 # shared stuff
407 cp -R ../../gtk2_ardour/splash.png $Shared
408 cp -R ../../gtk2_ardour/ArdourMono.ttf $Shared
409
410 # go through and recursively remove any .svn dirs in the bundle
411 for svndir in `find $APPDIR -name .svn -type dir`; do
412     rm -rf $svndir
413 done
414
415 # now fix up the executables
416 echo "Fixing up executable dependency names ..."
417 executables=$MAIN_EXECUTABLE
418 if test x$SAE != x ; then
419     executables="$executables"
420 fi
421
422 for exe in $executables; do
423     EXE=$APPROOT/MacOS/$exe
424     changes=""
425     for lib in `otool -L $EXE | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
426       base=`basename $lib`
427       changes="$changes -change $lib @executable_path/../lib/$base"
428     done
429     if test "x$changes" != "x" ; then
430         install_name_tool $changes $EXE
431     fi
432 done
433
434 echo "Fixing up library names ..."
435 # now do the same for all the libraries we include
436 for libdir in $Frameworks $Frameworks/modules $Surfaces $Panners ; do
437
438     libbase=`basename $libdir`
439     
440     for dylib in $libdir/*.dylib $libdir/*.so ; do
441         
442        # skip symlinks
443         
444         if test -L $dylib ; then
445             continue
446         fi
447         
448         # change all the dependencies
449         
450         changes=""
451         for lib in `otool -L $dylib | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
452             base=`basename $lib`
453             if echo $lib | grep -s libbase; then
454                 changes="$changes -change $lib @executable_path/../$libbase/$base"
455             else
456                 changes="$changes -change $lib @executable_path/../lib/$base"
457             fi
458         done
459         
460         if test "x$changes" != x ; then
461             if  install_name_tool $changes $dylib ; then
462                 :
463             else
464                 exit 1
465             fi
466         fi
467         
468         # now the change what the library thinks its own name is
469         
470         base=`basename $dylib`
471         install_name_tool -id @executable_path/../$libbase/$base $dylib
472     done
473 done
474
475 #
476 # and now ... the DMG
477
478
479 rm -rf $PRODUCT_PKG_DIR
480 mkdir $PRODUCT_PKG_DIR
481
482 DMGWINBOTTOM=440
483 DMGBACKGROUND=dmgbg.png
484
485 if [ x$SAE != x ] ; then
486         
487     # SAE packaging
488     
489     echo "Creating SAE packaging directory"
490     mv $APPDIR $PRODUCT_PKG_DIR/Ardour3-SAE.app
491     cp HowToInstallArdourSAE.pdf "$PRODUCT_PKG_DIR/How To Install Ardour SAE.pdf"
492     cp SAE-de-keypad.pdf "$PRODUCT_PKG_DIR/Ardour SAE Shortcuts (keypad).pdf"
493     cp SAE-de-nokeypad.pdf "$PRODUCT_PKG_DIR/Ardour SAE Shortcuts.pdf"
494     
495 elif [ x$MIXBUS != x ] ; then
496
497      # Mixbus packaging
498
499     echo "Creating Mixbus packaging directory"
500     mv $APPDIR $PRODUCT_PKG_DIR/
501     cp MixBus_Install_QuickStart.pdf "$PRODUCT_PKG_DIR/Mixbus Install & Quick Start Guide.pdf"
502                 DMGWINBOTTOM=580
503                 YPOS=$[ $DMGWINBOTTOM - 300 ]
504                 MIXBUSPOS="set position of item \"MixBus_Install_QuickStart.pdf\" of container window to {90, ${YPOS}}"
505 else 
506
507     echo "Creating $APPNAME packaging directory"
508     mv $APPDIR $PRODUCT_PKG_DIR/
509
510 fi
511
512 if test x$WITH_HARVID != x ; then
513         echo "installing video tools.."
514         HARVID_VERSION=$(curl -s -S http://ardour.org/files/video-tools/harvid_version.txt)
515         XJADEO_VERSION=$(curl -s -S http://ardour.org/files/video-tools/xjadeo_version.txt)
516         echo "copying harvid and xjadeo ..."
517
518         rsync -Pa \
519                 rsync://ardour.org/video-tools/harvid-osx-${HARVID_VERSION}.tgz \
520                 "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz"
521
522         rsync -Pa \
523                 rsync://ardour.org/video-tools/jadeo-${XJADEO_VERSION:1}.dmg \
524                 "$CACHEDIR/jadeo-${XJADEO_VERSION:1}.dmg"
525
526         tar -x -z \
527                 -C $PRODUCT_PKG_DIR/$APPROOT \
528                 -f "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz" || exit 1
529
530         JADEO=$(hdiutil attach "$CACHEDIR/jadeo-${XJADEO_VERSION:1}.dmg" | grep Apple_HFS | grep dev/ | cut -f 3)
531         cp -r "${JADEO}/Jadeo.app" "$PRODUCT_PKG_DIR/"
532         hdiutil detach "${JADEO}"
533
534         DMGWINBOTTOM=580
535         YPOS=$[ $DMGWINBOTTOM - 300 ]
536         XJADEOPOS="set position of item \"Jadeo.app\" of container window to {310, ${YPOS}}"
537
538         DMGBACKGROUND=dmgbgxj.png
539 fi
540
541 echo "Building DMG ..."
542
543 # UC_DMG=$APPNAME-${release_version}-${revision}-UC.dmg
544 # FINAL_DMG=$APPNAME-${release_version}-${revision}.dmg
545 UC_DMG=$APPNAME-$version.dmg
546 VOLNAME=$APPNAME-$version
547
548 # TODO use mktemp
549 export TMPDIR=`pwd`
550 MNTPATH=`mktemp -d -t /ardourimg`
551 TMPDMG=`mktemp -t ardour`
552 ICNSTMP=`mktemp -t ardouricon`
553 EXTRA_SPACE_MB=30
554 DMGMEGABYTES=$[ `du -sk "$PRODUCT_PKG_DIR" | cut -f 1` * 1024 / 1048576 + $EXTRA_SPACE_MB ]
555
556 echo "DMG MB = " $DMGMEGABYTES
557
558 rm -f $UC_DMG "$TMPDMG" "${TMPDMG}.dmg" "$ICNSTMP"
559 rm -rf "$MNTPATH"
560 mkdir -p "$MNTPATH"
561
562 TMPDMG="${TMPDMG}.dmg"
563
564 hdiutil create -megabytes $DMGMEGABYTES "$TMPDMG"
565 DiskDevice=$(hdid -nomount "$TMPDMG" | grep Apple_HFS | cut -f 1 -d ' ')
566 newfs_hfs -v "${VOLNAME}" "${DiskDevice}"
567 mount -t hfs "${DiskDevice}" "${MNTPATH}"
568
569 cp -r ${PRODUCT_PKG_DIR}/* "${MNTPATH}" || exit
570 mkdir "${MNTPATH}/.background"
571 cp -vi ${DMGBACKGROUND} "${MNTPATH}/.background/dmgbg.png"
572
573 echo "setting DMG background ..."
574
575 echo '
576    tell application "Finder"
577      tell disk "'${VOLNAME}'"
578            open
579            set current view of container window to icon view
580            set toolbar visible of container window to false
581            set statusbar visible of container window to false
582            set the bounds of container window to {400, 200, 800, '${DMGWINBOTTOM}'}
583            set theViewOptions to the icon view options of container window
584            set arrangement of theViewOptions to not arranged
585            set icon size of theViewOptions to 64
586            set background picture of theViewOptions to file ".background:dmgbg.png"
587            make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"}
588            set position of item "'${APPDIR}'" of container window to {90, 100}
589            set position of item "Applications" of container window to {310, 100}
590            '${MIXBUSPOS}'
591            '${HARVIDPOS}'
592            '${XJADEOPOS}'
593            close
594            open
595            update without registering applications
596            delay 5
597            eject
598      end tell
599    end tell
600 ' | osascript
601
602 chmod -Rf go-w "${MNTPATH}"
603 sync
604
605 echo "compressing Image ..."
606
607 # Umount the image
608 umount "${DiskDevice}"
609 hdiutil eject "${DiskDevice}"
610 # Create a read-only version, use zlib compression
611 hdiutil convert -format UDZO "${TMPDMG}" -imagekey zlib-level=9 -o "${UC_DMG}"
612 # Delete the temporary files
613 rm "$TMPDMG"
614 rm -rf "$MNTPATH"
615
616 echo "setting file icon ..."
617
618 cp ${PRODUCT_PKG_DIR}/$Resources/appIcon.icns ${ICNSTMP}.icns
619 /usr/bin/sips -i ${ICNSTMP}.icns
620 /Developer/Tools/DeRez -only icns ${ICNSTMP}.icns > ${ICNSTMP}.rsrc
621 /Developer/Tools/Rez -append ${ICNSTMP}.rsrc -o "$UC_DMG"
622 /Developer/Tools/SetFile -a C "$UC_DMG"
623
624 rm ${ICNSTMP}.icns ${ICNSTMP}.rsrc
625
626 echo
627 echo "packaging suceeded."
628 ls -l "$UC_DMG"
629
630 echo "Done."
631 exit