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