@@ -22,24 +22,48 @@ display_help() {
2222 echo
2323}
2424
25- # determine if script is being run on bullseye or above
26- BULLSEYE=false
27- read -d . DEBIAN_VERSION < /etc/debian_version
28- if (( $DEBIAN_VERSION > 10 )) ; then
29- echo Detected Debian version of Bullseye or above
30- BULLSEYE=true
25+ # Check Distro version
26+ if [ -f /etc/os-release ]; then
27+ OS_DISTRO=$( source /etc/os-release; echo ${PRETTY_NAME%% * } )
28+ if [ $OS_DISTRO = " Debian" ]; then
29+ isDebian=true
30+ # determine if script is being run on bullseye or above
31+ BULLSEYE=false
32+ read -d . DEBIAN_VERSION < /etc/debian_version
33+ if (( $DEBIAN_VERSION > 10 )) ; then
34+ echo Detected Debian version of Bullseye or above
35+ BULLSEYE=true
36+ fi
37+ elif [ $OS_DISTRO = " Ubuntu" ]; then
38+ isUbuntu=true
39+ echo Detected Ubuntu
40+ else
41+ echo Unsupported OS detected. Halting.
42+ exit 1
43+ fi
3144fi
3245
3346# check if /etc/rpi-issue exists, if not set the install Args to be false
3447if [ -f /etc/rpi-issue ]
3548then
49+ rpiModel=$( cat /sys/firmware/devicetree/base/model | awk ' {print $3}' )
50+ echo " Detected Raspberry Pi Model $rpiModel "
3651 installArgs=" -DRPI_BUILD=true"
3752 isRpi=true
3853else
3954 installArgs=" "
4055 isRpi=false
4156fi
4257
58+ # check for potential resource limit
59+ totalMem=$( free -tm | awk ' /Total/ {print $2}' )
60+ if [[ $rpiModel -lt 4 || $totalMem -lt 1900 ]]; then
61+ echo " Raspberry Pi Model $rpiModel with " $totalMem " MB RAM detected"
62+ echo " You may run out of memory while compiling with less than 2GB"
63+ echo " Consider raising swap space or compiling on another machine"
64+ sleep 5;
65+ fi
66+
4367BUILD_TYPE=" Release"
4468
4569# check to see if there are any arguments supplied, if none are supplied run full install
@@ -113,7 +137,7 @@ dependencies=(
113137" alsa-utils"
114138" cmake"
115139" libboost-all-dev"
116- " libusb-1.0. 0-dev"
140+ " libusb-1.0- 0-dev"
117141" libssl-dev"
118142" libprotobuf-dev"
119143" protobuf-c-compiler"
@@ -160,10 +184,11 @@ if [ $deps = false ]
160184 then
161185 echo -e skipping dependencies ' \n'
162186 else
163- if [ $BULLSEYE = false ]; then
187+ if [ $isDebian ] && [ $ BULLSEYE = false ]; then
164188 echo Adding qt5-default to dependencies
165189 dependencies[${# dependencies[@]} ]=" qt5-default"
166190 fi
191+
167192 echo installing dependencies
168193 # loop through dependencies and install
169194 echo Running apt update
@@ -191,6 +216,9 @@ if [ $pulseaudio = false ]
191216 then
192217 echo -e skipping pulseaudio ' \n'
193218 else
219+ # change to project root
220+ cd $script_path
221+
194222 echo Preparing to compile and install pulseaudio
195223 echo Grabbing pulseaudio deps
196224 sudo sed -i ' s/#deb-src/deb-src/g' /etc/apt/sources.list
@@ -242,6 +270,9 @@ if [ $bluez = false ]
242270 then
243271 echo -e skipping bluez ' \n'
244272 else
273+ # change to project root
274+ cd $script_path
275+
245276 echo Installing bluez
246277 sudo apt-get install -y libdbus-1-dev libudev-dev libical-dev libreadline-dev libjson-c-dev
247278 wget www.kernel.org/pub/linux/bluetooth/bluez-5.63.tar.xz
258289if [ $aasdk = false ]; then
259290 echo -e Skipping aasdk ' \n'
260291else
261- # change to parent directory
262- cd ..
292+ # change to project root
293+ cd $script_path
263294
264295 # clone aasdk
265296 git clone $aasdkRepo
@@ -281,6 +312,10 @@ else
281312 echo -e moving to aasdk ' \n'
282313 cd aasdk
283314
315+ # apply set_FIPS_mode patch
316+ echo Apply set_FIPS_mode patch
317+ git apply $script_path /patches/aasdk_openssl-fips-fix.patch
318+
284319 # create build directory
285320 echo Creating aasdk build directory
286321 mkdir build
330365if [ $h264bitstream = false ]; then
331366 echo -e Skipping h264bitstream ' \n'
332367else
333- # change to parent directory
334- cd ..
368+ # change to project root
369+ cd $script_path
335370
336- # clone aasdk
371+ # clone h264bitstream
337372 git clone $h264bitstreamRepo
338373 if [[ $? -eq 0 ]]; then
339374 echo -e h264bitstream Cloned ok ' \n'
402437if [ $gstreamer = true ]; then
403438 echo installing gstreamer
404439
405- # change to parent directory
406- cd ..
440+ # change to project root
441+ cd $script_path
407442
408443 # clone gstreamer
409444 echo Cloning Gstreamer
@@ -425,7 +460,7 @@ if [ $gstreamer = true ]; then
425460 # change into newly cloned directory
426461 cd qt-gstreamer
427462
428- if [ $BULLSEYE = true ]; then
463+ if [ $BULLSEYE = true ] || [ $isUbuntu = true ] ; then
429464 # apply 1.18 patch
430465 echo Applying qt-gstreamer 1.18 patch
431466 git apply $script_path /patches/qt-gstreamer-1.18.patch
@@ -435,6 +470,10 @@ if [ $gstreamer = true ]; then
435470 echo Apply greenline patch
436471 git apply $script_path /patches/greenline_fix.patch
437472
473+ # apply atomic patch
474+ echo Apply atomic patch
475+ git apply $script_path /patches/qt-gstreamer_atomic-load.patch
476+
438477 # create build directory
439478 echo Creating Gstreamer build directory
440479 mkdir build
@@ -459,7 +498,7 @@ if [ $gstreamer = true ]; then
459498 fi
460499
461500 echo Making Gstreamer
462- make -j4
501+ make
463502
464503 if [[ $? -eq 0 ]]; then
465504 echo -e Gstreamer make ok' \n'
@@ -493,8 +532,11 @@ if [ $openauto = false ]; then
493532 echo -e skipping openauto' \n'
494533else
495534 echo Installing openauto
496- cd ..
497535
536+ # change to project root
537+ cd $script_path
538+
539+ # clone openauto
498540 echo -e cloning openauto' \n'
499541 git clone $openautoRepo
500542 if [[ $? -eq 0 ]]; then
536578
537579 echo Beginning openauto make
538580 make
581+
539582 if [[ $? -eq 0 ]]; then
540583 echo -e Openauto make OK' \n'
541584 else
@@ -561,6 +604,9 @@ if [ $dash = false ]; then
561604 echo -e Skipping dash' \n'
562605else
563606
607+ # change to project root
608+ cd $script_path
609+
564610 # create build directory
565611 echo Creating dash build directory
566612 mkdir build
585631
586632 echo Running Dash make
587633 make
634+
588635 if [[ $? -eq 0 ]]; then
589636 echo -e Dash make ok, executable can be found ../bin/dash
590637 echo
@@ -608,34 +655,30 @@ else
608655 echo Dash make failed with error code $?
609656 exit 1
610657 fi
658+ cd ../
611659
612- # Setting openGL driver and GPU memory to 128mb
660+ # Raspberry Pi addons
613661 if $isRpi ; then
614- sudo raspi-config nonint do_memory_split 128
615- if [[ $? -eq 0 ]]; then
616- echo -e Memory set to 128mb' \n'
662+ read -p " Configure select Raspberry Pi enhancements? (y/N) " choice
663+ if [[ $choice == " y" || $choice == " Y" ]]; then
664+ ./rpi.sh
665+ exit 0
617666 else
618- echo Setting memory failed with error code $? please set manually
619- exit 1
667+ echo " Continuing"
620668 fi
621-
622- sudo raspi-config nonint do_gldriver G2
623- if [[ $? -eq 0 ]]; then
624- echo -e OpenGL set ok' \n'
625- else
626- echo Setting openGL failed with error code $? please set manually
627- exit 1
628- fi
629-
630- echo enabling krnbt to speed up boot and improve stability
631- cat << EOT >> /boot/config.txt
632- dtparam=krnbt
633- EOT
634669 fi
635670
636-
637- # Start app
638- echo Starting app
639- cd ../bin
640- ./dash
641- fi
671+ read -p " Build complete! Start application? (y/N) " choice
672+ if [[ $choice == " y" || $choice == " Y" ]]; then
673+ ./bin/dash
674+ if [[ $? -eq 1 ]]; then
675+ echo " Something went wrong! You may need to set up Xorg/X11"
676+ exit 1
677+ else
678+ exit 0
679+ fi
680+ else
681+ echo " Exiting"
682+ exit 0
683+ fi
684+ fi
0 commit comments