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