chore: refactor camera-streamer build conditions (#201)
This commit is contained in:
parent
2bdc30b54c
commit
549f7d455a
@ -49,20 +49,11 @@ main() {
|
||||
|
||||
[[ -n "${BASE_USER}" ]] || BASE_USER="${SUDO_USER}"
|
||||
|
||||
|
||||
if [[ "$(is_buster)" = "1" ]]; then
|
||||
not_supported_msg
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$(is_raspbian)" = "1" ]]; then
|
||||
link_pkglist_rpi
|
||||
fi
|
||||
|
||||
if [[ "$(is_raspbian)" = "0" ]]; then
|
||||
link_pkglist_generic
|
||||
fi
|
||||
|
||||
welcome_msg
|
||||
|
||||
msg "Running apt-get update first ...\n"
|
||||
@ -72,6 +63,30 @@ main() {
|
||||
status_msg "Running apt-get update first ..." "1"
|
||||
fi
|
||||
|
||||
if [[ "${CROWSNEST_UNATTENDED}" != "1" ]]; then
|
||||
msg "Doing some tests ...\n"
|
||||
if shallow_cs_dependencies_check; then
|
||||
CN_INSTALL_CS="1"
|
||||
else
|
||||
CN_INSTALL_CS="0"
|
||||
fi
|
||||
status_msg "Doing some tests ..." "0"
|
||||
else
|
||||
if [[ "$(is_raspbian)" = "1" ]]; then
|
||||
CN_INSTALL_CS="1"
|
||||
else
|
||||
CN_INSTALL_CS="0"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${CN_INSTALL_CS}" = "1" ]]; then
|
||||
msg "Installing with camera-streamer ...\n"
|
||||
link_pkglist_rpi
|
||||
else
|
||||
msg "Installing without camera-streamer ...\n"
|
||||
link_pkglist_generic
|
||||
fi
|
||||
|
||||
source_pkglist_file
|
||||
msg "Installing dependencies ...\n"
|
||||
if install_dependencies ;then
|
||||
@ -128,9 +143,9 @@ main() {
|
||||
|
||||
add_group_video
|
||||
|
||||
if [[ "$(is_bookworm)" = "1" ]]; then
|
||||
msg "Bookworm detected!"
|
||||
msg "Using main branch of camera-streamer for Bookworm..."
|
||||
if [[ "$(is_bookworm)" = "1" ]] && [[ "${CN_INSTALL_CS}" = "1" ]]; then
|
||||
msg "\nBookworm detected!"
|
||||
msg "Using main branch of camera-streamer for Bookworm ...\n"
|
||||
CROWSNEST_CAMERA_STREAMER_REPO_BRANCH="main"
|
||||
fi
|
||||
|
||||
|
@ -44,11 +44,10 @@ build_apps() {
|
||||
msg "Cloning ustreamer repository ..."
|
||||
clone_ustreamer
|
||||
## Detect Image build for Raspberrys
|
||||
if [[ "$(is_raspbian)" = "1" ]]; then
|
||||
if [[ "${CN_INSTALL_CS}" = "1" ]]; then
|
||||
msg "Cloning camera-streamer repository ..."
|
||||
clone_cstreamer
|
||||
fi
|
||||
if [[ "$(is_raspbian)" = "0" ]]; then
|
||||
else
|
||||
msg "Install of camera-streamer skipped, only supported on Raspberry SBC's! ... "
|
||||
fi
|
||||
sudo -u "${BASE_USER}" "${PWD}"/bin/build.sh --build
|
||||
|
@ -48,6 +48,74 @@ is_raspbian() {
|
||||
fi
|
||||
}
|
||||
|
||||
is_raspberry_pi() {
|
||||
if [[ -f /proc/device-tree/model ]] &&
|
||||
grep -q "Raspberry" /proc/device-tree/model; then
|
||||
echo "1"
|
||||
else
|
||||
echo "0"
|
||||
fi
|
||||
}
|
||||
|
||||
is_ubuntu_arm() {
|
||||
if [[ "$(is_raspberry_pi)" = "1" ]] &&
|
||||
grep -q "ubuntu" /etc/os-release; then
|
||||
echo "1"
|
||||
else
|
||||
echo "0"
|
||||
fi
|
||||
}
|
||||
|
||||
test_load_module() {
|
||||
if modprobe -n "${1}" &> /dev/null; then
|
||||
echo 1
|
||||
else
|
||||
echo 0
|
||||
fi
|
||||
}
|
||||
|
||||
shallow_cs_dependencies_check() {
|
||||
msg "Checking for camera-streamer dependencies ...\n"
|
||||
|
||||
msg "Checking if device is a Raspberry Pi ...\n"
|
||||
if [[ "$(is_raspberry_pi)" = "0" ]]; then
|
||||
status_msg "Checking if device is a Raspberry Pi ..." "3"
|
||||
msg "This device is not a Raspberry Pi therefore camera-streeamer cannot be installed ..."
|
||||
return 1
|
||||
fi
|
||||
status_msg "Checking if device is a Raspberry Pi ..." "0"
|
||||
|
||||
msg "Checking if device is not running Ubuntu ...\n"
|
||||
if [[ "$(is_ubuntu_arm)" = "1" ]]; then
|
||||
status_msg "Checking if device is not running Ubuntu ..." "3"
|
||||
msg "This device is running Ubuntu therefore camera-streeamer cannot be installed ..."
|
||||
return 1
|
||||
fi
|
||||
status_msg "Checking if device is not running Ubuntu ..." "0"
|
||||
|
||||
msg "Checking for required kernel module ...\n"
|
||||
SHALLOW_CHECK_MODULESLIST="bcm2835_codec"
|
||||
if [[ "$(test_load_module ${SHALLOW_CHECK_MODULESLIST})" = "0" ]]; then
|
||||
status_msg "Checking for required kernel module ..." "3"
|
||||
msg "Not all required kernel modules for camera-streamer can be loaded ..."
|
||||
return 1
|
||||
fi
|
||||
status_msg "Checking for required kernel module ..." "0"
|
||||
|
||||
msg "Checking for required packages ...\n"
|
||||
# Update the number below if you update SHALLOW_CHECK_PKGLIST
|
||||
SHALLOW_CHECK_PKGLIST="^(libavformat-dev|libavutil-dev|libavcodec-dev|liblivemedia-dev|libcamera-dev|libcamera-apps-lite)$"
|
||||
if [[ $(apt-cache search --names-only "${SHALLOW_CHECK_PKGLIST}" | wc -l) -lt 6 ]]; then
|
||||
status_msg "Checking for required packages ..." "3"
|
||||
msg "Not all required packages for camera-streamer can be installed ..."
|
||||
return 1
|
||||
fi
|
||||
status_msg "Checking for required packages ..." "0"
|
||||
|
||||
status_msg "Checking for camera-streamer dependencies ..." "0"
|
||||
return 0
|
||||
}
|
||||
|
||||
link_pkglist_rpi() {
|
||||
sudo -u "${BASE_USER}" ln -sf "${SRC_DIR}/libs/pkglist-rpi.sh" "${SRC_DIR}/pkglist.sh" &> /dev/null || return 1
|
||||
}
|
||||
|
@ -44,6 +44,9 @@ status_msg() {
|
||||
if [[ "${status}" == "2" ]]; then
|
||||
echo -e "${msg} [\e[33mSKIPPED\e[0m]"
|
||||
fi
|
||||
if [[ "${status}" == "3" ]]; then
|
||||
echo -e "${msg} [\e[33mFAILED\e[0m]"
|
||||
fi
|
||||
}
|
||||
|
||||
not_as_root_msg() {
|
||||
|
@ -22,5 +22,6 @@ PKGLIST="git crudini bsdutils findutils v4l-utils curl"
|
||||
### Ustreamer Dependencies
|
||||
PKGLIST="${PKGLIST} build-essential libevent-dev libjpeg-dev libbsd-dev"
|
||||
### Camera-Streamer Dependencies
|
||||
### If you change something below, also have a look at tools/libs/core.sh->shallow_cs_dependencies_check
|
||||
PKGLIST="${PKGLIST} cmake libavformat-dev libavutil-dev libavcodec-dev libcamera-dev libcamera-apps-lite"
|
||||
PKGLIST="${PKGLIST} liblivemedia-dev pkg-config xxd build-essential cmake libssl-dev"
|
||||
|
Loading…
x
Reference in New Issue
Block a user