Skip to content

Commit

Permalink
Install overhaul
Browse files Browse the repository at this point in the history
* Address current build issues via patches

* Advise on memory limit on RPi3

* Move all RPi helpers into their own file

* Dependency folder cleanup, formatting and labels

* Provide uninstall.sh to remove linked dependencies

* Line up Github Actions/Ubuntu 22.04
  • Loading branch information
breakingspell committed Jun 8, 2024
1 parent fae99ae commit 8a37462
Show file tree
Hide file tree
Showing 9 changed files with 377 additions and 172 deletions.
17 changes: 5 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
matrix:
config:
- {
name: "Ubuntu Latest GCC (Release)",
name: "Build Dash and dependencies",
os: ubuntu-latest,
build_type: "Release",
cc: "gcc",
Expand All @@ -31,26 +31,19 @@ jobs:

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Print env
run: |
echo github.event.action: ${{ github.event.action }}
echo github.event_name: ${{ github.event_name }}
- name: Install dependencies on ubuntu
if: startsWith(matrix.config.name, 'Ubuntu Latest GCC')
run: |
sudo apt-get update
sudo apt update && sudo apt upgrade -y
# sudo apt-get install --no-install-recommends libxkbcommon-x11-0 libgl1-mesa-dev xserver-xorg-video-all xserver-xorg-input-all xserver-xorg-core xinit x11-xserver-utils
cmake --version
gcc --version
- name: Patch install.sh
shell: bash
run: |
sed -i 's/libusb-1.0.0-dev/libusb-1.0-0-dev/g' install.sh
sed -i 's/^\s*\.\/dash/\# \.\/dash/g' install.sh
# cmake --version
# gcc --version
- name: Build
shell: bash
Expand Down
135 changes: 89 additions & 46 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,48 @@ display_help() {
echo
}

#determine if script is being run on bullseye or above
BULLSEYE=false
read -d . DEBIAN_VERSION < /etc/debian_version
if (( $DEBIAN_VERSION > 10 )); then
echo Detected Debian version of Bullseye or above
BULLSEYE=true
# 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
BULLSEYE=false
read -d . DEBIAN_VERSION < /etc/debian_version
if (( $DEBIAN_VERSION > 10 )); then
echo Detected Debian version of Bullseye or above
BULLSEYE=true
fi
elif [ $OS_DISTRO = "Ubuntu" ]; then
isUbuntu=true
echo Detected Ubuntu
else
echo Unsupported OS detected. Halting.
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=$(cat /sys/firmware/devicetree/base/model | awk '{print $3}')
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 [[ $rpiModel -lt 4 && $totalMem -lt 1900 ]]; then
echo "Raspberry Pi Model $rpiModel with "$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
Expand Down Expand Up @@ -113,7 +137,7 @@ dependencies=(
"alsa-utils"
"cmake"
"libboost-all-dev"
"libusb-1.0.0-dev"
"libusb-1.0-0-dev"
"libssl-dev"
"libprotobuf-dev"
"protobuf-c-compiler"
Expand Down Expand Up @@ -160,10 +184,11 @@ if [ $deps = false ]
then
echo -e skipping dependencies '\n'
else
if [ $BULLSEYE = false ]; then
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 update
Expand Down Expand Up @@ -191,6 +216,9 @@ 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
Expand Down Expand Up @@ -242,6 +270,9 @@ 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
Expand All @@ -258,8 +289,8 @@ fi
if [ $aasdk = false ]; then
echo -e Skipping aasdk '\n'
else
#change to parent directory
cd ..
#change to project root
cd $script_path

#clone aasdk
git clone $aasdkRepo
Expand All @@ -281,6 +312,10 @@ else
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
Expand All @@ -303,7 +338,7 @@ else
fi

#beginning make
make -j2
make -j4

if [[ $? -eq 0 ]]; then
echo -e Aasdk Make completed successfully '\n'
Expand All @@ -330,10 +365,10 @@ fi
if [ $h264bitstream = false ]; then
echo -e Skipping h264bitstream '\n'
else
#change to parent directory
cd ..
#change to project root
cd $script_path

#clone aasdk
#clone h264bitstream
git clone $h264bitstreamRepo
if [[ $? -eq 0 ]]; then
echo -e h264bitstream Cloned ok '\n'
Expand Down Expand Up @@ -374,7 +409,7 @@ else
fi

#beginning make
make
make -j4

if [[ $? -eq 0 ]]; then
echo -e h264bitstream Make completed successfully '\n'
Expand Down Expand Up @@ -402,8 +437,8 @@ fi
if [ $gstreamer = true ]; then
echo installing gstreamer

#change to parent directory
cd ..
#change to project root
cd $script_path

#clone gstreamer
echo Cloning Gstreamer
Expand All @@ -425,7 +460,7 @@ if [ $gstreamer = true ]; then
#change into newly cloned directory
cd qt-gstreamer

if [ $BULLSEYE = true ]; then
if [ $BULLSEYE = true ] || [ $isUbuntu = true ]; then
#apply 1.18 patch
echo Applying qt-gstreamer 1.18 patch
git apply $script_path/patches/qt-gstreamer-1.18.patch
Expand All @@ -435,6 +470,10 @@ if [ $gstreamer = true ]; then
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
Expand Down Expand Up @@ -493,8 +532,11 @@ if [ $openauto = false ]; then
echo -e skipping openauto'\n'
else
echo Installing openauto
cd ..

#change to project root
cd $script_path

#clone openauto
echo -e cloning openauto'\n'
git clone $openautoRepo
if [[ $? -eq 0 ]]; then
Expand Down Expand Up @@ -535,7 +577,8 @@ else
fi

echo Beginning openauto make
make
make -j4

if [[ $? -eq 0 ]]; then
echo -e Openauto make OK'\n'
else
Expand All @@ -561,6 +604,9 @@ 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
Expand All @@ -584,7 +630,8 @@ else
fi

echo Running Dash make
make
make -j4

if [[ $? -eq 0 ]]; then
echo -e Dash make ok, executable can be found ../bin/dash
echo
Expand All @@ -608,34 +655,30 @@ else
echo Dash make failed with error code $?
exit 1
fi
cd ../

#Setting openGL driver and GPU memory to 128mb
#Raspberry Pi addons
if $isRpi; then
sudo raspi-config nonint do_memory_split 128
if [[ $? -eq 0 ]]; then
echo -e Memory set to 128mb'\n'
else
echo Setting memory failed with error code $? please set manually
exit 1
fi

sudo raspi-config nonint do_gldriver G2
if [[ $? -eq 0 ]]; then
echo -e OpenGL set ok'\n'
read -p "Configure select Raspberry Pi enhancements? (y/N) " choice
if [[ $choice == "y" || $choice == "Y" ]]; then
./rpi.sh
exit 0
else
echo Setting openGL failed with error code $? please set manually
exit 1
echo "Continuing"
fi

echo enabling krnbt to speed up boot and improve stability
cat <<EOT >> /boot/config.txt
dtparam=krnbt
EOT
fi


#Start app
echo Starting app
cd ../bin
./dash
fi
read -p "Build complete! Start 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"
exit 0
fi
fi
42 changes: 42 additions & 0 deletions patches/aasdk_openssl-fips-fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
From 885a8c83ef4f813205fa21cd9e96228db94bcdd2 Mon Sep 17 00:00:00 2001
From: "John EVANS (eva0034)" <evansjohn@evansautoelectrics.com.au>
Date: Sat, 6 Jan 2024 16:58:01 +1100
Subject: [PATCH] Update SSLWrapper.cpp:

fix sslwrapper.cpp for newer openssl compilation.
---
src/Transport/SSLWrapper.cpp | 14 ++++++++++++++
1 file changed, 14 insertions(+)

diff --git a/src/Transport/SSLWrapper.cpp b/src/Transport/SSLWrapper.cpp
index 6aca9b44..1c770bf8 100644
--- a/src/Transport/SSLWrapper.cpp
+++ b/src/Transport/SSLWrapper.cpp
@@ -33,13 +33,27 @@ SSLWrapper::SSLWrapper()
{
SSL_library_init();
SSL_load_error_strings();
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L && !defined(LIBRESSL_VERSION_NUMBER)
+ /*
+ * ERR_load_*(), ERR_func_error_string(), ERR_get_error_line(), ERR_get_error_line_data(), ERR_get_state()
+ * OpenSSL now loads error strings automatically so these functions are not needed.
+ * SEE FOR MORE:
+ * https://www.openssl.org/docs/manmaster/man7/migration_guide.html
+ *
+ */
+#else
ERR_load_BIO_strings();
+#endif
OpenSSL_add_all_algorithms();
}

SSLWrapper::~SSLWrapper()
{
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+ EVP_default_properties_enable_fips(nullptr, 0);
+#else
FIPS_mode_set(0);
+#endif
ENGINE_cleanup();
CONF_modules_unload(1);
EVP_cleanup();
13 changes: 13 additions & 0 deletions patches/qt-gstreamer_atomic-load.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/elements/gstqtvideosink/gstqtvideosinkplugin.h b/elements/gstqtvideosink/gstqtvideosinkplugin.h
index dc04671..a72c572 100644
--- a/elements/gstqtvideosink/gstqtvideosinkplugin.h
+++ b/elements/gstqtvideosink/gstqtvideosinkplugin.h
@@ -27,7 +27,7 @@ GST_DEBUG_CATEGORY_EXTERN(gst_qt_video_sink_debug);
#define DEFINE_TYPE_FULL(cpp_type, type_name, parent_type, additional_initializations) \
GType cpp_type::get_type() \
{ \
- static volatile gsize gonce_data = 0; \
+ static gsize gonce_data = 0; \
if (g_once_init_enter(&gonce_data)) { \
GType type = 0; \
GTypeInfo info; \
Loading

0 comments on commit 8a37462

Please sign in to comment.