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