forked from wolfgangw/digital_cinema_tools_distribution
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdigital-cinema-tools-setup
executable file
·957 lines (885 loc) · 28 KB
/
digital-cinema-tools-setup
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
#!/usr/bin/env bash
set -e
setup_version='v1.2014.12.16'
#
# Usage:
#
# * Ubuntu / Debian / Mint / Raspbian / openSuSE: Run
# wget http://git.io/digital-cinema-tools-setup && bash digital-cinema-tools-setup
# in a terminal
#
# * Fedora: Run
# curl -sLO http://git.io/digital-cinema-tools-setup && bash digital-cinema-tools-setup
# in a terminal
#
# * For updates or re-runs run
# digital-cinema-tools-setup
# in a terminal
#
# This setup script will install everything required (batteries included) to run
#
# * dcp_inspect: Inspect and validate digital cinema packages (DCPs)
# See https://github.com/wolfgangw/backports#readme
#
# * cinemaslides: Build plaintext/encrypted digital cinema packages (DCPs)
# and generate key delivery messages (KDMs)
# See https://github.com/wolfgangw/digital_cinema_tools/wiki/Cinemaslides
#
# and a number of other digital cinema-related tools:
#
# * db_adjust_for_dolby_fader_ref.rb: Calculate adjustments for Dolby CP650/750 7.0 setting
# * dc_crypto_context.rb: Check certificate chains for digital cinema compliance
# * kdm-decrypt.rb: Decrypt Interop/SMPTE KDMs
# * make-dc-certificate-chain.rb: Generate an example digital cinema compliant certificate chain
# * public_key_thumbprint.rb: Compute dnQualifier/public key thumbprint of a X.509 certificate
# * signature_check.rb: Check XML signatures of DCP infrastructure documents
# * x509_extract.rb: Extract X.509 certificates from digital cinema documents
# * x509_inspect.rb: Inspect X.509 certificates
# * xsd-check.rb: Validate XML documents against Schema definitions
#
# This installer supports Debian / Ubuntu / Fedora / openSUSE systems
# Needs a working network connection
#
# It tries hard not to break anything and to respect the existing environment.
# You can run it multiple times, should anything go wrong during a setup run (network problems etc.)
#
# Wolfgang Woehl 2012-2013
#
#
# Location of self
#
setup_dirname=$( cd "$(dirname "${BASH_SOURCE[0]}")" && pwd )
setup_basename=$(basename ${BASH_SOURCE[0]})
setup_fullpath="$setup_dirname/$setup_basename"
echo "$setup_basename $setup_version"
bashrc=$HOME/.bashrc
bash_profile=$HOME/.bash_profile
inputrc=$HOME/.inputrc
script_runner=$(whoami)
basedir=$HOME/.digital_cinema_tools
libdir=$basedir/.lib
bindir=$basedir/.bin
# Ruby version management: rbenv
rbenv_url="git://github.com/sstephenson/rbenv.git"
export RBENV_ROOT=$libdir/.rbenv
rbenv_dir=$RBENV_ROOT
rbenv_plugins_dir=$rbenv_dir/plugins
# Ruby build system: ruby-build
rubybuild_url="git://github.com/sstephenson/ruby-build.git"
rubybuild_dir=$rbenv_plugins_dir/ruby-build
ruby_version='2.1.5'
gemrc=$HOME/.gemrc
# JPEG2000 codec: OpenJPEG
# http://openjpeg.googlecode.com/files/openjpeg-1.5.0.tar.gz (SHA1 dce705ae45f137e4698a8cf39d1fbf22bc434fa8)
# http://openjpeg.googlecode.com/files/openjpeg-2.0.0.tar.gz (SHA1 0af78ab2283b43421458f80373422d8029a9f7a7)
opj_googlecode='openjpeg.googlecode.com'
openjpeg_version='1.5.0'
openjpeg_tarball="openjpeg-$openjpeg_version.tar.gz"
openjpeg_tarball_url="http://$opj_googlecode/files/$openjpeg_tarball"
openjpeg_dir=$libdir/openjpeg
openjpeg_build_dir="$openjpeg_dir/openjpeg-$openjpeg_version"
openjpeg_install_dir=$bindir/openjpeg
# Handle SMPTE and Interop trackfiles: ASDCPLib
cinecert='download.cinecert.com/asdcplib'
asdcplib_version='1.12.58'
asdcplib_version_tarball_md5='95f3aa8712a7590fccff60f026659dbe'
asdcplib_tarball="asdcplib-$asdcplib_version.tar.gz"
asdcplib_tarball_url="http://$cinecert/$asdcplib_tarball"
asdcplib_dir=$libdir/asdcplib
asdcplib_build_dir="$asdcplib_dir/asdcplib-$asdcplib_version"
asdcplib_install_dir=$bindir/asdcplib
# Digital cinema tools distribution: cinemaslides, dcp_inspect etc.
dist_url="git://github.com/wolfgangw/digital_cinema_tools_distribution.git"
dist_dir=$libdir/digital_cinema_tools_distribution
errors=()
exec_shell_required=false
command_exists() {
type "$1" &> /dev/null
}
location_exists() {
[ -e "$1" ]
}
string_includes() {
[[ "$1" =~ "$2" ]]
}
echo_last() {
local arr=("${!1}")
echo ${arr[${#arr[@]}-1]}
}
remove_if_exists() {
if location_exists $1
then
rm -rf $1
fi
}
location_is_git_repo() {
location_exists "$1" && location_exists "$1/.git" && [ -d "$1/.git" ]
}
# Only linux systems in mind for now
if [[ ! $MACHTYPE = *linux* ]]
then
echo "This installer supports only linux systems"
exit 1
fi
# Check and bail out if the installer is run with root privileges
if [ $script_runner == "root" ]
then
echo
echo 'Do not run this installer as root'
echo 'Do not run this installer via sudo'
echo 'This installer will ask for privileges if and when required'
echo
echo 'That said:'
echo
echo 'If you know exactly why you would want to'
echo "continue as root -- usually you don't want to --"
read -p 'then type root and press [ENTER]: ' run_as_root_confirm
if ! [ "$run_as_root_confirm" == "root" ]
then
exit 1
fi
echo 'Continuing as root ...'
sleep 3
fi
#
# Which OS distribution are we on?
#
# Who'da thunk it that figuring out OS would be so messy:
#
# - Fedora has lsb_release and *-release files pre-installed,
# - Ubuntu doesn't have lsb_release initially, has os-release and lsb-release
# - openSuSE has os-release, SuSE-release and lsb_release
# - Debian 6.0.4 has lsb_release but no *-release files
# - Mint 15 has lsb_release and lsb-release
# - Raspbian (Debian 7) has os-release and no lsb*
#
if [ -f /etc/os-release ] && grep -P 'Debian' /etc/os-release &> /dev/null
then
os_dist=debian
elif [ -f /etc/fedora-release ]
then
os_dist=redhat
elif [ -f /etc/redhat-release ]
then
os_dist=redhat
elif [ -f /etc/SuSE-release ]
then
os_dist=opensuse
elif [ -f /etc/lsb-release ] && grep -P 'Ubuntu' /etc/lsb-release &> /dev/null
then
os_dist=ubuntu
elif [ -f /etc/lsb-release ] && grep -P 'LinuxMint' /etc/lsb-release &> /dev/null
then
os_dist=ubuntu
elif command_exists lsb_release
then
# do the debian thing here lsb_release -a, -i, -r ...
if [[ "$(lsb_release --id)" =~ Debian ]]
then
os_dist=debian
fi
fi
# Bail out if non-supported OS distribution
if ! [ -z $os_dist ]
then
echo "OS: $os_dist"
else
echo 'OS not supported'
exit 1
fi
# Bail out if we don't have sudo
if command_exists sudo
then
case $os_dist in
debian)
if echo `groups` | grep sudo &>/dev/null
then
echo "$os_dist: sudo OK"
else
echo "$os_dist: sudo: Need to be member of the sudo group."
echo
echo 'Run the following 3 commands:'
echo
echo "su - # will prompt for your root password"
echo "adduser `whoami` sudo # Adds you to the sudo group"
echo 'exit # exits from root account'
echo
echo 'Then log out or reboot'
echo 'Then re-run digital-cinema-tools-setup'
echo
exit 1
fi
esac
else
echo 'Required command "sudo" not found. Please install sudo'
exit 1
fi
# Depending on which OS we're on set the required packager and switches
# to install a basic set of packages from distribution sources
case $os_dist in
debian|ubuntu)
query='dpkg-query'
query_params='-s'
packager='apt-get'
packager_params='-y install'
# build-essential odd ..
packages_required=( build-essential curl libxslt1-dev libxml2-dev libexpat1-dev xmlsec1 libreadline-dev zlib1g zlib1g-dev libssl-dev imagemagick mplayer sox git-core libtiff4-dev libpng12-dev )
packager_prep="$packager update"
;;
redhat)
query='rpm'
query_params='--query'
packager='yum'
packager_params='-y install'
packages_required=( make automake gcc gcc-c++ wget libxslt-devel expat-devel xmlsec1 xmlsec1-openssl readline-devel zlib-devel openssl-devel ImageMagick mplayer sox git libtiff-devel libpng-devel )
;;
opensuse)
query='zypper'
query_params='--no-refresh se -i'
packager='zypper'
packager_params='--gpg-auto-import-keys --non-interactive install'
packages_required=( make automake gcc gcc-c++ libxslt-devel libexpat-devel libxmlsec1-openssl-devel xmlsec1 readline-devel zlib-devel openssl-devel ImageMagick mplayer sox git libtiff-devel libpng12-devel )
esac
# Check for the presence of required basic distribution packages
if command_exists $query && command_exists $packager
then
packages_missing=()
for package in ${packages_required[@]}
do
if $query $query_params $package &> /dev/null
then
echo "$package: OK"
else
echo "$package: Installation required"
packages_missing+=($package)
fi
done
if [ ${#packages_missing[@]} -gt 0 ]
then
echo
echo "$setup_basename: ${#packages_missing[@]} packages missing"
echo "$setup_basename: ${packages_missing[@]}"
echo
case $os_dist in
debian|ubuntu)
echo "Please enter your password" ;;
redhat|opensuse)
echo 'Please enter your root password' ;;
esac
# Some distributions need extra repositories
case $os_dist in
redhat)
# Special case Fedora/MPlayer: Provided by RPMFusion repository. Add the repo
# See repo keys and fingerprints on http://rpmfusion.org/keys
repo_rpmfusion_free='http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm'
repo_rpmfusion_nonfree='http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm'
if ! sudo $packager -y localinstall $repo_rpmfusion_free $repo_rpmfusion_nonfree
then
errors+=("$os_dist: Failed to add RPMFusion repositories (required for mplayer)") && echo_last errors[@]
else
echo "$os_dist: RPMFusion repositories (required for mplayer) OK"
fi
;;
opensuse)
# openSuSE seems to be a special case in its entirety:
# In a default installation there is no access to any "devel" packages
# and crucial stuff lives on packman. Go figure.
if command_exists lsb_release
then
os_info_blob_thank_you_very_much=`lsb_release -a`
elif [ -f /etc/SuSE-release ]
then
os_info_blob_thank_you_very_much=`cat /etc/SuSE-release`
elif [ -f /etc/os-release ]
then
os_info_blob_thank_you_very_much=`cat /etc/os-release`
fi
case $os_info_blob_thank_you_very_much in
*11.4*)
os_dist_version='11.4'
;;
*12.1*)
os_dist_version='12.1'
;;
*)
echo 'Sorry, openSuSE 12.1 and 11.4 support only for now'
exit 1
;;
esac
repo_packman="http://packman.inode.at/suse/openSUSE_$os_dist_version"
if ! sudo $packager ar -f -n packman $repo_packman packman && $packager refresh
then
errors+=("$os_dist $os_dist_version: Failed to add Packman repositories") && echo_last errors[@]
else
echo "$os_dist $os_dist_version: Packman repositories OK"
fi
esac
# Install packages
if ! [ -z "$packager_prep" ]
then
if ! sudo $packager_prep
then
errors+=("$setup_basename: Failed to prepare package installation") && echo_last errors[@]
else
echo "$setup_basename: Package preparation OK"
fi
fi
if ! sudo $packager $packager_params "${packages_missing[@]}"
then
errors+=("$packager: Failed to install basic requirements") && echo_last errors[@]
sudo -K # drop sudo privileges
exit 1
else
echo "$packager: OK"
fi
sudo -K
fi
else
errors+=("$setup_basename: Required packager tools not found: $query/$packager. Exiting") && echo_last errors[@]
exit 1
fi
# Set up directories for digital cinema tools
if ! location_exists $basedir ; then mkdir $basedir ; fi
if ! location_exists $libdir ; then mkdir $libdir ; fi
if ! location_exists $bindir ; then mkdir $bindir ; fi
# Source .bash_profile from .bashrc
if grep -P '^(source|\.) .*/.bash_profile' $bashrc
then
echo 'bashrc: OK'
else
# Fedora sources ~/.bashrc from ~/.bash_profile so we loop source if we add the following
if [ $os_dist = 'ubuntu' -o $os_dist = 'debian' ]
then
echo "$setup_basename: Source ~/.bash_profile from ~/.bashrc"
echo '' >> $bashrc
echo "# $setup_basename: Use .bash_profile to read rbenv environment" >> $bashrc
echo 'source $HOME/.bash_profile' >> $bashrc
if ! [ -f $bash_profile ]
then
touch $bash_profile
echo 'bash_profile: Touched'
fi
exec_shell_required=true
fi
fi
# Check for ~/bin and inclusion in PATH
if string_includes $PATH "$bindir"
then
echo "PATH: $bindir available in PATH"
else
if grep -P "export PATH=$bindir:" $bashrc $bash_profile
then
echo "bashrc: $bindir already included. OK"
else
echo "bashrc: Adding $bindir to PATH"
echo '' >> $bashrc
echo "# $setup_basename: Add $bindir to PATH" >> $bashrc
echo "export PATH=$bindir:"'$PATH' >> $bashrc
fi
exec_shell_required=true
fi
source $bashrc
# rbenv
if command_exists rvm
then
echo
echo "Sorry. This installer insists on using rbenv for Ruby version management."
echo "You have RVM installed and those 2 won't co-exist peacefully, so there."
echo "If you want to continue remove RVM from your system and re-run this installer."
echo
exit 1
fi
if command_exists rbenv
then
echo "rbenv: OK"
else
if location_exists $rbenv_dir && location_exists $rbenv_dir/.git
then
echo "rbenv: Repository exists"
if string_includes $PATH "$rbenv_dir/bin"
then
echo "rbenv: PATH includes rbenv bin dir"
else
errors+=("rbenv: PATH does not include rbenv bin dir") && echo_last errors[@]
fi
else
echo "rbenv: Installing"
remove_if_exists $rbenv_dir
if ! git clone $rbenv_url $rbenv_dir
then
errors+=("rbenv: Failed to clone repository. Try again later") && echo_last errors[@]
fi
case $os_dist in
debian|ubuntu)
env_target=$bash_profile ;;
redhat|opensuse)
env_target=$bashrc ;;
esac
echo '' >> $env_target
echo "# $setup_basename: rbenv environment" >> $env_target
echo "export RBENV_ROOT=$rbenv_dir" >> $env_target
echo "export PATH=$rbenv_dir/bin:"'$PATH' >> $env_target
echo 'eval "$(rbenv init -)"' >> $env_target
source $env_target
exec_shell_required=true
if command_exists rbenv
then
echo "rbenv: OK"
else
echo "rbenv: Command 'rbenv' not found"
exit 1
fi
fi
fi
# gems: ri/rdoc switches
if [ -e $gemrc ]
then
if grep -P '^gem: --no-ri --no-rdoc' $gemrc
then
echo 'gemrc: OK'
else
echo 'gemrc: Keeping changed gemrc (--no-ri/rdoc switches will not be added)'
fi
else
echo 'gem: --no-ri --no-rdoc' > $gemrc
fi
# ruby-build (as rbenv plugin)
if location_exists $rbenv_dir
then
if ! location_exists $rbenv_plugins_dir
then
mkdir $rbenv_plugins_dir
fi
else
mkdir -p $rbenv_plugins_dir
fi
cd $rbenv_plugins_dir
if location_is_git_repo $rubybuild_dir
then
cd $rubybuild_dir
if ! git pull
then
errors+=("ruby-build: Failed to pull updates. Try again later") && echo_last errors[@]
else
echo 'ruby-build: OK'
fi
else
remove_if_exists $rubybuild_dir
echo 'ruby-build: Installing'
if ! git clone $rubybuild_url
then
errors+=("ruby-build: Failed to clone repository. Try again later") && echo_last errors[@]
else
echo 'ruby-build: OK'
fi
fi
# Try to install a ruby version
# Explicitly set global $ruby_version
if command_exists rbenv
then
if ! rbenv global $ruby_version
then
echo 'rbenv: Required ruby not installed'
fi
if [[ `rbenv version` =~ $ruby_version ]] && command_exists ruby
then
echo "Ruby: OK"
else
echo "Ruby: Installing ... This will take a while (~5 minutes)"
if ! rbenv install $ruby_version
then
errors+=("Ruby: Failed to install requested version") && echo_last errors[@]
else
rbenv global $ruby_version
rbenv rehash
echo "Ruby: $( rbenv version )"
echo 'Ruby: OK'
fi
fi
else
errors+=("Ruby: Failed to install ruby (Required command rbenv not found)") && echo_last errors[@]
fi
# Nokogiri (with c14n)
if command_exists gem
then
if gem list -i nokogiri &> /dev/null
then
echo 'Nokogiri: Found installed gem'
else
# Install Nokogiri gem
if ! gem install nokogiri
then
errors+=("Nokogiri: Failed to install rtequired gem nokogiri") && echo_last errors[@]
else
rbenv rehash
echo 'Nokogiri: Installed gem nokogiri'
fi
fi
# Check for C14N support
if gem list -i nokogiri &> /dev/null
then
if [[ `rbenv version` =~ $ruby_version ]] && command_exists ruby
then
ruby -e "require 'rubygems'; require 'nokogiri'; if Nokogiri::XML::Document.new.respond_to?( 'canonicalize' ) then exit 0 else exit 1 ; end"
if [ $? == 0 ]
then
nokogiri_c14n=true
echo 'Nokogiri: C14N support present'
else
nokogiri_c14n=false
errors+=("Nokogiri: Installed version does not support C14N") && echo_last errors[@]
fi
else
errors+=("Nokogiri: Could not test Nokogiri C14N support (Required ruby version not found)") && echo_last errors[@]
fi
if $nokogiri_c14n
then
echo 'Nokogiri: OK'
else
errors+=("Nokogiri: There is a problem with the installed version of Nokogiri. Consider removing your installed version of Nokogiri and re-run this installer") && echo_last errors[@]
fi
fi
else
errors+=("Nokogiri: Failed to install Nokogiri (Required command gem not found)") && echo_last errors[@]
fi # Nokogiri
# openjpeg
cd $libdir
if command_exists image_to_j2k
then
echo 'openjpeg: OK'
else
echo 'openjpeg: Installing ...'
if location_exists $openjpeg_dir
then
cd $openjpeg_dir
else
mkdir $openjpeg_dir && cd $openjpeg_dir
fi
remove_if_exists $openjpeg_build_dir
if [ -e $openjpeg_tarball ]
then
echo "openjpeg: Tarball exists"
else
echo "openjpeg: Downloading tarball $openjpeg_tarball_url"
if wget $openjpeg_tarball_url
then
echo "openjpeg: Download OK"
else
if ! ping -c 1 $opj_googlecode
then
errors+=("openjpeg: $opj_googlecode seems to be down") && echo_last errors[@]
fi
errors+=("openjpeg: Failed to download tarball. Try again later") && echo_last errors[@]
fi
fi
if tar xzf $openjpeg_tarball
then
cd $openjpeg_build_dir
if ./configure --disable-doc --prefix=$openjpeg_install_dir && make -j3 && make install
then
opj_build=ok
echo "openjpeg: Build OK"
else
opj_build=fail
errors+=("openjpeg: Failed to configure, build and install") && echo_last errors[@]
fi
else
opj_build=fail
errors+=("Failed to extract tarball at $openjpeg_dir") && echo_last errors[@]
fi
fi
if [ "$opj_build" = 'ok' ]
then
cd $bindir
for tool in $openjpeg_install_dir/bin/*
do
if [ -e $bindir/$(basename ${tool}) ]
then
echo "openjpeg: $(basename ${tool}) OK"
else
echo "openjpeg: Add to $bindir: $(basename ${tool})"
ln -s $tool .
fi
done # openjpeg
fi
# asdcplib
cd $libdir
if command_exists asdcp-info && [[ `asdcp-info -V` =~ $asdcplib_version ]]
then
echo "asdcplib: OK ($asdcplib_version)"
else
echo "asdcplib: Installing $asdcplib_version ..."
if location_exists $asdcplib_dir
then
cd $asdcplib_dir
else
mkdir $asdcplib_dir && cd $asdcplib_dir
fi
remove_if_exists $asdcplib_build_dir
if [ -e $asdcplib_tarball ] && [[ $( md5sum $asdcplib_tarball | cut -d ' ' -f 1 ) =~ $asdcplib_version_tarball_md5 ]]
then
echo "asdcplib: $asdcplib_version_tarball_md5: MD5 OK"
else
if [ -e $asdcplib_tarball ]
then
rm $asdcplib_tarball
fi
echo "asdcplib: Downloading tarball $asdcplib_tarball_url"
if wget $asdcplib_tarball_url
then
echo 'asdcplib: Download OK'
if [ -e $asdcplib_tarball ] && [[ $( md5sum $asdcplib_tarball | cut -d ' ' -f 1 ) =~ $asdcplib_version_tarball_md5 ]]
then
echo "asdcplib: $asdcplib_version_tarball_md5: MD5 OK"
else
errors+=("asdcplib: Failed to verify tarball: $asdcplib_dir/$asdcplib_tarball") && echo_last errors[@]
fi
else
if ! ping -c 1 $cinecert
then
errors+=("asdcplib: $cinecert seems to be down") && echo_last errors[@]
fi
errors+=("asdcplib: Failed to download tarball. Try again later") && echo_last errors[@]
fi
fi
if tar xzf $asdcplib_tarball
then
cd $asdcplib_build_dir
case $os_dist in
ubuntu)
export LDFLAGS="-L/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)" ;;
redhat)
export LDFLAGS='' ;;
esac
# See gcc.gnu.org/gcc-4.7/changes.html (Section C++ bullet "G++ now correctly implements the two-phase lookup rules ...")
# The suggested workaround is using the -fpermissive compiler flag which will allow the code to compile with a warning.
if ./configure --with-expat=yes LIBS="-lexpat" --prefix=$asdcplib_install_dir CXXFLAGS="-fpermissive" && make -j3 && make install
then
asdcplib_build=ok
echo 'asdcplib: Build OK'
else
asdcplib_build=fail
errors+=("asdcplib: Failed to configure, build and install") && echo_last errors[@]
fi
else
asdcplib_build=fail
errors+=("asdcplib: Failed to extract tarball at $asdcplib_dir") && echo_last errors[@]
fi
fi
if [ "$asdcplib_build" = 'ok' ]
then
cd $bindir
for tool in $asdcplib_install_dir/bin/*
do
if [ -e $bindir/$(basename ${tool}) ]
then
rm $bindir/$(basename ${tool})
echo "asdcplib: Updating $(basename ${tool})"
ln -s $tool .
else
echo "asdcplib: Add to $bindir: $(basename ${tool})"
ln -s $tool .
fi
done # asdcplib
fi
# Digital Cinema Tools distribution
cd $libdir
if location_is_git_repo $dist_dir
then
cd $dist_dir
echo "Digital cinema tools distribution: Pulling updates ..."
if ! git pull
then
errors+=("Digital cinema tools distribution: Failed to pull updates. Try again later") && echo_last errors[@]
fi
else
remove_if_exists $dist_dir
if ! git clone $dist_url
then
errors+=("Digital cinema tools distribution: Failed to clone repository. Try again later") && echo_last errors[@]
else
echo 'Digital cinema tools distribution: Repository OK'
fi
fi
# Update $bindir entries for distribution
if location_exists $dist_dir
then
cd $dist_dir
tools=( $( cat toollist ) )
cd $bindir
for tool in ${tools[@]}
do
if [ -e $bindir/$tool ] && command_exists $tool
then
# Special case: setup might be hanging around here from a previous run:
# When distribution setup would have failed and the downloaded setup been moved to $bindir.
# Replace with repo version
if [[ $tool =~ $setup_basename ]] && [ ! -L $setup_fullpath ]
then
echo "Digital cinema tools distribution: Replacing setup with repo version"
rm $bindir/$tool
ln -s $dist_dir/$tool .
else
echo "Digital cinema tools distribution: $tool OK"
fi
else
echo "Digital cinema tools distribution: Add to $bindir: $tool"
ln -s $dist_dir/$tool .
fi
done
else
errors+=("Digital cinema tools distribution: Failed to update $bindir. Repository missing") && echo_last errors[@]
fi
# dcp_inspect: gem ttfunk nice-to-have
if command_exists gem
then
if gem list -i ttfunk &> /dev/null
then
echo 'dcp_inspect: Nice-to-have gem ttfunk OK'
else
if ! gem install ttfunk && rbenv rehash
then
echo 'dcp_inspect: Failed to install nice-to-have gem ttfunk. This is not a critical error'
else
echo 'dcp_inspect: Nice-to-have gem ttfunk OK'
fi
fi
fi
# cinemaslides: gem highline required
if command_exists gem
then
if gem list -i highline &> /dev/null
then
echo 'cinemaslides: Required gem highline OK'
else
if ! gem install highline && rbenv rehash
then
errors+=("cinemaslides: Failed to install required gem highline. Try again later") && echo_last errors[@]
else
echo 'cinemaslides: Required gem highline OK'
fi
fi
else
errors+=("cinemaslides: Failed to install required gem highline (Required command gem not found)") && echo_last errors[@]
fi
# cinemaslides: Set env CINEMASLIDESDIR (will be created on-demand by cinemaslides)
if [ -z "$CINEMASLIDESDIR" ]
then
cinemaslidesdir=$basedir/CINEMASLIDESDIR
else
cinemaslidesdir="$CINEMASLIDESDIR"
fi
# There might be another path exported for CINEMASLIDESDIR (user mod)
if grep -P "export CINEMASLIDESDIR=" $bashrc $bash_profile &> /dev/null
then
echo 'cinemaslides: CINEMASLIDESDIR is set. OK'
else
echo 'cinemaslides: Setting CINEMASLIDESDIR'
echo '' >> $bashrc
echo "# $setup_basename: Location of cinemaslides' working directory" >> $bashrc
echo "export CINEMASLIDESDIR=$cinemaslidesdir" >> $bashrc
exec_shell_required=true
fi
# Local certificate store and example certificates
certstore=$basedir/CERTSTORE
if grep -P "export CINEMACERTSTORE=" $bashrc $bash_profile &> /dev/null
then
echo 'cinemaslides: CINEMACERTSTORE is set. OK'
else
echo '' >> $bashrc
echo "# $setup_basename: Location of local example cinema certificates" >> $bashrc
echo "export CINEMACERTSTORE=$certstore" >> $bashrc
exec_shell_required=true
fi
if location_exists $certstore
then
cd $certstore
if [ -f leaf.key -a -f leaf.signed.pem -a -f intermediate.key -a -f intermediate.signed.pem -a -f ca.key -a -f ca.self-signed.pem -a -f dc-certificate-chain ]
then
echo 'Local certificate store: Required certificates found'
else
echo 'Local certificate store: Generating example certificates ...'
$bindir/make-dc-certificate-chain.rb
fi
else
mkdir $certstore && cd $certstore
$bindir/make-dc-certificate-chain.rb
fi
if $bindir/dc_crypto_context.rb --quiet $certstore
then
echo 'Local certificate store: OK'
else
echo "Local certificate store: Failed to find valid certificate chain in $certstore"
fi
# Done: Digital Cinemas Tools Distribution
# Fastpath for tab-completion
if [ -e $inputrc ]
then
# Leave any existing setting untouched
if grep -P "^set show-all-if-ambiguous on$" $inputrc
then
echo 'Tab completion: Fastpath set to on. Leaving untouched. OK'
elif grep -P "^set show-all-if-ambiguous off$" $inputrc
then
echo 'Tab completion: Fastpath set to off. Leaving untouched. OK'
fi
else
touch $inputrc
echo 'Tab completion: Setting fastpath to on'
echo "# $setup_basename: This will make completions show up after 1 TAB hit" >> $inputrc
echo 'set show-all-if-ambiguous on' >> $inputrc
exec_shell_required=true
fi
# Keep downloaded setup script around if distribution setup failed (which would have it included)
if [ -x "$bindir/$setup_basename" -a -L "$bindir/$setup_basename" ] && [[ $( readlink -f "$bindir/$setup_basename" ) = "$dist_dir/$setup_basename" ]]
then
# I am installation
echo "$setup_basename: OK"
if [[ $setup_dirname != $bindir ]]
then
echo "$setup_basename: Removing ad-hoc self"
rm $setup_fullpath
fi
elif [ -x $bindir/$setup_basename ]
then
# I am ad-hoc
echo "$setup_basename: Keep downloaded setup"
rm $bindir/$setup_basename
chmod u+x $setup_fullpath && mv $setup_fullpath $bindir/$setup_basename
if command_exists $setup_basename
then
echo "$setup_basename: Keeper OK"
else
echo "$setup_basename: Keeper failed"
fi
else
errors+=("$setup_basename: Keeper still borked") && echo_last errors[@]
fi
# Setup done
echo
if [ ${#errors[@]} -gt 0 ]
then
echo 'There were errors:'
for e in "${errors[@]}"
do
echo "Error: $e"
done
echo
fi
# FIXME On re-runs in already working environments this is mis-leading
if $exec_shell_required
then
echo ' ---------------------------------------------------'
echo ' | |'
echo ' | To finish the installation run |'
echo ' | |'
echo ' | exec $SHELL |'
echo ' | |'
echo ' | in this terminal now (mind the "$" in "$SHELL") |'
echo ' | |'
echo ' ---------------------------------------------------'
echo
fi
echo "$setup_basename: Done"
echo
exit 0