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