-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathinstall.sh
executable file
·703 lines (613 loc) · 17.1 KB
/
install.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
#!/bin/bash
#repo addresses
aasdkRepo="https://github.com/OpenDsh/aasdk"
gstreamerRepo="https://github.com/GStreamer/qt-gstreamer"
openautoRepo="https://github.com/openDsh/openauto"
h264bitstreamRepo="https://github.com/aizvorski/h264bitstream"
pulseaudioRepo="https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git"
#Help text
display_help() {
echo
echo " --deps install all dependencies"
echo " --aasdk install and build aasdk"
echo " --openauto install and build openauto "
echo " --gstreamer install and build gstreamer "
echo " --dash install and build dash "
echo " --h264bitstream install and build h264bitstream"
echo " --pulseaudio install and build pulseaudio to fix raspberry pi bluetooth HFP"
echo " --bluez install and build bluez to fix raspberry pi bluetooth outbound connection"
echo " --ofono install and configure ofono to allow bluetooth HFP"
echo " --debug create a debug build "
echo
}
# Check Distro version
if [ -f /etc/os-release ]; then
OS_DISTRO=$(source /etc/os-release; echo ${PRETTY_NAME%% *})
if [ $OS_DISTRO = "Debian" ]; then
isDebian=true
#determine if script is being run on bullseye or above
read -d . DEBIAN_VERSION < /etc/debian_version
if (( $DEBIAN_VERSION > 10 )); then
echo Detected Debian version of Bullseye or above
BULLSEYE=true
else
echo Older version of Debian detected
BULLSEYE=false
fi
elif [ $OS_DISTRO = "Ubuntu" ]; then
isUbuntu=true
UBUNTU_VERSION=$(source /etc/os-release; echo ${VERSION_ID%% *} | cut -c1-2)
if (( $UBUNTU_VERSION >= 22 )); then
echo Detcted Ubuntu version of Jammy or above
JAMMY=true
else
echo Older version of Ubuntu detected.
JAMMY=false
fi
else
echo "Unsupported OS detected. Recommended Debian 12 or Ubuntu 22.04"
exit 1
fi
fi
#check if /etc/rpi-issue exists, if not set the install Args to be false
if [ -f /etc/rpi-issue ]
then
rpiModel=$(awk '{print $3}' < /sys/firmware/devicetree/base/model)
echo "Detected Raspberry Pi Model $rpiModel"
installArgs="-DRPI_BUILD=true"
isRpi=true
else
installArgs=""
isRpi=false
fi
#check for potential resource limit
totalMem=$(free -tm | awk '/Total/ {print $2}')
if [[ $totalMem -lt 1900 ]]; then
echo "$totalMem MB RAM detected"
echo "You may run out of memory while compiling with less than 2GB"
echo "Consider raising swap space or compiling on another machine"
sleep 5;
fi
BUILD_TYPE="Release"
#check to see if there are any arguments supplied, if none are supplied run full install
if [ $# -gt 0 ]; then
#initialize all arguments to false before looping to find which are available
deps=false
aasdk=false
gstreamer=false
openauto=false
dash=false
h264bitstream=false
pulseaudio=false
bluez=false
ofono=false
while [ "$1" != "" ]; do
case $1 in
--deps ) shift
deps=true
;;
--aasdk ) aasdk=true
;;
--gstreamer ) gstreamer=true
;;
--openauto ) openauto=true
;;
--dash ) dash=true
;;
--h264bitstream ) h264bitstream=true
;;
--pulseaudio ) pulseaudio=true
;;
--bluez ) bluez=true
;;
--ofono ) ofono=true
;;
--debug ) BUILD_TYPE="Debug"
;;
-h | --help ) display_help
exit
;;
* ) display_help
exit 1
esac
shift
done
else
echo -e Full install running'\n'
deps=true
aasdk=true
gstreamer=true
openauto=true
dash=true
h264bitstream=true
pulseaudio=false
bluez=false
ofono=false
if [ $isRpi = true ]; then
pulseaudio=true
bluez=true
ofono=false # Skip Ofono due to issue with Bluetooth HSP
fi
fi
script_path=$(dirname "$(realpath -s "$0")")
echo "Script directory is $script_path"
installArgs="-DCMAKE_BUILD_TYPE=${BUILD_TYPE} $installArgs"
#Array of dependencies any new dependencies can be added here
dependencies=(
"alsa-utils"
"cmake"
"libboost-all-dev"
"libusb-1.0-0-dev"
"libssl-dev"
"libprotobuf-dev"
"protobuf-c-compiler"
"protobuf-compiler"
"libqt5multimedia5"
"libqt5multimedia5-plugins"
"libqt5multimediawidgets5"
"qtmultimedia5-dev"
"libqt5bluetooth5"
"libqt5bluetooth5-bin"
"qtconnectivity5-dev"
"pulseaudio"
"pulseaudio-module-bluetooth"
"librtaudio-dev"
"librtaudio6"
"libkf5bluezqt-dev"
"libtag1-dev"
"qml-module-qtquick2"
"libglib2.0-dev"
"libgstreamer1.0-dev"
"gstreamer1.0-plugins-base-apps"
"gstreamer1.0-plugins-bad"
"gstreamer1.0-libav"
"gstreamer1.0-alsa"
"libgstreamer-plugins-base1.0-dev"
"qtdeclarative5-dev"
"libgstreamer-plugins-bad1.0-dev"
"libunwind-dev"
"qml-module-qtmultimedia"
"libqt5serialbus5-dev"
"libqt5serialbus5-plugins"
"libqt5serialport5-dev"
"libqt5websockets5-dev"
"libqt5svg5-dev"
"build-essential"
"libtool"
"autoconf"
"ffmpeg"
)
############################### dependencies #########################
if [ $deps = false ]
then
echo -e skipping dependencies '\n'
else
if [ $isDebian ] && [ $BULLSEYE = false ]; then
echo Adding qt5-default to dependencies
dependencies[${#dependencies[@]}]="qt5-default"
fi
echo installing dependencies
#loop through dependencies and install
echo Running apt-get update
sudo apt-get update
installString="sudo apt-get install -y "
#create apt-get install string
for i in ${dependencies[@]}; do
installString+=" $i"
done
#run install
${installString}
if [[ $? -eq 0 ]]; then
echo -e All dependencies Installed ok '\n'
else
echo Package failed to install with error code $?, quitting check logs above
exit 1
fi
fi
############################### pulseaudio #########################
if [ $pulseaudio = false ]
then
echo -e skipping pulseaudio '\n'
else
#change to project root
cd $script_path
echo Preparing to compile and install pulseaudio
echo Grabbing pulseaudio deps
sudo sed -i 's/#deb-src/deb-src/g' /etc/apt/sources.list
sudo apt-get update -y
git clone $pulseaudioRepo
sudo apt-get install -y autopoint
cd pulseaudio
git checkout tags/v12.99.3
echo Applying imtu patch
sed -i 's/*imtu = 48;/*imtu = 60;/g' src/modules/bluetooth/backend-native.c
sed -i 's/*imtu = 48;/*imtu = 60;/g' src/modules/bluetooth/backend-ofono.c
sudo apt-get build-dep -y pulseaudio
./bootstrap.sh
make -j4
sudo make install
sudo ldconfig
# copy configs and force an exit 0 just in case files are identical (we don't care but it will make pimod exit)
sudo cp /usr/share/pulseaudio/alsa-mixer/profile-sets/* /usr/local/share/pulseaudio/alsa-mixer/profile-sets/
cd ..
fi
############################### ofono #########################
if [ $ofono = false ]
then
echo -e skipping ofono '\n'
else
echo Installing ofono
sudo apt-get install -y ofono
if [[ $? -eq 0 ]]; then
echo -e ofono Installed ok '\n'
else
echo Package failed to install with error code $?, quitting check logs above
exit 1
fi
echo "Enabling Ofono in Pulse config"
sudo sed -i 's/load-module module-bluetooth-discover/load-module module-bluetooth-discover headset=ofono/g' /etc/pulse/default.pa
sudo tee -a /etc/pulse/default.pa <<'EOT'
### Echo cancel and noise reduction
.ifexists module-echo-cancel.so
load-module module-echo-cancel aec_method=webrtc source_name=ec_out sink_name=ec_ref
set-default-source ec_out
set-default-sink ec_ref
.endif
EOT
fi
############################### bluez #########################
if [ $bluez = false ]
then
echo -e skipping bluez '\n'
else
#change to project root
cd $script_path
echo Installing bluez
sudo apt-get install -y libdbus-1-dev libudev-dev libical-dev libreadline-dev libjson-c-dev
wget www.kernel.org/pub/linux/bluetooth/bluez-5.63.tar.xz
tar -xvf bluez-5.63.tar.xz bluez-5.63/
rm bluez-5.63.tar.xz
cd bluez-5.63
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-library --disable-manpages --enable-deprecated
make
sudo make install
cd ..
fi
############################### AASDK #########################
if [ $aasdk = false ]; then
echo -e Skipping aasdk '\n'
else
#change to project root
cd $script_path
#clone aasdk
git clone $aasdkRepo
if [[ $? -eq 0 ]]; then
echo -e Aasdk Cloned ok '\n'
else
cd aasdk
if [[ $? -eq 0 ]]; then
git pull $aasdkRepo
echo -e Aasdk Cloned OK '\n'
cd ..
else
echo Aasdk clone/pull error
exit 1
fi
fi
#change into aasdk folder
echo -e moving to aasdk '\n'
cd aasdk
#apply set_FIPS_mode patch
echo Apply set_FIPS_mode patch
git apply $script_path/patches/aasdk_openssl-fips-fix.patch
#create build directory
echo Creating aasdk build directory
mkdir build
if [[ $? -eq 0 ]]; then
echo -e aasdk build directory made
else
echo Unable to create aasdk build directory assuming it exists...
fi
cd build
#beginning cmake
cmake -DCMAKE_BUILD_TYPE=Release ../
if [[ $? -eq 0 ]]; then
echo -e Aasdk CMake completed successfully'\n'
else
echo Aasdk CMake failed with code $?
exit 1
fi
#beginning make
make -j2
if [[ $? -eq 0 ]]; then
echo -e Aasdk Make completed successfully '\n'
else
echo Aasdk Make failed with code $?
exit 1
fi
#begin make install
sudo make install
if [[ $? -eq 0 ]]
then
echo -e Aasdk installed ok'\n'
echo
else
echo Aasdk install failed with code $?
exit 1
fi
cd $script_path
fi
############################### h264bitstream #########################
if [ $h264bitstream = false ]; then
echo -e Skipping h264bitstream '\n'
else
#change to project root
cd $script_path
#clone h264bitstream
git clone $h264bitstreamRepo
if [[ $? -eq 0 ]]; then
echo -e h264bitstream Cloned ok '\n'
else
cd h264bitstream
if [[ $? -eq 0 ]]; then
git pull $h264bitstreamRepo
echo -e h264bitstream Cloned OK '\n'
cd ..
else
echo h264bitstream clone/pull error
exit 1
fi
fi
#change into folder
echo -e moving to h264bitstream '\n'
cd h264bitstream
echo Auto-reconfigure project
autoreconf -i
if [[ $? -eq 0 ]]; then
echo -e autoreconfed h264bitstream
else
echo Unable to autoreconf h264bitstream
exit 1
fi
echo Configuring h264bitstream
./configure --prefix=/usr/local
if [[ $? -eq 0 ]]; then
echo -e h264bitstream configured successfully'\n'
else
echo h264bitstream configure failed with code $?
exit 1
fi
#beginning make
make
if [[ $? -eq 0 ]]; then
echo -e h264bitstream Make completed successfully '\n'
else
echo h264bitstream Make failed with code $?
exit 1
fi
#begin make install
sudo make install
if [[ $? -eq 0 ]]
then
echo -e h264bitstream installed ok'\n'
echo
else
echo h264bitstream install failed with code $?
exit 1
fi
cd $script_path
fi
############################### gstreamer #########################
#check if gstreamer install is requested
if [ $gstreamer = true ]; then
echo installing gstreamer
#change to project root
cd $script_path
#clone gstreamer
echo Cloning Gstreamer
git clone $gstreamerRepo
if [[ $? -eq 0 ]]; then
echo -e Gstreamer cloned OK
else
cd qt-gstreamer
if [[ $? -eq 0 ]]; then
git pull $gstreamerRepo
echo -e cloned OK '\n'
cd ..
else
echo Gstreamer clone/pull error
exit 1
fi
fi
#change into newly cloned directory
cd qt-gstreamer
if [ $BULLSEYE = true ] || [ $JAMMY = true ]; then
#apply 1.18 patch
echo Applying qt-gstreamer 1.18 patch
git apply $script_path/patches/qt-gstreamer-1.18.patch
fi
#apply greenline patch
echo Apply greenline patch
git apply $script_path/patches/greenline_fix.patch
#apply atomic patch
echo Apply atomic patch
git apply $script_path/patches/qt-gstreamer_atomic-load.patch
#create build directory
echo Creating Gstreamer build directory
mkdir build
if [[ $? -eq 0 ]]; then
echo -e Gstreamer build directory made
else
echo Unable to create Gstreamer build directory assuming it exists...
fi
cd build
#run cmake
echo Beginning cmake
cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH) -DCMAKE_INSTALL_INCLUDEDIR=include -DQT_VERSION=5 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=-std=c++11
if [[ $? -eq 0 ]]; then
echo -e Make ok'\n'
else
echo Gstreamer CMake failed
exit 1
fi
echo Making Gstreamer
make
if [[ $? -eq 0 ]]; then
echo -e Gstreamer make ok'\n'
else
echo Make failed with error code $?
exit 1
fi
#run make install
echo Beginning make install
sudo make install
if [[ $? -eq 0 ]]; then
echo -e Gstreamer installed ok'\n'
else
echo Gstreamer make install failed with error code $?
exit 1
fi
sudo ldconfig
cd $script_path
else
echo -e Skipping Gstreamer'\n'
fi
############################### openauto #########################
if [ $openauto = false ]; then
echo -e skipping openauto'\n'
else
echo Installing openauto
#change to project root
cd $script_path
#clone openauto
echo -e cloning openauto'\n'
git clone $openautoRepo
if [[ $? -eq 0 ]]; then
echo -e cloned OK'\n'
else
cd openauto
if [[ $? -eq 0 ]]; then
git pull $openautoRepo
echo -e Openauto cloned OK'\n'
cd ..
else
echo Openauto clone/pull error
exit 1
fi
fi
cd openauto
#create build directory
echo Creating openauto build directory
mkdir build
if [[ $? -eq 0 ]]; then
echo -e openauto build directory made
else
echo Unable to create openauto build directory assuming it exists...
fi
cd build
echo Beginning openauto cmake
cmake ${installArgs} -DGST_BUILD=true ../
if [[ $? -eq 0 ]]; then
echo -e Openauto CMake OK'\n'
else
echo Openauto CMake failed with error code $?
exit 1
fi
echo Beginning openauto make
make
if [[ $? -eq 0 ]]; then
echo -e Openauto make OK'\n'
else
echo Openauto make failed with error code $?
exit 1
fi
#run make install
echo Beginning make install
sudo make install
if [[ $? -eq 0 ]]; then
echo -e Openauto installed ok'\n'
else
echo Openauto make install failed with error code $?
exit 1
fi
cd $script_path
fi
############################### dash #########################
if [ $dash = false ]; then
echo -e Skipping dash'\n'
else
#change to project root
cd $script_path
#create build directory
echo Creating dash build directory
mkdir build
if [[ $? -eq 0 ]]; then
echo -e dash build directory made
else
echo Unable to create dash build directory assuming it exists...
fi
cd build
echo -e Installing dash'\n'
echo Running CMake for dash
cmake ${installArgs} -DGST_BUILD=TRUE ../
if [[ $? -eq 0 ]]; then
echo -e Dash CMake OK'\n'
else
echo Dash CMake failed with error code $?
exit 1
fi
echo Running Dash make
make
if [[ $? -eq 0 ]]; then
echo -e Dash make ok, executable can be found ../bin/dash
echo
#check and add usb rules for openauto if they dont exist
echo Checking if permissions exist
#udev rule to be created below, change as needed
FILE=/etc/udev/rules.d/51-dashusb.rules
if [[ ! -f "$FILE" ]]; then
# OPEN USB RULE, CREATE MORE SECURE RULE IF REQUIRED
echo "SUBSYSTEM==\"usb\", ATTR{idVendor}==\"*\", ATTR{idProduct}==\"*\", MODE=\"0660\", GROUP=\"plugdev\"" | sudo tee $FILE
if [[ $? -eq 0 ]]; then
echo -e Permissions created'\n'
else
echo -e Unable to create permissions'\n'
fi
else
echo -e Rules exists'\n'
fi
else
echo Dash make failed with error code $?
exit 1
fi
cd $script_path
#Raspberry Pi addons
if $isRpi; then
read -p "View select Raspberry Pi enhancements? (y/N) " choice
if [[ $choice == "y" || $choice == "Y" ]]; then
./rpi.sh
else
echo "Continuing"
fi
fi
#Autostart options
read -p "View autostart options? (y/N) " choice
if [[ $choice == "y" || $choice == "Y" ]]; then
./autostart.sh
else
echo "Continuing"
fi
read -p "Build complete! Run application? (y/N) " choice
if [[ $choice == "y" || $choice == "Y" ]]; then
./bin/dash
if [[ $? -eq 1 ]]; then
echo "Something went wrong! You may need to set up Xorg/X11"
exit 1
else
exit 0
fi
else
echo "Exiting. Check autostart.sh and rpi.sh for more options"
exit 0
fi
fi