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