more harrison packaging
[ardour.git] / tools / osx_packaging / osx_build
1 #!/bin/bash
2
3 set -e
4
5 # script for pulling together a MacOSX app bundle.
6
7 GTKSTACK_ROOT=$HOME/gtk/inst
8 ARDOURSTACK_ROOT=$HOME/a3/inst
9 BUILD_ROOT=../../build
10
11 # where harvid and xjadeo binaries are cached
12 if test -z "$CACHEDIR" -o ! -d "$CACHEDIR"; then
13         CACHEDIR=/var/tmp
14 fi
15 mkdir -p "$CACHEDIR"
16
17 SAE=
18 MIXBUS=
19 MIXBUS32C=
20 WITH_HARVID=1
21 WITH_HARRISON_LV2=
22 WITH_X42_LV2=
23 WITH_LADSPA=1
24 STRIP=1
25 PRINT_SYSDEPS=
26 WITH_NLS=
27
28 : ${HARRISONCHANNELSTRIP=harrison_channelstrip}
29
30 . ../define_versions.sh
31
32 while [ $# -gt 0 ] ; do
33     echo "arg = $1"
34     case $1 in
35
36         #
37         # top level build targets
38         #
39
40         --sae)
41                 SAE=1 ;
42                 WITH_LADSPA=1;
43                 STRIP= ;
44                 PRODUCT_PKG_DIR=ArdourSAE ;
45                 APPNAME=Ardour ;
46                 shift ;;
47         --mixbus) MIXBUS=1;
48                 WITH_HARRISON_LV2=1 ;
49                 WITH_X42_LV2=1 ;
50                 WITH_NLS=1 ;
51                 SAE= ;
52                 WITH_LADSPA=;
53                 STRIP= ;
54                 PRODUCT_PKG_DIR=Mixbus;
55                 APPNAME=Mixbus ;
56                 shift ;;
57         --mixbus32c) MIXBUS=1;
58                 MIXBUS32C=1;
59                 WITH_HARRISON_LV2=1 ;
60                 WITH_X42_LV2=1 ;
61                 WITH_NLS=1 ;
62                 SAE= ;
63                 WITH_LADSPA=;
64                 STRIP= ;
65                 PRODUCT_PKG_DIR=Mixbus32C;
66                 APPNAME=Mixbus32C-${major_version} ;
67                 major_version=""
68                 shift ;;
69         --public)
70                 SAE= ;
71                 WITH_LADSPA=1;
72                 PRODUCT_PKG_DIR=Ardour;
73                 APPNAME=Ardour ;
74                 shift ;;
75         --allinone) SAE= ;
76                 WITH_LADSPA=1;
77                 STRIP= ;
78                 PRODUCT_PKG_DIR=Ardour ;
79                 shift ;;
80         --test) SAE= ; WITH_LADSPA=; STRIP= ; shift ;;
81
82         #
83         # specific build flags
84         #
85
86         --noharvid) WITH_HARVID= ; shift ;;
87         --noladspa) WITH_LADSPA= ; shift ;;
88         --nostrip) STRIP= ; shift ;;
89         --sysdeps) PRINT_SYSDEPS=1; shift ;;
90         --nls) WITH_NLS=1 ; shift ;;
91         --chanstrip) HARRISONCHANNELSTRIP=$2 ; shift; shift ;;
92     esac
93 done
94
95 if test -z "$PRODUCT_PKG_DIR" -o -z "$APPNAME"; then
96         echo "application or product-name was not specified"
97         exit 1
98 fi
99
100 echo "Version is $release_version"
101 if [ "x$commit" != "x" ] ; then
102     info_string="$release_version ($commit) built on `hostname` by `whoami` on `date`"
103 else
104     info_string="$release_version built on `hostname` by `whoami` on `date`"
105 fi
106 echo "Info string is $info_string"
107
108 if [ x$DEBUG = xT ]; then
109         STRIP=
110         echo "Debug build, strip disabled"
111 else
112         if test x$STRIP != x ; then
113                 echo "No debug build, strip enabled"
114         else
115                 echo "No debug build, but strip disabled."
116         fi
117 fi
118
119 # setup directory structure
120
121 APPDIR=${APPNAME}${major_version}.app
122 APPROOT=$APPDIR/Contents
123 Frameworks=$APPROOT/lib
124 Resources=$APPROOT/Resources
125 #
126 # Since this is OS X, don't try to distinguish between etc and shared
127 # (machine dependent and independent data) - just put everything
128 # into Resources.
129
130 Shared=$Resources
131 Etc=$Resources
132 Locale=$Resources/locale
133 #
134 # Bundled Plugins live in a top level folder
135
136 Plugins=$APPROOT/Plugins
137 Surfaces=$Frameworks/surfaces
138 Panners=$Frameworks/panners
139 Backends=$Frameworks/backends
140 MidiMaps=$Shared/midi_maps
141 ExportFormats=$Shared/export
142 Templates=$Shared/templates
143 PatchFiles=$Shared/patchfiles
144 LuaScripts=$Shared/scripts
145 MackieControl=$Shared/mcp
146
147 if [ x$PRINT_SYSDEPS != x ] ; then
148 #
149 # print system dependencies
150 #
151
152 for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Plugins/*.so ; do
153         if ! file $file | grep -qs Mach-O ; then
154             continue
155         fi
156         otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)" 
157     done | sort | uniq
158     exit 0
159 fi
160
161 echo "Removing old $APPDIR tree ..."
162
163 rm -rf $APPDIR
164
165 echo "Building new app directory structure ..."
166
167 # only bother to make the longest paths
168
169 mkdir -p $APPROOT/MacOS
170 mkdir -p $APPROOT/Resources
171 mkdir -p $Plugins
172 mkdir -p $Surfaces
173 mkdir -p $Panners
174 mkdir -p $Backends
175 mkdir -p $MidiMaps
176 mkdir -p $ExportFormats
177 mkdir -p $Templates
178 mkdir -p $Frameworks/modules
179 mkdir -p $Etc
180 mkdir -p $MackieControl
181 mkdir -p $PatchFiles
182 mkdir -p $LuaScripts
183
184 # maybe set variables
185 env=""
186 if test x$SAE != x ; then
187     appname="Ardour${major_version}-SAE"
188     EXECUTABLE=${appname}
189     env="$env<key>ARDOUR_SAE</key><string>true</string>"
190     #
191     # current default for SAE version is German keyboard layout without a keypad
192     #
193     env="$env<key>ARDOUR_KEYBOARD_LAYOUT</key><string>de-nokeypad</string>"
194     env="$env<key>ARDOUR_UI_CONF</key><string>ardour3_ui_sae.conf</string>"
195 elif test x$MIXBUS != x ; then
196     appname=$APPNAME
197     EXECUTABLE=${appname}${major_version}
198     env="$env<key>ARDOUR_MIXBUS</key><string>true</string>"
199     #
200     # current default for MIXBUS version is US keyboard layout without a keypad
201     #
202     env="$env<key>ARDOUR_KEYBOARD_LAYOUT</key><string>us-nokeypad</string>"
203     env="$env<key>ARDOUR_UI_CONF</key><string>ardour3_ui.conf</string>"
204 else
205     appname="Ardour${major_version}"
206     EXECUTABLE=${appname}
207 fi
208
209 #
210 # if we're not going to bundle JACK, make sure we can find
211 # jack in the places where it might be
212 #
213
214 env="$env<key>PATH</key><string>/usr/local/bin:/opt/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>"
215 env="$env<key>DYLIB_FALLBACK_LIBRARY_PATH</key><string>/usr/local/lib:/opt/lib</string>"
216
217 env="<key>LSEnvironment</key><dict>$env<key>ARDOUR_BUNDLED</key><string>true</string></dict>"
218
219
220 # edit plist
221 sed -e "s?@ENV@?$env?g" \
222     -e "s?@VERSION@?$release_version?g" \
223     -e "s?@INFOSTRING@?$info_string?g" \
224     -e "s?@IDSUFFIX@?$EXECUTABLE?g" \
225     -e "s?@BUNDLENAME@?${APPNAME}${major_version}?g" \
226     -e "s?@EXECUTABLE@?$EXECUTABLE?g" < Info.plist.in > Info.plist
227 # and plist strings
228 sed -e "s?@APPNAME@?$appname?" \
229     -e "s?@ENV@?$env?g" \
230     -e "s?@VERSION@?$release_version?g" \
231     -e "s?@INFOSTRING@?$info_string?g" < InfoPlist.strings.in > Resources/InfoPlist.strings || exit 1
232
233 # copy static files
234
235 cp Info.plist $APPROOT
236 cp -R Resources $APPROOT
237
238 # ..and clean up
239 rm -f Info.plist
240 rm -f Resources/InfoPlist.strings
241
242 #
243 # if we build a bundle without jack, then
244 # make the Ardour executable a helper
245 # script that checks to see if JACK is
246 # installed.
247 #
248
249 cp startup_script $APPROOT/MacOS/$EXECUTABLE
250 chmod 775 $APPROOT/MacOS/$EXECUTABLE
251 MAIN_EXECUTABLE=Ardour.bin  ## used in startup_script
252
253 echo "Copying ardour executable ...."
254 cp $BUILD_ROOT/gtk2_ardour/ardour-$release_version $APPROOT/MacOS/$MAIN_EXECUTABLE
255 if test x$SAE != x ; then
256     # cp $BUILD_ROOT/gtk2_ardour/evtest $APPROOT/MacOS/gtkevents
257     cp  Ardour3-SAE.icns $Resources/appIcon.icns
258 elif test x$MIXBUS32C != x ; then
259     cp  Mixbus32C.icns $Resources/appIcon.icns
260 elif test x$MIXBUS != x ; then
261     cp  Mixbus.icns $Resources/appIcon.icns
262 else
263     cp  Ardour.icns $Resources/appIcon.icns
264 fi
265 cp  typeArdour.icns $Resources/
266
267 set +e # things below are not error-free (optional files etc) :(
268
269 # copy locale files
270 if test x$WITH_NLS != x ; then
271     echo "NLS support ..."
272     echo "I hope you remembered to run waf i18n"
273     LINGUAS=
274
275     for pkg in gtk2_ardour libs/ardour libs/gtkmm2ext ; do 
276         files=`find ../../$pkg -name "*.mo"`
277         
278             #
279             # the package name is appended with a number so that
280             # it can be parallel installed during a regular install
281             # with older (and newer) versions. it is just the major
282             # number of the release (i.e. leading digits)
283             #
284         
285         vsuffix=`echo $release_version | sed 's/^\([0-9][0-9]*\).*/\1/'`
286         
287         if [ -z "$files" ]; then
288             echo ""
289             echo "!!!! WARNING !!!! - Did not find any .mo files in ../../$pkg"
290             echo ""
291         fi
292         
293         for file in $files 
294         do
295             echo $file
296             lang=`basename $file | sed 's/\.mo//'`
297             mkdir -p $Locale/$lang/LC_MESSAGES
298             cp $file $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
299             echo copy $file to $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
300             if echo $LINGUAS | grep $lang >/dev/null 2>&1 ; then
301                 :
302             else 
303                 LINGUAS="$LINGUAS $lang"
304             fi
305         done
306     done
307
308     for l in $LINGUAS
309     do
310       if [ -d $GTKSTACK_ROOT/share/locale/$l ] ; then
311           echo "Copying GTK i18n files for $l..."
312           cp -r $GTKSTACK_ROOT/share/locale/$l $Locale
313       else
314           # try with just the language spec
315           just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
316           if [ -d $GTKSTACK_ROOT/share/locale/$just_lang ] ; then
317               echo "Copying GTK i18n files for $l..."
318               cp -r $GTKSTACK_ROOT/share/locale/$just_lang $Locale
319           fi
320       fi
321     done
322 else
323     echo "Skipping NLS support"
324 fi
325
326 #
327 # Copy stuff that may be dynamically loaded
328
329
330 cp -R $GTKSTACK_ROOT/etc/* $Etc
331 cp -R $GTKSTACK_ROOT/lib/charset.alias $Resources
332
333 # We rely on clearlooks, so include a version from our own build tree
334 # this one is special - we will set GTK_PATH to $Frameworks/gtkengines
335
336 GTK_ENGINE_DIR=$Frameworks/gtkengines/engines
337 mkdir -p $GTK_ENGINE_DIR
338
339 echo "Copying GTK engines ..."
340 cp $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.dylib $Frameworks
341 (cd $GTK_ENGINE_DIR && ln -s ../../libclearlooks.dylib . && ln -s ../../libclearlooks.dylib libclearlooks.so)
342
343 cp $GTKSTACK_ROOT/lib/gtk-2.0/2.10.0/engines/libpixmap.so $Frameworks
344 (cd $GTK_ENGINE_DIR && ln -s ../../libpixmap.so)
345
346
347 if test x$WITH_LADSPA != x ; then
348     if test x$SAE != x ; then
349         plugdir=sae_ladspa
350     elif test x$MIXBUS != x ; then
351         plugdir=mixbus_ladspa
352     else
353         plugdir=ladspa
354     fi
355     if [ -d $plugdir -a "x$(ls $plugdir)" != x ] ; then 
356         echo "Copying `ls $plugdir | wc -l` plugins ..."
357         cp -r $plugdir/* $Plugins
358     fi
359 fi
360
361 # Control Surface shared libraries
362 cp $BUILD_ROOT/libs/surfaces/*/libardour_*.dylib $Surfaces
363 cp $BUILD_ROOT/libs/surfaces/control_protocol/libardourcp*.dylib $Frameworks
364
365 # Panners
366 cp $BUILD_ROOT/libs/panners/*/lib*.dylib $Panners
367
368 # Backends
369 for backend in jack wavesaudio dummy coreaudio; do
370     cp $BUILD_ROOT/libs/backends/$backend/lib*.dylib $Backends
371 done
372
373 # Export Formats/Presets
374 for f in $BUILD_ROOT/../export/*.preset $BUILD_ROOT/../export/*.format ; do 
375     cp "$f" $ExportFormats ; 
376 done
377
378 # Session and Route templates
379 #for f in $BUILD_ROOT/../templates/* ; do 
380 #    if [ -d "$f" ] ; then
381 #        cp -r "$f" $Templates ; 
382 #    fi
383 #done
384
385 # MidiMaps
386 # got to be careful with names here
387 for x in $BUILD_ROOT/../midi_maps/*.map ; do
388     cp "$x" $MidiMaps
389 done
390
391 # MIDNAM Patch Files
392 # got to be careful with names here
393 for x in $BUILD_ROOT/../patchfiles/*.midnam ; do
394     cp "$x" $PatchFiles
395 done
396
397 # Lua Script Files
398 # got to be careful with names here
399 for x in $BUILD_ROOT/../scripts/*.lua ; do
400     cp "$x" $LuaScripts
401 done
402
403 # MackieControl data
404 # got to be careful with names here
405 for x in $BUILD_ROOT/../mcp/*.device $BUILD_ROOT/../mcp/*.profile ; do
406     cp "$x" $MackieControl
407 done
408
409 # VAMP plugins that we use
410 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.dylib $Frameworks
411
412 # Suil modules (new dir 'build-stack')
413 if test -d $GTKSTACK_ROOT/lib/suil-0/ ; then
414     cp $GTKSTACK_ROOT/lib/suil-0/lib* $Frameworks
415 fi
416
417 # Suil modules (old dir 'build-ardour-stack')
418 if test -d $ARDOURSTACK_ROOT/lib/suil-0/ ; then
419     cp $ARDOURSTACK_ROOT/lib/suil-0/lib* $Frameworks
420 fi
421
422 # VST scanner app and wrapper script, if they exist
423 if test -d $BUILD_ROOT/libs/fst ; then
424     cp $BUILD_ROOT/libs/fst/ardour-vst-scanner* $Frameworks/
425 fi
426
427 # vfork wrapper
428 if test -f $BUILD_ROOT/libs/vfork/ardour-exec-wrapper ; then
429     mkdir -p $Frameworks/vfork
430     cp $BUILD_ROOT/libs/vfork/ardour-exec-wrapper $Frameworks/
431 fi
432
433 # TODO check if this is still needed, even when building on 10.5
434 if file $BUILD_ROOT/gtk2_ardour/ardour-$release_version | grep -q ppc; then
435 STDCPP='|libstdc\+\+'
436 else
437 STDCPP=
438 fi
439
440 while [ true ] ; do 
441     missing=false
442     for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Panners/*.dylib $Backends/*.dylib $Surfaces/*.dylib $Plugins/*.so ; do 
443         if ! file $file | grep -qs Mach-O ; then
444             continue
445         fi
446         # libffi contains "S" (other section symbols) that should not be stripped.
447         if [[ $file == *"libffi"* ]] ; then
448             continue
449         fi
450
451         if test x$STRIP != x ; then
452                 strip -u -r -arch all $file &>/dev/null
453         fi
454
455         deps=`otool -L $file | awk '{print $1}' | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/$STDCPP)" | grep -v 'libjack\.' | grep -v "$(basename $file)"`
456         # echo -n "."
457         for dep in $deps ; do
458             base=`basename $dep`
459             if ! test -f $Frameworks/$base; then
460                 if echo $dep | grep -sq '^libs' ; then
461                     cp $BUILD_ROOT/$dep $Frameworks
462                 else
463                     cp $dep $Frameworks
464                 fi
465                 missing=true
466             fi
467         done
468     done
469     if test x$missing = xfalse ; then
470         # everything has been found
471         break
472     fi
473 done
474 echo
475
476 echo "Copying other stuff to $APPDIR  ..."
477
478 cp $BUILD_ROOT/gtk2_ardour/ardour.keys  $Resources
479 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Resources
480 cp $BUILD_ROOT/gtk2_ardour/default_ui_config $Resources
481 cp $BUILD_ROOT/gtk2_ardour/clearlooks.rc $Resources
482
483 # Copied directly from source tree
484
485 mkdir ${Resources}/icons
486 mkdir ${Resources}/resources
487 cp ../../system_config $Resources/system_config
488 cp ../../instant.xml $Resources/instant.xml
489 cp ../../gtk2_ardour/icons/*.png ${Resources}/icons/
490 cp -r ../../gtk2_ardour/icons/cursor_* ${Resources}/icons/
491 cp ../../gtk2_ardour/*.colors $Resources
492 cp ../../gtk2_ardour/ArdourMono.ttf $Shared
493 cp ../../gtk2_ardour/resources/${PRODUCT_PKG_DIR}-* ${Resources}/resources/
494
495 # go through and recursively remove any .svn dirs in the bundle
496 for svndir in `find $APPDIR -name .svn -type dir`; do
497     rm -rf $svndir
498 done
499
500 # install bundled LV2s to <app>/Contents/lib/LV2/
501 cp -R $BUILD_ROOT/libs/LV2 $Frameworks/
502
503 # lv2 core, classifications etc - TODO check if we need the complete LV2 ontology
504 if test -d $ARDOURSTACK_ROOT/lib/lv2/lv2core.lv2 ; then
505         cp -R $ARDOURSTACK_ROOT/lib/lv2/lv2core.lv2 $Frameworks/LV2/
506 elif test -d $GTKSTACK_ROOT/lib/lv2/lv2core.lv2 ; then
507         cp -R $GTKSTACK_ROOT/lib/lv2/lv2core.lv2 $Frameworks/LV2/
508 fi
509
510
511 # now fix up the executables
512 echo "Fixing up executable dependency names ..."
513 executables=$MAIN_EXECUTABLE
514 if test x$SAE != x ; then
515     executables="$executables"
516 fi
517
518 for exe in $executables; do
519     EXE=$APPROOT/MacOS/$exe
520     changes=""
521     for lib in `otool -L $EXE | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/$STDCPP)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
522       base=`basename $lib`
523       changes="$changes -change $lib @executable_path/../lib/$base"
524     done
525     if test "x$changes" != "x" ; then
526         install_name_tool $changes $EXE
527     fi
528 done
529
530 echo "Fixing up library names ..."
531 # now do the same for all the libraries we include
532 for libdir in $Frameworks $Frameworks/modules $Surfaces $Panners $Backends ; do
533
534     libbase=`basename $libdir`
535     
536     for dylib in $libdir/*.dylib $libdir/*.so ; do
537         
538        # skip symlinks
539         
540         if test -L $dylib ; then
541             continue
542         fi
543         
544         # change all the dependencies
545         
546         changes=""
547         for lib in `otool -L $dylib | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/$STDCPP)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
548             base=`basename $lib`
549             if echo $lib | grep -s libbase; then
550                 changes="$changes -change $lib @executable_path/../$libbase/$base"
551             else
552                 changes="$changes -change $lib @executable_path/../lib/$base"
553             fi
554         done
555         
556         if test "x$changes" != x ; then
557             if  install_name_tool $changes $dylib ; then
558                 :
559             else
560                 exit 1
561             fi
562         fi
563         
564         # now the change what the library thinks its own name is
565         
566         base=`basename $dylib`
567         install_name_tool -id @executable_path/../$libbase/$base $dylib
568     done
569 done
570
571 #
572 # and now ... the DMG
573
574
575 rm -rf $PRODUCT_PKG_DIR
576 mkdir $PRODUCT_PKG_DIR
577
578 DMGWINBOTTOM=440
579 DMGBACKGROUND=dmgbg
580
581 if [ x$SAE != x ] ; then
582         
583     # SAE packaging
584     
585     echo "Creating SAE packaging directory"
586     mv $APPDIR $PRODUCT_PKG_DIR/Ardour3-SAE.app
587     cp HowToInstallArdourSAE.pdf "$PRODUCT_PKG_DIR/How To Install Ardour SAE.pdf"
588     cp SAE-de-keypad.pdf "$PRODUCT_PKG_DIR/Ardour SAE Shortcuts (keypad).pdf"
589     cp SAE-de-nokeypad.pdf "$PRODUCT_PKG_DIR/Ardour SAE Shortcuts.pdf"
590     
591 elif [ x$MIXBUS != x ] ; then
592
593      # Mixbus packaging
594
595     echo "Creating Mixbus packaging directory"
596     mv $APPDIR $PRODUCT_PKG_DIR/
597     DMGBACKGROUND=dmgbgMB
598 else 
599
600     echo "Creating $APPNAME packaging directory"
601     mv $APPDIR $PRODUCT_PKG_DIR/
602
603 fi
604
605 if file ${PRODUCT_PKG_DIR}/$APPROOT/MacOS/$MAIN_EXECUTABLE | grep -q x86_64; then
606         OSX_ARCH=x86_64
607         OSX_BENSID=osx64
608 elif file ${PRODUCT_PKG_DIR}/$APPROOT/MacOS/$MAIN_EXECUTABLE | grep -q ppc; then
609         OSX_ARCH=ppc
610         OSX_BENSID=osxppc
611 else
612         OSX_ARCH=i386
613         OSX_BENSID=osx32
614 fi
615
616 if test x$WITH_HARRISON_LV2 != x ; then
617         curl -s -S --fail -#  \
618                 -z "${CACHEDIR}/harrison_lv2s.${OSX_BENSID}.zip" \
619                 -o "${CACHEDIR}/harrison_lv2s.${OSX_BENSID}.zip" \
620                 "http://www.harrisonconsoles.com/mixbus/mb3/beta/harrison-dsp/harrison_lv2s.${OSX_BENSID}.zip"
621
622         mkdir -p "${PRODUCT_PKG_DIR}/${APPROOT}/lib/LV2"
623         bsdtar -C "${PRODUCT_PKG_DIR}/${APPROOT}/lib/LV2/" -xf \
624                 "${CACHEDIR}/harrison_lv2s.${OSX_BENSID}.zip"
625 fi
626
627 if test x$WITH_HARVID != x ; then
628         echo "installing video tools.."
629         HARVID_VERSION=$(curl -s -S http://ardour.org/files/video-tools/harvid_version.txt)
630         XJADEO_VERSION=$(curl -s -S http://ardour.org/files/video-tools/xjadeo_version.txt)
631         MULTIARCH=osx
632         echo "copying harvid and xjadeo ..."
633
634         rsync -Pa \
635                 rsync://ardour.org/video-tools/harvid-osx-${HARVID_VERSION}.tgz \
636                 "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz"
637
638         rsync -Pa \
639                 rsync://ardour.org/video-tools/jadeo-${XJADEO_VERSION:1}.dmg \
640                 "$CACHEDIR/jadeo-${XJADEO_VERSION:1}.dmg"
641
642         tar -x -z \
643                 -C $PRODUCT_PKG_DIR/$APPROOT \
644                 -f "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz" || exit 1
645
646         JADEO=$(hdiutil attach "$CACHEDIR/jadeo-${XJADEO_VERSION:1}.dmg" | grep Apple_HFS | grep dev/ | cut -f 3)
647         cp -r "${JADEO}/Jadeo.app" "$PRODUCT_PKG_DIR/"
648         hdiutil detach "${JADEO}"
649
650         XJCONTENT=${PRODUCT_PKG_DIR}/Jadeo.app/Contents
651         HVLIBS=${PRODUCT_PKG_DIR}/$APPROOT/lib/harvid
652
653         for file in ${XJCONTENT}/MacOS/Jadeo-bin ${XJCONTENT}/Frameworks/*.dylib ${HVLIBS}/*.dylib ${PRODUCT_PKG_DIR}/$APPROOT/MacOS/*harvid* ; do
654                 lipo -extract_family ${OSX_ARCH} ${file} -output ${file}.thin && \
655                 mv ${file}.thin ${file}
656         done
657
658         DMGWINBOTTOM=580
659         YPOS=$[ $DMGWINBOTTOM - 300 ]
660         XJADEOPOS="set position of item \"Jadeo.app\" of container window to {310, ${YPOS}}"
661
662         DMGBACKGROUND=${DMGBACKGROUND}xj
663 fi
664
665 ################################################################################
666 ### Mixbus plugins, etc
667 if test x$WITH_X42_LV2 != x ; then
668         echo "bundling x42 plugins"
669         mkdir -p "${PRODUCT_PKG_DIR}/${APPROOT}/lib/LV2"
670
671         METERS_VERSION=$(curl -s -S http://x42-plugins.com/x42/osx/x42-meters.latest.txt)
672         rsync -a -q --partial \
673                 rsync://x42-plugins.com/x42/osx/x42-meters-lv2-osx-${METERS_VERSION}.zip \
674                 "$CACHEDIR/x42-meters-lv2-osx-${METERS_VERSION}.zip"
675         bsdtar -C "${PRODUCT_PKG_DIR}/${APPROOT}/lib/LV2/" -xf \
676                 "$CACHEDIR/x42-meters-lv2-osx-${METERS_VERSION}.zip"
677
678         EQ_VERSION=$(curl -s -S http://x42-plugins.com/x42/osx/x42-eq.latest.txt)
679         rsync -a -q --partial \
680                 rsync://x42-plugins.com/x42/osx/x42-eq-lv2-osx-${EQ_VERSION}.zip \
681                 "$CACHEDIR/x42-eq-lv2-osx-${EQ_VERSION}.zip"
682         bsdtar -C "${PRODUCT_PKG_DIR}/${APPROOT}/lib/LV2/" -xf \
683                 "$CACHEDIR/x42-eq-lv2-osx-${EQ_VERSION}.zip"
684
685         SETBFREE_VERSION=$(curl -s -S http://x42-plugins.com/x42/osx/setBfree.latest.txt)
686         rsync -a -q --partial \
687                 rsync://x42-plugins.com/x42/osx/setBfree-lv2-osx-${SETBFREE_VERSION}.zip \
688                 "$CACHEDIR/setBfree-lv2-osx-${SETBFREE_VERSION}.zip"
689         bsdtar -C "${PRODUCT_PKG_DIR}/${APPROOT}/lib/LV2/" -xf \
690                 "$CACHEDIR/setBfree-lv2-osx-${SETBFREE_VERSION}.zip"
691
692         MIDIFILTER_VERSION=$(curl -s -S http://x42-plugins.com/x42/osx/x42-midifilter.latest.txt)
693         rsync -a -q --partial \
694                 rsync://x42-plugins.com/x42/osx/x42-midifilter-lv2-osx-${MIDIFILTER_VERSION}.zip \
695                 "$CACHEDIR/x42-midifilter-lv2-osx-${MIDIFILTER_VERSION}.zip"
696         bsdtar -C "${PRODUCT_PKG_DIR}/${APPROOT}/lib/LV2/" -xf \
697                 "$CACHEDIR/x42-midifilter-lv2-osx-${MIDIFILTER_VERSION}.zip"
698
699         for file in ${PRODUCT_PKG_DIR}/${APPROOT}/lib/LV2/*/*.dylib ; do
700                 lipo -extract_family ${OSX_ARCH} ${file} -output ${file}.thin
701                 mv ${file}.thin ${file}
702         done
703 fi
704
705 if test -n "$MIXBUS"; then
706         echo "deploying harrison channelstrip for $OSX_BENSID"
707
708         mkdir -p "${PRODUCT_PKG_DIR}/${APPROOT}/lib/ladspa/strip"
709
710         curl -s -S --fail -#  \
711                 -z "${CACHEDIR}/${HARRISONCHANNELSTRIP}.${OSX_BENSID}.so" \
712                 -o "${CACHEDIR}/${HARRISONCHANNELSTRIP}.${OSX_BENSID}.so" \
713                 "http://www.harrisonconsoles.com/mixbus/mb3/beta/harrison-dsp/${HARRISONCHANNELSTRIP}.${OSX_BENSID}.so"
714
715         cp "${CACHEDIR}/${HARRISONCHANNELSTRIP}.${OSX_BENSID}.so" \
716                 "${PRODUCT_PKG_DIR}/${APPROOT}/lib/ladspa/strip/${HARRISONCHANNELSTRIP}.so"
717
718         echo "deploying harrison vamp plugins for $OSX_BENSID"
719
720         curl -s -S --fail -#  \
721                 -z "${CACHEDIR}/harrison_vamp.${OSX_BENSID}.dylib" \
722                 -o "${CACHEDIR}/harrison_vamp.${OSX_BENSID}.dylib" \
723                 "http://www.harrisonconsoles.com/mixbus/mb3/beta/harrison-dsp/harrison_vamp.${OSX_BENSID}.dylib"
724
725         cp "${CACHEDIR}/harrison_vamp.${OSX_BENSID}.dylib" \
726                 "${PRODUCT_PKG_DIR}/${APPROOT}/lib/harrison_vamp.dylib"
727 fi
728 ################################################################################
729
730 ( cd $PRODUCT_PKG_DIR ; find . ) > file_list.txt
731
732 echo "Building DMG ..."
733
734 # UC_DMG=$APPNAME-${release_version}-UC.dmg
735 # FINAL_DMG=$APPNAME-${release_version}.dmg
736
737 if [ x$DEBUG = xT ]; then
738         UC_DMG=$APPNAME-$release_version-dbg.dmg
739 else
740         UC_DMG=$APPNAME-$release_version.dmg
741 fi
742 VOLNAME=$APPNAME-$release_version
743
744 MNTPATH=`mktemp -d -t ardourimg`
745 TMPDMG=`mktemp -t ardour`
746 ICNSTMP=`mktemp -t ardouricon`
747 EXTRA_SPACE_MB=30
748 DMGMEGABYTES=$[ `du -sk "$PRODUCT_PKG_DIR" | cut -f 1` * 1024 / 1048576 + $EXTRA_SPACE_MB ]
749
750 echo "DMG MB = " $DMGMEGABYTES
751
752 rm -f $UC_DMG "$TMPDMG" "${TMPDMG}.dmg" "$ICNSTMP"
753 rm -rf "$MNTPATH"
754 mkdir -p "$MNTPATH"
755
756 TMPDMG="${TMPDMG}.dmg"
757
758 trap "rm -rf $MNTPATH $TMPDMG ${TMPDMG}.dmg $ICNSTMP" EXIT
759
760 hdiutil create -megabytes $DMGMEGABYTES -fs HFS+ -volname "${VOLNAME}" "$TMPDMG"
761 DiskDevice=$(hdid -nomount "$TMPDMG" | grep Apple_HFS | cut -f 1 -d ' ')
762 mount -t hfs -o nobrowse "${DiskDevice}" "${MNTPATH}"
763
764 cp -r ${PRODUCT_PKG_DIR}/* "${MNTPATH}" || exit
765 mkdir "${MNTPATH}/.background"
766 cp -vi ${DMGBACKGROUND}.png "${MNTPATH}/.background/dmgbg.png"
767
768 echo "setting DMG background ..."
769
770 if test $(sw_vers -productVersion | cut -d '.' -f 2) -lt 9; then
771         # OSX ..10.8.X
772         DISKNAME=${VOLNAME}
773 else
774         # OSX 10.9.X and later
775         DISKNAME=`basename "${MNTPATH}"`
776 fi
777
778 osascript << EOF
779   tell application "Finder"
780     activate
781     tell disk "${DISKNAME}"
782       open
783       delay 2
784       set current view of container window to icon view
785       set toolbar visible of container window to false
786       set statusbar visible of container window to false
787       set the bounds of container window to {400, 200, 800, ${DMGWINBOTTOM}}
788       set theViewOptions to the icon view options of container window
789       set arrangement of theViewOptions to not arranged
790       set icon size of theViewOptions to 64
791       set background picture of theViewOptions to file ".background:dmgbg.png"
792       make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"}
793       set position of item "${APPDIR}" of container window to {90, 100}
794       set position of item "Applications" of container window to {310, 100}
795       ${MIXBUSPOS}
796       ${HARVIDPOS}
797       ${XJADEOPOS}
798       close
799       open
800       update without registering applications
801       delay 5
802       eject
803     end tell
804   end tell
805 EOF
806
807 chmod -Rf go-w "${MNTPATH}"
808 sync
809
810 set -e
811 echo "compressing Image ..."
812
813 # Umount the image ('eject' above may already have done that)
814 umount "${DiskDevice}" || true
815 hdiutil eject "${DiskDevice}" || true
816 # Create a read-only version, use zlib compression
817 hdiutil convert -format UDZO "${TMPDMG}" -imagekey zlib-level=9 -o "${UC_DMG}"
818
819 if test $(sw_vers -productVersion | cut -d '.' -f 2) -gt 5; then
820 echo "setting file icon ..."
821
822 cp ${PRODUCT_PKG_DIR}/$Resources/appIcon.icns ${ICNSTMP}.icns
823 sips -i ${ICNSTMP}.icns
824 DeRez -only icns ${ICNSTMP}.icns > ${ICNSTMP}.rsrc
825 Rez -append ${ICNSTMP}.rsrc -o "$UC_DMG"
826 SetFile -a C "$UC_DMG"
827
828 rm ${ICNSTMP}.icns ${ICNSTMP}.rsrc
829 fi
830
831 rm -rf ${PRODUCT_PKG_DIR}
832
833 echo
834 echo "packaging suceeded."
835 ls -l "$UC_DMG"
836
837 echo "Done."
838 exit