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