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