fun hacks for wine
[ardour.git] / tools / linux_packaging / build
1 #!/bin/bash
2
3 # script for pulling together a Linux app bundle.
4 #
5 # This will create a bundle for a single architecture.
6 # Execute this scirpt on both x86 and x86_64 and then use
7 # package to merge the 2 bundles into a final package with the
8 # installer. See "noderun" for a complete build script.
9
10 # where the GTK stack is installed
11 GTKSTACK_ROOT=$HOME/gtk/inst
12 # where the Ardour dependencies are installed
13 ARDOURSTACK_ROOT=$HOME/a3/inst
14 # the waf build tree to use when copying built/generated files
15 BUILD_ROOT=../../build
16
17 . ../define_versions.sh
18
19 # where harvid and xjadeo binaries are cached
20 if test -z "$CACHEDIR" -o ! -d "$CACHEDIR"; then
21         CACHEDIR=`pwd`
22 fi
23
24 MIXBUS=
25 WITH_HARRISON_LV2=
26 WITH_X42_LV2=
27 WITH_LADSPA=0
28 WITH_HARVID=
29 STRIP=all
30 PRINT_SYSDEPS=
31 WITH_NLS=
32 EXTERNAL_JACK=
33 VENDOR=Ardour ;
34 EXENAME=ardour
35 GCC5ABI=false
36 USEWINE=false
37 BUILDTYPE=""
38 NOSTRIP="libsuil|libserd|libsord|liblilv|libsratom|liblrdf|libardour|libpbd|libevoral"
39
40
41 if [ $# -eq 0 ] ; then
42         echo ""
43         echo "ERROR - Please specify build type"
44         echo "    --public"
45         echo "    --mixbus"
46         echo ""
47         exit 1
48 fi
49
50 while [ $# -gt 0 ] ; do
51         echo "arg = $1"
52         case $1 in
53
54         #
55         # top level build targets
56         #
57
58         --mixbus)
59                 MIXBUS=1;
60                 WITH_HARRISON_LV2=1 ;
61                 WITH_X42_LV2=1 ;
62                 WITH_NLS=1 ;
63                 WITH_LADSPA=;
64                 STRIP=all
65                 APPNAME=Mixbus ;
66                 VENDOR=Harrison ;
67                 EXENAME=mixbus ;
68                 shift ;;
69         --public)
70                 WITH_NLS=1 ;
71                 WITH_LADSPA=;
72                 STRIP=all ;
73                 APPNAME=Ardour ;
74                 shift ;;
75         --allinone)
76                 WITH_NLS= ;
77                 WITH_LADSPA=1;
78                 STRIP=all;
79                 shift ;;
80         --test) WITH_LADSPA=; STRIP= ; shift ;;
81
82         #
83         # specific build flags
84         #
85
86         --nojack) INTERNAL_JACK= ; shift ;;
87         --noladspa) WITH_LADSPA= ; shift ;;
88         --strip) STRIP=$2 ; shift ; shift ;;
89         --sysdeps) PRINT_SYSDEPS=1; shift ;;
90         --nls) WITH_NLS=1 ; shift ;;
91         --harvid) WITH_HARVID=1 ; shift ;;
92         --gcc5abi) GCC5ABI=true ; shift ;;
93
94         *)
95                 #catch all for unknown arguments
96                 echo ""
97                 echo "!!! ERROR !!! - Unknown argument $1"
98                 echo ""
99                 exit 1
100                 ;;
101         esac
102 done
103
104 if test x$STRIP != xall -a x$STRIP != xnone -a x$STRIP != xsome ; then
105     echo "Unknown strip option \"$STRIP\""
106     echo "Legal values are: all, none, some"
107     exit 1
108 fi
109
110 . ../define_versions.sh
111
112 echo "Version is $release_version"
113 if [ "x$commit" != "x" ] ; then
114     info_string="$release_version ($commit) built on `hostname` by `whoami` on `date`"
115 else
116     info_string="$release_version built on `hostname` by `whoami` on `date`"
117 fi
118 echo "Info string is $info_string"
119
120 # Figure out our CPU type
121 case `uname -m` in
122         i[3456789]86|x86|i86pc)
123                 echo "Architecture is x86"
124                 ARCH='x86'
125                 WARCH='i386'
126                 HARCH='linux32'
127                 ARCH_BITS='32-bit'
128                 MULTIARCH='i386-linux-gnu'
129                 ;;
130         x86_64|amd64|AMD64)
131                 echo "Architecture is x86_64"
132                 ARCH='x86_64'
133                 WARCH='x86_64'
134                 HARCH='linux64'
135                 ARCH_BITS='64-bit'
136                 MULTIARCH='x86_64-linux-gnu'
137                 ;;
138         *)
139                 echo ""
140                 echo "ERROR - Unknown architecture `uname -m`"
141                 echo ""
142                 exit 1
143                 ;;
144 esac
145
146 if [ x$DEBUG = xT ]; then
147     BUILDTYPE="dbg"
148     if [ x$STRIP = xall ] ; then
149         echo "A debug build with --strip all makes no sense - STRIP reset to \"some\""
150         STRIP=some
151     fi
152 fi
153
154 # setup directory structure
155
156 if [ -z "${BUILDTYPE}" ]; then
157         APPDIR=${APPNAME}_${ARCH}-${release_version}
158         APP_VER_NAME=${APPNAME}-${release_version}
159 else
160         APPDIR=${APPNAME}_${ARCH}-${release_version}-${BUILDTYPE}
161         APP_VER_NAME=${APPNAME}-${release_version}-${BUILDTYPE}
162 fi
163
164 APPBIN=$APPDIR/bin
165 APPLIB=$APPDIR/lib
166 Libraries=$APPLIB
167 Etc=$APPDIR/etc
168 Shared=$APPDIR/share
169
170 Plugins=$APPLIB/plugins
171 Surfaces=$APPLIB/surfaces
172 Panners=$APPLIB/panners
173 Backends=$APPLIB/backends
174
175 Templates=$Shared/templates
176 ExportFormats=$Shared/export
177 Locale=$Shared/locale
178 MidiMaps=$Shared/midi_maps
179 PatchFiles=$Shared/patchfiles
180 MackieControl=$Shared/mcp
181
182 if [ x$PRINT_SYSDEPS != x ] ; then
183 #
184 # print system dependencies
185 #
186
187         for file in $APPBIN/* $Libraries/* $Plugins/*.so ; do
188                 if ! file $file | grep -qs Mach-O ; then
189                         continue
190                 fi
191                 otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)"
192         done | sort | uniq
193         exit 0
194 fi
195
196 echo "Removing old $APPDIR tree ..."
197 rm -rf $APPDIR/
198
199 echo "Building new app directory structure ..."
200
201 # only bother to make the longest paths
202
203 mkdir -p $APPDIR
204 mkdir -p $APPBIN
205 mkdir -p $APPLIB
206 mkdir -p $Etc
207 mkdir -p $Shared
208 mkdir -p $Locale
209 mkdir -p $Surfaces
210 mkdir -p $MidiMaps
211 mkdir -p $PatchFiles
212 mkdir -p $MackieControl
213 mkdir -p $ExportFormats
214 mkdir -p $Panners
215 mkdir -p $Backends
216 mkdir -p $Templates
217 mkdir -p $Shared/doc
218
219 # maybe set variables
220 ENVIRONMENT=environment
221 rm -f $ENVIRONMENT
222 touch $ENVIRONMENT
223
224 if test x$MIXBUS != x ; then
225         echo export ARDOUR_MIXBUS=true >> $ENVIRONMENT
226         #
227         # current default for MIXBUS version is US keyboard layout without a keypad
228         #
229         echo export ARDOUR_KEYBOARD_LAYOUT=us-nokeypad >> $ENVIRONMENT
230         echo export ARDOUR_UI_CONF=ardour3_ui.conf >> $ENVIRONMENT
231 fi
232
233 #
234 # if we're not going to bundle JACK, make sure we can find
235 # jack in the places where it might be
236 #
237
238 echo export 'PATH=/usr/local/bin:/opt/bin:$PATH' >> $ENVIRONMENT
239
240 # create startup helper script
241 if test -d $BUILD_ROOT/vst; then
242         WINEEXE=wine
243         USEWINE=true
244         echo export INSTALL_DIR >> $ENVIRONMENT
245 else
246         WINEEXE=
247 fi
248
249 sed -e "/^%ENV%/r $ENVIRONMENT" -e '/^%ENV%/d' -e 's/%VER%/'"${release_version}"'/;s/%EXENAME%/'"${EXENAME}"'/;s/%WINE%/'"$WINEEXE"'/' < ardour.sh.in > $APPBIN/${EXENAME}${major_version}
250 rm $ENVIRONMENT && chmod 775 $APPBIN/${EXENAME}${major_version}
251
252 echo "Copying ardour executable ...."
253 if test -d $BUILD_ROOT/vst; then
254         #cp -v $BUILD_ROOT/gtk2_ardour/libgtk2_ardour.so $APPLIB/
255         cp -v $BUILD_ROOT/gtk2_ardour/ardour-${release_version}-vst.exe.so $APPBIN/${EXENAME}-${release_version}
256 else
257         cp -v $BUILD_ROOT/gtk2_ardour/ardour-${release_version}* $APPBIN/${EXENAME}-${release_version}
258 fi
259
260 if test x$STRIP = xall ; then
261         strip -s $APPBIN/${EXENAME}-${release_version}
262 fi
263
264 # copy locale files
265 # note that at present(feb 2011), the .mo files end up in the source tree which is
266 # not really as it should be.
267 if test x$WITH_NLS != x ; then
268         echo "NLS support ..."
269         echo "I hope you remembered to run scons msgupdate!"
270         LINGUAS=
271
272         for pkg in gtk2_ardour libs/ardour libs/gtkmm2ext ; do
273             files=`find ../../$pkg -name "*.mo"`
274
275             #
276             # the package name is appended with a number so that
277             # it can be parallel installed during a regular install
278             # with older (and newer) versions. it is just the major
279             # number of the release (i.e. leading digits)
280             #
281
282             vsuffix=`echo $release_version | sed 's/^\([0-9][0-9]*\).*/\1/'`
283
284             if [ -z "$files" ]; then
285                 echo ""
286                 echo "!!!! WARNING !!!! - Did not find any .mo files in ../../$pkg"
287                 echo ""
288             fi
289
290             for file in $files
291             do
292                 echo $file
293                 lang=`basename $file | sed 's/\.mo//'`
294                 mkdir -p $Locale/$lang/LC_MESSAGES
295                 cp $file $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
296                 echo copy $file to $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
297                 if echo $LINGUAS | grep $lang >/dev/null 2>&1 ; then
298                     :
299                 else
300                     LINGUAS="$LINGUAS $lang"
301                 fi
302             done
303         done
304
305         GTK_MESSAGES="atk10.mo gdk-pixbuf.mo gtk20-properties.mo gtk20.mo atk10.mo glib20.mo"
306         LOCALEROOT=$GTKSTACK_ROOT/share/locale
307
308         for l in $LINGUAS ; do
309                 echo "Copying GTK i18n files for $l..."
310                 for MO in $GTK_MESSAGES ; do
311                         if [ -f $LOCALEROOT/$l/LC_MESSAGES/$MO ] ; then
312                                 cp $LOCALEROOT/$l/LC_MESSAGES/$MO $Locale/$l/LC_MESSAGES
313                         else
314                                 # try with just the language spec
315                                 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
316                                 if [ -f $LOCALEROOT/$just_lang/LC_MESSAGES/$MO ] ; then
317                                         cp $LOCALEROOT/$just_lang/LC_MESSAGES/$MO $Locale/$just_lang/LC_MESSAGES
318                                 fi
319                         fi
320                 done
321         done
322 else
323         echo "Skipping NLS support"
324 fi
325
326 #
327 # Copy stuff that may be dynamically loaded
328 #
329
330 cp -R $GTKSTACK_ROOT/etc/* $Etc
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 $Libraries/gtkengines
334
335 GTK_ENGINE_DIR=$Libraries/gtkengines/engines
336 mkdir -p $GTK_ENGINE_DIR
337
338 echo "Copying GTK engines ..."
339 cp $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.so $Libraries
340 (cd $GTK_ENGINE_DIR && ln -s ../../libclearlooks.so . )
341
342 cp $GTKSTACK_ROOT/lib/gtk-2.0/2.10.0/engines/libpixmap.so $Libraries
343 (cd $GTK_ENGINE_DIR && ln -s ../../libpixmap.so . )
344
345 # LADSPA
346 if test x$WITH_LADSPA != x ; then
347         if test x$MIXBUS != x ; then
348                 plugdir=mixbus_ladspa
349         else
350                 plugdir=ladspa
351         fi
352         echo "Copying `ls $plugdir | wc -l` plugins ..."
353         if [ -d $plugdir ] ; then
354                 mkdir -p $Plugins
355                 cp -r $plugdir/* $Plugins
356         fi
357 fi
358
359 # Control Surfaces
360 cp $BUILD_ROOT/libs/surfaces/*/libardour_*.so* $Surfaces
361 cp $BUILD_ROOT/libs/surfaces/control_protocol/libardourcp.so* $Libraries
362
363 # MidiMaps
364 # got to be careful with names here
365 for x in $BUILD_ROOT/../midi_maps/*.map ; do
366     cp "$x" $MidiMaps
367 done
368
369 # MIDNAM Patch Files
370 # got to be careful with names here
371 for x in $BUILD_ROOT/../patchfiles/*.midnam ; do
372     cp "$x" $PatchFiles
373 done
374
375 # MackieControl data
376 # got to be careful with names here
377 for x in $BUILD_ROOT/../mcp/*.device $BUILD_ROOT/../mcp/*.profile ; do
378     cp "$x" $MackieControl
379 done
380
381 # Templates
382 #for f in $BUILD_ROOT/../templates/* ; do
383 #    if [ -d "$f" ] ; then
384 #       echo Template: $f ; cp -r "$f" $Templates ;
385 #    fi
386 #done
387
388 # ExportFormats
389 # got to be careful with names here
390 for x in $BUILD_ROOT/../export/*.preset $BUILD_ROOT/../export/*.format ; do
391     cp "$x" $ExportFormats
392 done
393
394 # Panners
395 cp $BUILD_ROOT/libs/panners/*/lib*.so* $Panners
396
397 # Backends
398 for backend in jack alsa dummy wavesaudio ; do
399     cp $BUILD_ROOT/libs/backends/$backend/lib*.so* $Backends
400 done
401
402 # VAMP plugins that we use
403 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.so* $Libraries
404
405 # Suil modules (new dir 'build-stack')
406 if test -d $GTKSTACK_ROOT/lib/suil-0/ ; then
407     cp $GTKSTACK_ROOT/lib/suil-0/lib* $Libraries
408 fi
409
410 # Suil modules (old dir 'build-ardour-stack')
411 if test -d $ARDOURSTACK_ROOT/lib/suil-0/ ; then
412     cp $ARDOURSTACK_ROOT/lib/suil-0/lib* $Libraries
413 fi
414
415 # VST scanner app (both LXVST as well as WIN-VST, 2in1)
416 # (if build with wine: ardour-vst-scanner is a wrapper
417 #  script for ardour-vst-scanner.exe.so, if VST is disabled
418 #  neither binary nor script exists)
419 if test -d $BUILD_ROOT/libs/fst ; then
420     cp $BUILD_ROOT/libs/fst/ardour-vst-scanner* $APPLIB || true
421     if test x$STRIP = xall ; then
422         strip -s $APPLIB/ardour-vst-scanner*
423     fi
424 fi
425
426 # vfork wrapper
427 if test -f $BUILD_ROOT/libs/vfork/ardour-exec-wrapper ; then
428     cp $BUILD_ROOT/libs/vfork/ardour-exec-wrapper $APPLIB
429     if test x$STRIP = xall ; then
430         strip -s $APPLIB/ardour-exec-wrapper
431     fi
432 fi
433
434 # ALSA device reservation tool (if available)
435 if test -f $BUILD_ROOT/libs/ardouralsautil/ardour-request-device; then
436     cp $BUILD_ROOT/libs/ardouralsautil/ardour-request-device $APPLIB/ || true
437     if test x$STRIP = xall ; then
438         strip -s $APPLIB/ardour-request-device
439     fi
440 fi
441
442 OURLIBDIR=$BUILD_ROOT/libs
443 OURLIBS=$OURLIBDIR/vamp-sdk:$OURLIBDIR/surfaces/control_protocol:$OURLIBDIR/ardour:$OURLIBDIR/midi++2:$OURLIBDIR/pbd:$OURLIBDIR/rubberband:$OURLIBDIR/soundtouch:$OURLIBDIR/gtkmm2ext:$OURLIBDIR/sigc++2:$OURLIBDIR/glibmm2:$OURLIBDIR/gtkmm2/atk:$OURLIBDIR/gtkmm2/pango:$OURLIBDIR/gtkmm2/gdk:$OURLIBDIR/gtkmm2/gtk:$OURLIBDIR/canvas:$OURLIBDIR/libsndfile:$OURLIBDIR/evoral:$OURLIBDIR/evoral/src/libsmf:$OURLIBDIR/audiographer:$OURLIBDIR/timecode:$OURLIBDIR/taglib:$OURLIBDIR/libltc:$OURLIBDIR/qm-dsp:$OURLIBDIR/ardouralsautil:$OURLIBDIR/ptformat:$BUILD_ROOT/gtk2_ardour
444
445 echo $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
446
447 checkedIdx=0
448 deplibs=
449
450 while [ true ] ; do
451         missing=false
452         filelist=`find $APPLIB/ -type f`
453         filelist="$APPBIN/${EXENAME}-${release_version} $filelist"
454
455         for file in $filelist  ; do
456                 if ! file $file | grep -qs ELF ; then
457                         continue
458                 fi
459
460                 # speed this up a bit by not checking things multiple times.
461                 for i in "${depCheckedList[@]}"; do
462                         if [ $i == $file ]; then
463                                 continue 2
464                         fi
465                 done
466                 depCheckedList[$checkIdx]=$file
467                 checkIdx=$(($checkIdx + 1))
468
469                 # ignore suil/qt wrappers - the plugin will pull in QT4.
470                 if echo $file | grep -qs 'libsuil_.*qt4' ; then continue; fi
471
472                 # do not include libjack
473                 deps=`LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file | awk '{print $3}'`
474
475                 echo -n "."
476                 for dep in $deps ; do
477                         if test "not" = ${dep}; then
478                                 echo ""
479                                 echo "!!! ERROR !!! - Missing dependant library for $file."
480                                 echo "Searched: " $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
481                                 echo ""
482                                 (LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file)
483                                 echo ""
484                                 echo "!!! ERROR !!! - See Above"
485                                 exit 1
486                         fi
487
488                         # don't use anything mapped at a specific address
489                         if echo $dep | grep -qs '0x' ; then continue; fi
490                         # don't include /lib
491                         if echo $dep | grep -qs "^/lib/" ; then continue; fi
492                         # don't include jack
493                         if echo $dep | grep -qs libjack ; then continue; fi
494                         # don't include ALSA
495                         if echo $dep | grep -qs libasound ; then continue; fi
496                         # don't include any X Window libraries
497                         if echo $dep | grep -qs libX\. ; then continue; fi
498                         if echo $dep | grep -qs libxcb ; then continue; fi
499                         if echo $dep | grep -qs libICE\. ; then continue; fi
500                         if echo $dep | grep -qs libSM\. ; then continue; fi
501                         # don't include libc
502                         if echo $dep | grep -qs 'libc\.' ; then continue; fi
503                         # don't include libstdc++
504                         if echo $dep | grep -qs libstdc++ ; then continue; fi
505                         # don't include libdbus
506                         if echo $dep | grep -qs libdbus ; then continue; fi
507
508                         base=`basename $dep`
509                         if ! test -f $Libraries/$base; then
510                                 parent=$(basename ${file})
511                                 if echo $dep | grep -sq '^libs' ; then
512                                         echo "Copying dependant lib $BUILD_ROOT/$dep    (required by ${parent})"
513                                         cp $BUILD_ROOT/$dep $Libraries
514                                 else
515                                         echo "Copying dependant lib $dep    (required by ${parent})"
516                                         cp $dep $Libraries
517                                 fi
518                                 #
519                                 # reset RPATH so that the runtime linker never looks
520                                 # in places we don't want it to
521                                 #
522                                 chrpath -r foo $Libraries/`basename $dep`
523                                 if echo $dep | grep -sq '^/' ; then
524                                     # absolute path, candidate for stripping
525                                     deplibs="$deplibs $base"
526                                 fi
527                                 missing=true
528                         fi
529                 done
530         done
531         if test x$missing = xfalse ; then
532                 # everything has been found
533                 break
534         fi
535 done
536 echo
537
538 # strip libraries
539 if test x$STRIP = xall ; then
540     echo Stripping all libraries
541     # Must be writable so that we can strip
542     find $APPLIB/ -name "*.so*" -print0 | xargs -0 chmod u+w
543     # and strip ...
544     find $APPLIB/ -name "*.so*" -print0 | xargs -0 strip -s
545 elif test x$STRIP = xsome ; then
546     echo Stripping dependent libraries
547     for l in $deplibs ; do
548         if echo "$l" | grep -qE "$NOSTRIP"; then
549             continue
550         fi
551         chmod u+w $APPLIB/$l
552         strip -s $APPLIB/$l
553     done
554 fi
555 find $APPLIB/ -name "*.so*" -print0 | xargs -0 chmod a+rx
556
557 echo "Copying other stuff to $APPDIR  ..."
558
559 # these are all generated by waf
560 cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings  $Etc
561 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Etc
562 cp $BUILD_ROOT/gtk2_ardour/clearlooks.rc $Etc
563 cp $BUILD_ROOT/gtk2_ardour/default_ui_config $Etc
564
565 # Copied directly from source tree
566
567 cp ../../system_config $Etc/system_config
568 cp ../../gtk2_ardour/dark.colors $Etc
569 cp ../../instant.xml $Shared/instant.xml
570 cp ../../gtk2_ardour/step_editing.bindings $Etc
571 cp ../../gtk2_ardour/mixer.bindings $Etc
572 cp -r ../../gtk2_ardour/icons $Shared
573 cp -r ../../gtk2_ardour/pixmaps $Shared
574 cp -r ../../gtk2_ardour/splash.png $Shared
575 cp -r ../../gtk2_ardour/small-splash.png $Shared
576 cp -r ../../gtk2_ardour/ArdourMono.ttf $Shared
577
578 #
579 # put sooper sekrit ingredients here and they will be copied
580 #
581
582 if [ -d specialSauce ] ; then
583         cp -r specialSauce $Etc
584 fi
585
586 # install bundled LV2s to <app>/lib/LV2/
587 cp -R $BUILD_ROOT/libs/LV2 $APPLIB/
588
589 # lv2 core, classifications etc - TODO check if we need the complete LV2 ontology
590 if test -d $ARDOURSTACK_ROOT/lib/lv2/lv2core.lv2 ; then
591         mkdir -p $APPLIB/LV2/lv2core.lv2
592         cp -R $ARDOURSTACK_ROOT/lib/lv2/lv2core.lv2/*.ttl $APPLIB/LV2/lv2core.lv2/
593 elif test -d $GTKSTACK_ROOT/lib/lv2/lv2core.lv2 ; then
594         mkdir -p $APPLIB/LV2/lv2core.lv2
595         cp -R $GTKSTACK_ROOT/lib/lv2/lv2core.lv2/*.ttl $APPLIB/LV2/lv2core.lv2/
596 fi
597
598 # go through and recursively remove any .svn dirs in the bundle
599 for svndir in `find $APPDIR -name .svn -type d`; do
600         rm -rf $svndir
601 done
602
603
604 ################################################################################
605 ### Mixbus plugins, etc
606 if test x$WITH_HARRISON_LV2 != x ; then
607         echo "Adding Harrison LV2s"
608         mkdir -p $APPLIB/LV2
609
610         curl -s -S --fail -# \
611                 -z "${CACHEDIR}/harrison_lv2s.${HARCH}.zip" \
612                 -o "${CACHEDIR}/harrison_lv2s.${HARCH}.zip" \
613                 "http://www.harrisonconsoles.com/mixbus/mb3/beta/harrison-dsp/harrison_lv2s.${HARCH}.zip"
614         unzip -q -d "$APPLIB/LV2/" "${CACHEDIR}/harrison_lv2s.${HARCH}.zip"
615 fi
616
617 if test -n "$MIXBUS"; then
618         echo "Adding Mixbus Channelstrip"
619
620         mkdir -p $APPLIB/ladspa/strip/
621         curl -s -S --fail -# \
622                 -z "${CACHEDIR}/harrison_channelstrip.${HARCH}.so" \
623                 -o "${CACHEDIR}/harrison_channelstrip.${HARCH}.so" \
624                 "http://www.harrisonconsoles.com/mixbus/mb3/beta/harrison-dsp/harrison_channelstrip.${HARCH}.so"
625
626         cp "${CACHEDIR}/harrison_channelstrip.${HARCH}.so" \
627                 $APPLIB/ladspa/strip/harrison_channelstrip.so
628         chmod +x $APPLIB/ladspa/strip/harrison_channelstrip.so
629 fi
630
631 if test x$WITH_X42_LV2 != x ; then
632         METERS_VERSION=$(curl -s -S http://x42-plugins.com/x42/linux/x42-meters.latest.txt)
633         rsync -a -q --partial \
634                 rsync://x42-plugins.com/x42/linux/x42-meters-lv2-linux-${WARCH}-${METERS_VERSION}.zip \
635                 "${CACHEDIR}/x42-meters-lv2-linux-${WARCH}-${METERS_VERSION}.zip"
636         unzip -q -d "$APPLIB/LV2/" "${CACHEDIR}/x42-meters-lv2-linux-${WARCH}-${METERS_VERSION}.zip"
637
638         SETBFREE_VERSION=$(curl -s -S http://x42-plugins.com/x42/linux/setBfree.latest.txt)
639         rsync -a -q --partial \
640                 rsync://x42-plugins.com/x42/linux/setBfree-lv2-linux-${WARCH}-${SETBFREE_VERSION}.zip \
641                 "${CACHEDIR}/setBfree-lv2-linux-${WARCH}-${SETBFREE_VERSION}.zip"
642         unzip -q -d "$APPLIB/LV2/" "${CACHEDIR}/setBfree-lv2-linux-${WARCH}-${SETBFREE_VERSION}.zip"
643
644         MIDIFILTER_VERSION=$(curl -s -S http://x42-plugins.com/x42/linux/x42-midifilter.latest.txt)
645         rsync -a -q --partial \
646                 rsync://x42-plugins.com/x42/linux/x42-midifilter-lv2-linux-${WARCH}-${MIDIFILTER_VERSION}.zip \
647                 "${CACHEDIR}/x42-midifilter-lv2-linux-${WARCH}-${MIDIFILTER_VERSION}.zip"
648         unzip -q -d "$APPLIB/LV2/" "${CACHEDIR}/x42-midifilter-lv2-linux-${WARCH}-${MIDIFILTER_VERSION}.zip"
649
650 fi
651 ################################################################################
652
653
654 if test x$WITH_HARVID != x ; then
655         cd $APPBIN
656         HARVID_VERSION=$(curl -s -S http://ardour.org/files/video-tools/harvid_version.txt)
657         XJADEO_VERSION=$(curl -s -S http://ardour.org/files/video-tools/xjadeo_version.txt)
658
659         rsync -Pa \
660                 rsync://ardour.org/video-tools/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz \
661                 "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz"
662
663         rsync -Pa \
664                 rsync://ardour.org/video-tools/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz \
665                 "$CACHEDIR/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz"
666
667         tar -x -z \
668                 --exclude=README --exclude=harvid.1 --strip-components=1 \
669                 -f "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz" || exit 1
670
671         tar -x -z \
672                 --exclude=README --exclude=xjadeo.1 --strip-components=1 \
673                 -f "$CACHEDIR/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz" || exit 1
674         mv xjadeo xjremote
675         cd -
676 fi
677
678 #
679 # Add the uninstaller
680 #
681 sed -e "s/%REPLACE_PGM%/${APPNAME}/" -e "s/%REPLACE_VENDOR%/${VENDOR}/" -e "s/%REPLACE_MAJOR_VERSION%/${major_version}/" -e "s/%REPLACE_VERSION%/${release_version}/" -e "s/%REPLACE_TYPE%/${BUILDTYPE}/" < uninstall.sh.in > $APPBIN/${APP_VER_NAME}.uninstall.sh
682 chmod a+x $APPBIN/${APP_VER_NAME}.uninstall.sh
683
684 #
685 # Add the stage2.run script
686 #
687 sed -e "s/%REPLACE_MAJOR_VERSION%/${major_version}/;s/%REPLACE_PGM%/${APPNAME}/;s/%REPLACE_VENDOR%/${VENDOR}/;s/%REPLACE_EXE%/${EXENAME}/;s/%REPLACE_GCC5%/${GCC5ABI}/;s/%REPLACE_WINE%/${USEWINE}/" < stage2.run.in > stage2.run
688 chmod a+x stage2.run
689
690
691 #Sanity Check file
692 if [ -e $BUILD_ROOT/tools/sanity_check/sanityCheck ]; then
693         cp $BUILD_ROOT/tools/sanity_check/sanityCheck $APPBIN
694 else
695         echo "!!!ERROR !!! sanityCheck program is missing. packager will exit without being complete"
696         exit 1
697 fi
698
699 echo "Building tarball ..."
700
701 rm -f $APPDIR.tar.bz2
702 tar -cjf $APPDIR.tar.bz2 $APPDIR
703
704 echo "Calculating bundle size"
705 du -sb $APPDIR/  | awk '{print $1}' > $APPDIR.size
706
707 ( cd $APPDIR ; find . ) > file_list.txt
708
709 rm -rf $APPDIR/
710
711 echo "Done."
712