forked from mltframework/shotcut
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-linux.sh
executable file
·1294 lines (1183 loc) · 42.1 KB
/
deploy-linux.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# This script builds shotcut and many of its dependencies.
# It can accept a configuration file, default: build-shotcut.conf
# List of programs used:
# bash, test, tr, awk, ps, make, cmake, cat, sed, curl or wget, and possibly others
# Author: Dan Dennedy <dan@dennedy.org>
# Version: 1
# License: GPL2
################################################################################
# ARGS AND GLOBALS
################################################################################
# These are all of the configuration variables with defaults
INSTALL_DIR="$HOME/shotcut"
AUTO_APPEND_DATE=0
SOURCE_DIR="$INSTALL_DIR/src"
ACTION_GET_COMPILE_INSTALL=1
ACTION_GET_ONLY=0
ACTION_COMPILE_INSTALL=0
SOURCES_CLEAN=0
INSTALL_AS_ROOT=0
CREATE_STARTUP_SCRIPT=1
ENABLE_FREI0R=1
FREI0R_HEAD=1
FREI0R_REVISION=
ENABLE_SWFDEC=0
SWFDEC_HEAD=
SWFDEC_REVISION=
X264_HEAD=1
X264_REVISION=
LIBVPX_HEAD=1
LIBVPX_REVISION=
ENABLE_LAME=1
FFMPEG_HEAD=1
FFMPEG_REVISION=
FFMPEG_SUPPORT_H264=1
FFMPEG_SUPPORT_LIBVPX=1
FFMPEG_SUPPORT_THEORA=1
FFMPEG_SUPPORT_MP3=1
FFMPEG_SUPPORT_FAAC=0
FFMPEG_ADDITIONAL_OPTIONS=
MLT_HEAD=1
MLT_REVISION=
SHOTCUT_HEAD=1
SHOTCUT_REVISION=
# QT_INCLUDE_DIR="$(pkg-config --variable=prefix QtCore)/include"
QT_INCLUDE_DIR=
# QT_LIB_DIR="$(pkg-config --variable=prefix QtCore)/lib"
QT_LIB_DIR=
MLT_DISABLE_SOX=0
################################################################################
# Location of config file - if not overriden on command line
CONFIGFILE=build-shotcut.conf
# If defined to 1, outputs trace log lines
TRACE=0
# If defined to 1, outputs debug log lines
DEBUG=0
# We need to set LANG to C to avoid e.g. svn from getting to funky
export LANG=C
# User CFLAGS and LDFLAGS sometimes prevent more recent local headers.
# Also, you can adjust some flags here.
export CFLAGS=
export CXXFLAGS=
export LDFLAGS=
################################################################################
# FUNCTION SECTION
################################################################################
#################################################################
# usage
# Reports legal options to this script
function usage {
echo "Usage: $0 [-c config-file] [-t] [-h]"
echo "Where:"
echo -e "\t-c config-file\tDefaults to $CONFIGFILE"
echo -e "\t-t\t\tSpawn into sep. process"
}
#################################################################
# parse_args
# Parses the arguments passed in $@ and sets some global vars
function parse_args {
CONFIGFILEOPT=""
DETACH=0
while getopts ":tc:d:l:" OPT; do
case $OPT in
c ) CONFIGFILEOPT=$OPTARG
echo Setting configfile to $CONFIGFILEOPT
;;
t ) DETACH=1;;
h ) usage
exit 0;;
* ) echo "Unknown option $OPT"
usage
exit 1;;
esac
done
# Check configfile
if test "$CONFIGFILEOPT" != ""; then
if test ! -r "$CONFIGFILEOPT" ; then
echo "Unable to read config-file $CONFIGFILEOPT"
exit 1
fi
CONFIGFILE="$CONFIGFILEOPT"
fi
}
######################################################################
# DATA HANDLING FUNCTIONS
######################################################################
#################################################################
# to_key
# Returns a numeric key from a known subproject
# $1 : string: ffmpeg, mlt, etc.
function to_key {
case $1 in
ffmpeg)
echo 0
;;
mlt)
echo 1
;;
frei0r)
echo 2
;;
x264)
echo 3
;;
libvpx)
echo 4
;;
swfdec)
echo 5
;;
lame)
echo 6
;;
shotcut)
echo 7
;;
*)
echo UNKNOWN
;;
esac
}
#################################################################
# lookup - lookup a value from an array and return it
# $1 array name, $2 subdir name, that is, text string
function lookup {
eval echo "\${${1}[`to_key $2`]}"
}
######################################################################
# LOG FUNCTIONS
######################################################################
#################################################################
# init_log_file
# Write some init stuff
function init_log_file {
log `date`
log $0 starting
}
#################################################################
# trace
# Function that prints a trace line
# $@ : arguments to be printed
function trace {
if test "1" = "$TRACE" ; then
echo "TRACE: $@"
fi
}
#################################################################
# debug
# Function that prints a debug line
# $@ : arguments to be printed
function debug {
if test "1" = "$DEBUG" ; then
echo "DEBUG: $@"
fi
}
#################################################################
# log
# Function that prints a log line
# $@ : arguments to be printed
function log {
echo "LOG: $@"
}
#################################################################
# log warning
# Function that prints a warning line
# $@ : arguments to be printed
function warn {
echo "WARN: $@"
}
#################################################################
# die
# Function that prints a line and exists
# $@ : arguments to be printed
function die {
echo "ERROR: $@"
feedback_result FAILURE "Some kind of error occured: $@"
exit -1
}
#################################################################
# cmd
# Function that does a (non-background, non-outputting) command, after logging it
function cmd {
trace "Entering cmd @ = $@"
log About to run command: "$@"
"$@"
}
######################################################################
# SETUP FUNCTIONS
######################################################################
#################################################################
# read_configuration
# Reads $CONFIGFILE, parses it, and exports global variables reflecting the
# content. Aborts, if the file does not exist or is not readable
CONFIGURATION=""
function read_configuration {
trace "Entering read_configuration @ = $@"
if test ! -r "$CONFIGFILE"; then
warn "Unable to read config file $CONFIGFILE"
return
fi
debug "Reading configuration from $CONFIGFILE"
# This is for replacement in startup scripts
for LINE in `tr "\t" "=" < $CONFIGFILE`; do
debug Setting $LINE
CONFIGURATION="$CONFIGURATION$LINE "
#export $LINE || die "Invalid export line: $LINE. Unable to set configuration options from CONFIGFILE"
done ||\
die "Unable to set configuration options from $CONFIGFILE"
source "$CONFIGFILE" || die "Unable to evaluate configuration options from $CONFIGFILE"
}
#################################################################
# set_globals
# Set up globals based on configuration
# This is where the configuration options for each subproject is assembled
function set_globals {
trace "Entering set_globals @ = $@"
# Set two convenience variables.
if test 1 = "$ACTION_GET_ONLY" -o 1 = "$ACTION_GET_COMPILE_INSTALL" ; then
GET=1
else
GET=0
fi
NEED_SUDO=0
if test 1 = "$ACTION_GET_COMPILE_INSTALL" -o 1 = "$ACTION_COMPILE_INSTALL" ; then
COMPILE_INSTALL=1
if test 1 = $INSTALL_AS_ROOT ; then
NEED_SUDO=1
fi
else
COMPILE_INSTALL=0
fi
debug "GET=$GET, COMPILE_INSTALL=$COMPILE_INSTALL, NEED_SUDO=$NEED_SUDO"
# The script sets CREATE_STARTUP_SCRIPT to true always, disable if not COMPILE_INSTALL
if test 0 = "$COMPILE_INSTALL" ; then
CREATE_STARTUP_SCRIPT=0
fi
debug "CREATE_STARTUP_SCRIPT=$CREATE_STARTUP_SCRIPT"
# Subdirs list, for number of common operations
# Note, the function to_key depends on this
SUBDIRS="ffmpeg mlt shotcut"
if test "$ENABLE_FREI0R" = 1 ; then
SUBDIRS="frei0r $SUBDIRS"
fi
if test "$ENABLE_SWFDEC" = 1 && test "$SWFDEC_HEAD" = 1 -o "$SWFDEC_REVISION" != ""; then
SUBDIRS="swfdec $SUBDIRS"
fi
if test "$FFMPEG_SUPPORT_H264" = 1 && test "$X264_HEAD" = 1 -o "$X264_REVISION" != ""; then
SUBDIRS="x264 $SUBDIRS"
fi
if test "$FFMPEG_SUPPORT_LIBVPX" = 1 && test "$LIBVPX_HEAD" = 1 -o "$LIBVPX_REVISION" != ""; then
SUBDIRS="libvpx $SUBDIRS"
fi
if test "$FFMPEG_SUPPORT_MP3" = 1 && test "$ENABLE_LAME" = 1; then
SUBDIRS="lame $SUBDIRS"
fi
debug "SUBDIRS = $SUBDIRS"
# REPOLOCS Array holds the repo urls
REPOLOCS[0]="git://git.videolan.org/ffmpeg.git"
REPOLOCS[1]="git://mltframework.org/mlt.git"
REPOLOCS[2]="git://code.dyne.org/frei0r.git"
REPOLOCS[3]="git://git.videolan.org/x264.git"
REPOLOCS[4]="http://git.chromium.org/webm/libvpx.git"
REPOLOCS[5]="git://mltframework.org/swfdec.git"
REPOLOCS[6]="http://downloads.sourceforge.net/project/lame/lame/3.98.4/lame-3.98.4.tar.gz"
REPOLOCS[7]="git://gitorious.org/mltframework/shotcut.git"
# REPOTYPE Array holds the repo types. (Yes, this might be redundant, but easy for me)
REPOTYPES[0]="git"
REPOTYPES[1]="git"
REPOTYPES[2]="git"
REPOTYPES[3]="git"
REPOTYPES[4]="git"
REPOTYPES[5]="git"
REPOTYPES[6]="http-tgz"
REPOTYPES[7]="git"
# And, set up the revisions
REVISIONS[0]=""
if test 0 = "$FFMPEG_HEAD" -a "$FFMPEG_REVISION" ; then
REVISIONS[0]="$FFMPEG_REVISION"
fi
# Git, just use blank or the hash.
REVISIONS[1]=""
if test 0 = "$MLT_HEAD" -a "$MLT_REVISION" ; then
REVISIONS[1]="$MLT_REVISION"
fi
REVISIONS[2]=""
if test 0 = "$FREI0R_HEAD" -a "$FREI0R_REVISION" ; then
REVISIONS[2]="$FREI0R_REVISION"
fi
REVISIONS[3]=""
if test 0 = "$X264_HEAD" -a "$X264_REVISION" ; then
REVISIONS[3]="$X264_REVISION"
fi
REVISIONS[4]=""
if test 0 = "$LIBVPX_HEAD" -a "$LIBVPX_REVISION" ; then
REVISIONS[4]="$LIBVPX_REVISION"
fi
REVISIONS[5]=""
if test 0 = "$SWFDEC_HEAD" -a "$SWFDEC_REVISION" ; then
REVISIONS[5]="$SWFDEC_REVISION"
fi
REVISIONS[6]="lame-3.98.4"
REVISIONS[7]=""
if test 0 = "$SHOTCUT_HEAD" -a "$SHOTCUT_REVISION" ; then
REVISIONS[7]="$SHOTCUT_REVISION"
fi
# Figure out the install dir - we may not install, but then we know it.
FINAL_INSTALL_DIR=$INSTALL_DIR
if test 1 = "$AUTO_APPEND_DATE" ; then
FINAL_INSTALL_DIR="$INSTALL_DIR/`date +'%Y%m%d'`"
else
FINAL_INSTALL_DIR="$INSTALL_DIR/Shotcut/.usr"
fi
debug "Using install dir FINAL_INSTALL_DIR=$FINAL_INSTALL_DIR"
# Figure out the number of cores in the system. Used both by make and startup script
TARGET_OS="$(uname -s)"
if test "$TARGET_OS" = "Darwin"; then
CPUS=$(sysctl -a hw | grep "ncpu:" | cut -d ' ' -f 2)
else
CPUS=$(grep "processor.*:" /proc/cpuinfo | wc -l)
fi
# Sanity check
if test 0 = $CPUS ; then
CPUS=1
fi
MAKEJ=$(( $CPUS + 1 ))
debug "Using make -j$MAKEJ for compilation"
# CONFIG Array holds the ./configure (or equiv) command for each project
# CFLAGS_ Array holds additional CFLAGS for the configure/make step of a given project
# LDFLAGS_ Array holds additional LDFLAGS for the configure/make step of a given project
#####
# ffmpeg
CONFIG[0]="./configure --prefix=$FINAL_INSTALL_DIR --disable-doc --disable-ffserver --enable-gpl --enable-version3 --enable-shared --enable-debug --enable-pthreads --enable-runtime-cpudetect"
if test 1 = "$FFMPEG_SUPPORT_THEORA" ; then
CONFIG[0]="${CONFIG[0]} --enable-libtheora --enable-libvorbis"
fi
if test 1 = "$FFMPEG_SUPPORT_MP3" ; then
CONFIG[0]="${CONFIG[0]} --enable-libmp3lame"
fi
if test 1 = "$FFMPEG_SUPPORT_FAAC" ; then
CONFIG[0]="${CONFIG[0]} --enable-libfaac --enable-nonfree"
fi
if test 1 = "$FFMPEG_SUPPORT_H264" ; then
CONFIG[0]="${CONFIG[0]} --enable-libx264"
fi
if test 1 = "$FFMPEG_SUPPORT_LIBVPX" ; then
CONFIG[0]="${CONFIG[0]} --enable-libvpx"
fi
# Add optional parameters
CONFIG[0]="${CONFIG[0]} $FFMPEG_ADDITIONAL_OPTIONS"
CFLAGS_[0]="-I$FINAL_INSTALL_DIR/include $CFLAGS"
LDFLAGS_[0]="-L$FINAL_INSTALL_DIR/lib $LDFLAGS"
#####
# mlt
CONFIG[1]="./configure --prefix=$FINAL_INSTALL_DIR --enable-gpl --enable-linsys --swig-languages=python"
# Remember, if adding more of these, to update the post-configure check.
[ "$TARGET_OS" = "Darwin" ] && CONFIG[1]="${CONFIG[1]} --disable-jackrack"
[ "$QT_INCLUDE_DIR" ] && CONFIG[1]="${CONFIG[1]} --qimage-includedir=$QT_INCLUDE_DIR"
[ "$QT_LIB_DIR" ] && CONFIG[1]="${CONFIG[1]} --qimage-libdir=$QT_LIB_DIR"
if test "1" = "$MLT_DISABLE_SOX" ; then
CONFIG[1]="${CONFIG[1]} --disable-sox"
fi
CFLAGS_[1]="-I$FINAL_INSTALL_DIR/include $CFLAGS"
# Temporary patch until makefile for MLT corrected?
#CFLAGS_[1]="${CFLAGS_[1]} -I$FINAL_INSTALL_DIR/include/libavcodec/ -I$FINAL_INSTALL_DIR/include/libavformat/ -I$FINAL_INSTALL_DIR/include/libswscale/ -I$FINAL_INSTALL_DIR/include/libavdevice"
LDFLAGS_[1]="-L$FINAL_INSTALL_DIR/lib $LDFLAGS"
# Note in the above, that we always looks for frei0r. User can do own install
# it will be picked up.
####
# frei0r
CONFIG[2]="./configure --prefix=$FINAL_INSTALL_DIR"
CFLAGS_[2]=$CFLAGS
LDFLAGS_[2]=$LDFLAGS
####
# x264
CONFIG[3]="./configure --prefix=$FINAL_INSTALL_DIR --disable-lavf --disable-ffms --disable-gpac --disable-swscale --enable-shared"
CFLAGS_[3]=$CFLAGS
[ "$TARGET_OS" = "Darwin" ] && CFLAGS_[3]="-I. -fno-common -read_only_relocs suppress ${CFLAGS_34]} "
LDFLAGS_[3]=$LDFLAGS
####
# libvpx
CONFIG[4]="./configure --prefix=$FINAL_INSTALL_DIR --enable-vp8 --enable-postproc --enable-multithread --enable-runtime-cpu-detect --disable-install-docs --disable-debug-libs --disable-examples"
[ "$TARGET_OS" = "Linux" ] && CONFIG[4]="${CONFIG[4]} --enable-shared"
CFLAGS_[4]=$CFLAGS
# [ "$TARGET_OS" = "Darwin" ] && CFLAGS_[5]="-I. -fno-common -read_only_relocs suppress ${CFLAGS_[4]} "
LDFLAGS_[4]=$LDFLAGS
#####
# swfdec
CONFIG[5]="./configure --prefix=$FINAL_INSTALL_DIR --disable-gtk --disable-gstreamer"
CFLAGS_[5]=$CFLAGS
LDFLAGS_[5]=$LDFLAGS
#####
# lame
CONFIG[6]="./configure --prefix=$FINAL_INSTALL_DIR --disable-decoder --disable-frontend"
CFLAGS_[6]=$CFLAGS
LDFLAGS_[6]=$LDFLAGS
#####
# lame
CONFIG[7]="qmake"
CFLAGS_[7]=$CFLAGS
LDFLAGS_[7]=$LDFLAGS
}
######################################################################
# FEEDBACK FUNCTIONS
######################################################################
#################################################################
# feedback_init
# $1 : ProgressBar maximum
# Resets the progressbar or textual output based on DCOPREF
function feedback_init {
trace "Entering feedback_init @ = $@"
case $DCOPREF in
none)
log Total number of steps needed to complete $1
log Press Ctrl+C to abort
;;
kdialog*)
cmd dcop $DCOPREF ProgressDialog setTotalSteps $1 || \
warn Unable to setTotalSteps on ProgressBar
cmd dcop $DCOPREF ProgressDialog showCancelButton true || \
warn Unable to show Cancel button on kdialog instance
;;
kmdr*)
cmd dcop $DCOPREF KommanderIf setMaximum ProgressBar $1 || \
warn Unable to setMaximum on ProgressBar
;;
esac
PROGRESS=0
feedback_set_progress $PROGRESS
}
#################################################################
# feedback_progress
# $1 : ProgressBar position
# Sets the progressbar position or textual output based on DCOPREF
function feedback_set_progress {
trace "Entering feedback_set_progress @ = $@"
case $DCOPREF in
none)
log Number of steps completed : $1
;;
kdialog*)
cmd dcop $DCOPREF ProgressDialog setProgress $1 || \
warn Unable to setProgress on ProgressBar
;;
kmdr*)
cmd dcop $DCOPREF KommanderIf setText ProgressBar $1 || \
warn Unable to setProgress on ProgressBar
;;
esac
}
#################################################################
# feedback_status
# $@ status information
# Displays/Appends status, based on DCOPREF
function feedback_status {
trace "Entering feedback_status @ = $@"
# Need to collect $@ in a single variable for cmd to work
ARG=$@
log "$ARG"
}
#################################################################
# feedback_result
# $1 : SUCCESS, FAILURE, ABORTED
# $2 : Additional information
# Does the relevant feedback, and terminates.
function feedback_result {
trace "Entering feedback_result @ = $@"
# If needed, kill the checker process
if test "" != "$CHECKERPID" ; then
# Kill the checker process
kill -9 $CHECKERPID &> /dev/null
fi
log "Process has finished. Reason: $@"
}
#################################################################
# feedback_progress
# $@ : Description of task completed
# Increases the progressbar with 1 and sets the status to $@
function feedback_progress {
trace "Entering feedback_progress @ = $@"
PROGRESS=$(( $PROGRESS + 1 ))
feedback_status $@
feedback_set_progress $PROGRESS
}
#################################################################
# prepare_feedback
# Function to prepare the feedback. E.g. set up max progress steps
# Based on configuration read and the DCOPREF variable
function prepare_feedback {
trace "Entering prepare_feedback @ = $@"
# Figure out the number of steps
# Get adds 8 if cleaning, 4 otherwise (2/1 pr. proj)
# Compile/Install adds 12 (3/proj)
# Script install adds 1
NUMSTEPS=0
if test 1 = "$GET" ; then
debug Adding 3 steps for get
NUMSTEPS=$(( $NUMSTEPS + 3 ))
if test 1 = "$ENABLE_FREI0R" ; then
debug Adding 1 step for get frei0r
NUMSTEPS=$(( $NUMSTEPS + 1 ))
fi
if test 1 = "$ENABLE_SWFDEC" ; then
debug Adding 1 step for get swfdec
NUMSTEPS=$(( $NUMSTEPS + 1 ))
fi
fi
if test 1 = "$GET" -a 1 = "$SOURCES_CLEAN" ; then
debug Adding 3 steps for clean on get
NUMSTEPS=$(( $NUMSTEPS + 3 ))
if test 1 = "$ENABLE_FREI0R" ; then
debug Adding 1 step for clean frei0r
NUMSTEPS=$(( $NUMSTEPS + 1 ))
fi
if test 1 = "$ENABLE_SWFDEC" ; then
debug Adding 1 step for clean swfdec
NUMSTEPS=$(( $NUMSTEPS + 1 ))
fi
fi
if test 1 = "$COMPILE_INSTALL" ; then
debug Adding 9 steps for compile-install
NUMSTEPS=$(( $NUMSTEPS + 9 ))
if test 1 = "$ENABLE_FREI0R" ; then
debug Adding 3 steps for compile-install frei0r
NUMSTEPS=$(( $NUMSTEPS + 3 ))
fi
if test 1 = "$ENABLE_SWFDEC" ; then
debug Adding 3 steps for compile-install swfdec
NUMSTEPS=$(( $NUMSTEPS + 3 ))
fi
fi
if test 1 = "$CREATE_STARTUP_SCRIPT" ; then
debug Adding 1 step for script creating
NUMSTEPS=$(( $NUMSTEPS + 1 ))
fi
log Number of steps determined to $NUMSTEPS
feedback_init $NUMSTEPS
}
#################################################################
# check_abort
# Function that checks if the user wanted to cancel what we are doing.
# returns "stop" or "cont" as appropiate
function check_abort {
# log "$ARG"
echo
}
######################################################################
# GLOBAL TEST FUNCTIONS
######################################################################
#################################################################
# is_newer_equal
# Compares versions strings, and returns 1 if $1 is newer than $2
# This is highly ineffective, I am sorry to say...
function is_newer_equal {
trace "Entering is_newer_equal @ = $@"
A1=`echo $1 | cut -d. -f1`
A2=`echo $1 | cut -d. -f2`
A3=`echo $1 | cut -d. -f3 | sed 's/^\([0-9]\{1,3\}\).*/\1/'`
B1=`echo $2 | cut -d. -f1`
B2=`echo $2 | cut -d. -f2`
B3=`echo $2 | cut -d. -f3 | sed 's/^\([0-9]\{1,3\}\).*/\1/'`
debug "A = $A1 $A2 $A3, B = $B1 $B2 $B3"
test "$A1" -gt "$B1" -o \( "$A1" = "$B1" -a "$A2" -gt "$B2" \) -o \( "$A1" = "$B1" -a "$A2" = "$B2" -a "$A3" -ge "$B3" \)
}
######################################################################
# ACTION GET FUNCTIONS
######################################################################
#################################################################
# make_clean_dir
# Make clean in a specific directory
# $1: The directory to make clean in.
# Any errors are ignored. Make clean is only called if cd success.
# Assumes cwd is common parent dir
function make_clean_dir {
trace "Entering make_clean_dir @ = $@"
log Make clean for $1 called
feedback_status "Cleaning out sources for $1"
cmd pushd .
# Special hack for ffmpeg, it sometimes requires distclean to work.
if test "ffmpeg" = "$1" ; then
cmd cd $1 && cmd make distclean
else
cmd cd $1 && cmd make clean
fi
feedback_progress Cleaned up in $1
cmd popd
}
#################################################################
# clean_dirs
# Make clean in all directories
function clean_dirs {
trace "Entering clean_dirs @ = $@"
feedback_status Cleaning out all subdirs
cmd cd $SOURCE_DIR || mkdir -p $SOURCE_DIR
cmd cd $SOURCE_DIR || die "Unable to change to directory $SOURCE_DIR"
for DIR in $SUBDIRS ; do
make_clean_dir $DIR
done
feedback_status Done cleaning out in source dirs
}
#################################################################
# get_subproject
# $1 The sourcedir to get sources for
# Get the sources for a single project
# Assumes cwd is common parent dir
# Errors abort
function get_subproject {
trace "Entering get_subproject @ = $@"
feedback_status Getting or updating source for $1 - this could take some time
cmd pushd .
# Check for repository setyp
REPOTYPE=`lookup REPOTYPES $1`
REPOLOC=`lookup REPOLOCS $1`
REVISION=`lookup REVISIONS $1`
debug "REPOTYPE=$REPOTYPE, REPOLOC=$REPOLOC, REVISION=$REVISION"
# Note that svn can check out to current directory, whereas git will not. Sigh.
if test "git" = "$REPOTYPE" ; then
# If the dir is there, check if it is a git repo
if test -d "$1" ; then
# Change to it
cmd cd $1 || die "Unable to change to directory $1"
debug "About to look for git repo"
git --no-pager status 2>&1 | grep "fatal" &> /dev/null
if test 0 != $? ; then
# Found git repo
debug "Found git repo, will update"
feedback_status "Pulling git sources for $1"
cmd git reset --hard || die "Unable to reset git tree for $1"
cmd git checkout master || die "Unable to git checkout master"
cmd git --no-pager pull $REPOLOC master || die "Unable to git pull sources for $1"
cmd git checkout $REVISION || die "Unable to git checkout $REVISION"
else
# A dir with the expected name, but not a git repo, bailing out
PWD=`pwd`
die "Found a dir with the expected name $1 ($PWD), but it was not a git repo. Unable to proceed. If you have old mlt/mlt++ sources, please delete these directories, before rerunning the script."
fi
else
# No git repo
debug "No git repo, need to check out"
feedback_status "Cloning git sources for $1"
DEPTH="--depth 1"
# mltframework.org git does not yet support depth option
echo $REPOLOC | grep mltframework &> /dev/null
test 0 = $? && DEPTH=""
# webmproject.org git does not yet support depth option
echo $REPOLOC | grep webmproject &> /dev/null
test 0 = $? && DEPTH=""
cmd git --no-pager clone $DEPTH $REPOLOC || die "Unable to git clone source for $1 from $REPOLOC"
cmd cd $1 || die "Unable to change to directory $1"
cmd git checkout $REVISION || die "Unable to git checkout $REVISION"
fi
elif test "svn" = "$REPOTYPE" ; then
# Create subdir if not exist
if test ! -d "$1" ; then
cmd mkdir -p $1 || die "Unable to create directory $1"
fi
# Change to it
cmd cd $1 || die "Unable to change to directory $1"
FIND_STR="\(Revision\|Last\ Changed\ Date\)"
debug "About to look for SVN revision info for $REPOLOC $REVISION"
svn --non-interactive info | grep "$FIND_STR"
if test 0 = $? ; then
debug "Found existing SVN checkout"
# Found svn info
# For KDENLIVE: If the svn info URL matches the one we have in the REPOLOCS array, do an update, otherwise, do a switch.
REPOLOCURL=`svn --non-interactive info | grep URL | awk '{print $2}'`
# Now, we have to be a bit clever here, because if the user originally checked it out using
# https, we can not change to http. So, we check for https in the current URL
# Note, that beeing clever almost always fails at some point. But, at least we give it a try...
if test "${REPOLOCURL:0:5}" = "https" ; then
REPOLOC=${REPOLOC/http/https}
fi
if test "kdenlive" = "$1" -a $REPOLOCURL != $REPOLOC ; then
warn "Existing url $REPOLOCURL for $1 does not match the url for selected version: $REPOLOC. Trying svn switch to update"
feedback_status "Trying to switch repo url for $1"
cmd svn --non-interactive switch $REPOLOC $REVISION || die "Unable to switch svn repo from $REPOLOCURL to $REPOLOC $REVISION"
else
feedback_status "Updating SVN sources for $1"
cmd svn --non-interactive update $REVISION || die "Unable to update SVN repo in $1 to $REVISION"
fi
else
# No svn info
feedback_status "Getting SVN sources for $1"
cmd svn --non-interactive co $REPOLOC . $REVISION || die "Unable to get SVN source for $1 from $REPOLOC $REVISION"
fi
elif test "http-tgz" = "$REPOTYPE" ; then
if test ! -d "$1" ; then
feedback_status "Downloading archive for $1"
which curl > /dev/null
if test 0 = $?; then
cmd $(curl -L $REPOLOC | tar -xz) || die "Unable to download source for $1 from $REPOLOC"
else
which wget > /dev/null
if test 0 = $?; then
cmd $(wget -O - $REPOLOC | tar -xz) || die "Unable to download source for $1 from $REPOLOC"
fi
fi
cmd mv "$REVISION" "$1" || due "Unable to rename $REVISION to $1"
fi
fi # git/svn
feedback_progress Done getting or updating source for $1
cmd popd
}
#################################################################
# get_all_sources
# Gets all the sources for all subprojects
function get_all_sources {
trace "Entering get_all_sources @ = $@"
feedback_status Getting all sources
log Changing to $SOURCE_DIR
cd $SOURCE_DIR || mkdir -p "$SOURCE_DIR"
cd $SOURCE_DIR || die "Unable to change to directory $SOURCE_DIR"
for DIR in $SUBDIRS ; do
get_subproject $DIR
done
feedback_status Done getting all sources
}
######################################################################
# ACTION COMPILE-INSTALL FUNCTIONS
######################################################################
#################################################################
# mlt_format_required
# log a string that expresses a requirement
function mlt_format_required {
log 'MLTDISABLED <b>'$1'</b> : this is a <b>required</b> module. '$2'Will abort compilation.'
}
#################################################################
# mlt_format_optional
# log a string that expresses missing an optional
function mlt_format_optional {
log 'MLTDISABLED <b>'$1'</b> : this is an <b>optional</b> module that provides '$2'. To enable it, try installing a package called something like '$3'.'
}
#################################################################
# mlt_check_configure
# This is a special hack for mlt. Mlt does not allow --enable, or abort
# if something is missing, so we check all the disable files. Some are
# optional, some are required. We stop compilation if a required file is
# missing. For optionals, we report them to the log
# Oh, and it is assumed we are in the toplevel mlt source directory, when
# this is called.
function mlt_check_configure {
trace "Entering check_mlt_configure @ = $@"
cmd pushd .
DODIE=0
cmd cd src/modules || die "Unable to check mlt modules list"
for FILE in `ls disable-* 2>/dev/null` ; do
debug "Checking $FILE"
case $FILE in
# REQUIRED
disable-core)
mlt_format_required core "I have no idea why this was disabled. "
DODIE=1
;;
disable-avformat)
mlt_format_required avformat "Did ffmpeg installation fail? "
DODIE=1
;;
disable-xml)
mlt_format_required xml "Please install libxml2-dev. "
DODIE=1
;;
disable-sdl)
mlt_format_required sdl "Please install libsdl1.2-dev. "
DODIE=1
;;
disable-qimage)
mlt_format_required qimage "Please provide paths for QImage on the 'Compile options' page. "
DODIE=1
;;
# AUDIO
disable-sox)
if test "0" = "$MLT_DISABLE_SOX" ; then
mlt_format_optional sox "sound effects/operations" "sox-dev"
DODIE=1
fi
;;
disable-jackrack)
mlt_format_optional jackrack "sound effects/operations" "libjack-dev"
;;
disable-resample)
mlt_format_optional resample "audio resampling" "libsamplerate0-dev"
;;
# IMAGE
disable-gtk2)
mlt_format_optional gtk2 "some additional image loading support" "libgtk2-dev?"
;;
disable-kdenlive)
mlt_format_optional kdenlive "slow motion and freeze effects" "??"
;;
disable-frei0r)
mlt_format_optional frei0r "plugin architecture. Several additional effects and transitions" "see http://www.piksel.org/frei0r"
;;
# OTHERS
disable-dv)
mlt_format_optional dv "loading and saving of DV files" "libdv/libdv-dev"
;;
disable-vorbis)
mlt_format_optional vorbis "loading and saving ogg/theora/vorbis files" "libvorbis-dev"
;;
# FALLBACK
disable-*)
mlt_format_optional ${FILE/disable-} "... dunno ... " "... dunno ..."
;;
esac
done
if test 1 = "$DODIE" ; then
die "One or more required MLT modules could not be enabled"
fi
cmd popd
}
#################################################################
# configure_compile_install_subproject
# $1 The sourcedir to configure, compile, and install
# Configures, compiles, and installs a single subproject.
# Assumes cwd is common parent dir
# Errors abort
function configure_compile_install_subproject {
trace "Entering configure_compile_install_subproject @ = $@"
feedback_status Configuring, compiling, and installing $1
OLDCFLAGS=$CFLAGS
OLDLD_LIBRARY_PATH=$LD_LIBRARY_PATH
cmd pushd .
# Change to right directory
cmd cd $1 || die "Unable to change to directory $1"
# Set cflags, log settings
log PATH=$PATH
log LD_RUN_PATH=$LD_RUN_PATH
log PKG_CONFIG_PATH=$PKG_CONFIG_PATH
export CFLAGS=`lookup CFLAGS_ $1`
log CFLAGS=$CFLAGS
export LDFLAGS=`lookup LDFLAGS_ $1`
log LDFLAGS=$LDFLAGS
# Configure
feedback_status Configuring $1
# Special hack for libvpx
if test "libvpx" = "$1" ; then
cmd make clean
fi
# Special hack for frei0r
if test "frei0r" = "$1" -a ! -e configure ; then
debug "Need to create configure for $1"
cmd ./autogen.sh || die "Unable to create configure file for $1"
if test ! -e configure ; then
die "Unable to confirm presence of configure file for $1"
fi
fi
# Special hack for swfdec
if test "swfdec" = "$1" ; then
debug "Need to create configure for $1"
cmd autoreconf -i || die "Unable to create configure file for $1"
if test ! -e configure ; then
die "Unable to confirm presence of configure file for $1"
fi
fi
cmd `lookup CONFIG $1` || die "Unable to configure $1"
feedback_progress Done configuring $1
# Special hack for mlt, post-configure
if test "mlt" = "$1" ; then
mlt_check_configure
fi
# Compile
feedback_status Building $1 - this could take some time
cmd make -j$MAKEJ || die "Unable to build $1"
feedback_progress Done building $1
# Install
feedback_status Installing $1
# This export is only for kdenlive, really, and only for the install step
export LD_LIBRARY_PATH=`lookup LD_LIBRARY_PATH_ $1`
log "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
if test "1" = "$NEED_SUDO" ; then
debug "Needs to be root to install - trying"
log About to run $SUDO make install
TMPNAME=`mktemp -t build-shotcut.installoutput.XXXXXXXXX`
# At least kdesudo does not return an error code if the program fails
# Filter output for error, and dup it to the log
# Special hack for libvpx
if test "shotcut" = "$1" ; then
$SUDO install -c -m 755 shotcut "$FINAL_INSTALL_DIR"
else
$SUDO make install > $TMPNAME 2>&1
fi
cat $TMPNAME 2>&1
# If it contains error it returns 0. 1 matches, 255 errors
# Filter X errors out too
grep -v "X Error" $TMPNAME | grep -i error 2>&1
if test 0 = $? ; then
die "Unable to install $1"
fi
else
if test "shotcut" = "$1" ; then
cmd install -c -m 755 shotcut "$FINAL_INSTALL_DIR"/bin
cmd install -d "$FINAL_INSTALL_DIR"/lib/qt4
cmd install -p -c /usr/lib/libQt{Core,Gui,Xml,Svg}.so* "$FINAL_INSTALL_DIR"/lib
cmd install -p -c /usr/lib/libaudio.so* "$FINAL_INSTALL_DIR"/lib
cmd cp -r /usr/lib/qt4/plugins/* "$FINAL_INSTALL_DIR"/lib/qt4
else
cmd make install || die "Unable to install $1"