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