From e247478e879b3fb9668a41a5410d39afd9e125e1 Mon Sep 17 00:00:00 2001 From: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com> Date: Tue, 7 Nov 2023 14:22:28 +0100 Subject: [PATCH] chore: wip --- custompios/crowsnest/start_chroot_script | 4 ++-- tools/install.sh | 17 ++++++++--------- tools/libs/core.sh | 21 +++++++++++++++++++++ 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/custompios/crowsnest/start_chroot_script b/custompios/crowsnest/start_chroot_script index 7da29599..e4cec953 100644 --- a/custompios/crowsnest/start_chroot_script +++ b/custompios/crowsnest/start_chroot_script @@ -33,8 +33,8 @@ is_raspbian() { get_pkglist() { if [[ "$(is_raspbian)" = "1" ]]; then CN_BUILD_INSTALL_SH="/home/${BASE_USER}/crowsnest/tools/libs/pkglist-rpi.sh" - fi - if [[ "$(is_raspbian)" = "0" ]]; then + INSTALL_CS="1" + else CN_BUILD_INSTALL_SH="/home/${BASE_USER}/crowsnest/tools/libs/pkglist-generic.sh" fi } diff --git a/tools/install.sh b/tools/install.sh index 49e76514..2b7a4776 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -49,20 +49,13 @@ main() { [[ -n "${BASE_USER}" ]] || BASE_USER="${SUDO_USER}" + [[ -n "${INSTALL_CS}" ]] || INSTALL_CS="$(shallow_cs_dependencies_check)" - if [[ "$(is_buster)" = "1" ]]; then + if [[ "$(is_buster)" = "1" && "${INSTALL_CS}" == "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 +65,12 @@ main() { status_msg "Running apt-get update first ..." "1" fi + if [[ "$(is_raspberry_pi)" = "1" && "${INSTALL_CS}" = "1" ]]; then + link_pkglist_rpi + else + link_pkglist_generic + fi + source_pkglist_file msg "Installing dependencies ...\n" if install_dependencies ;then diff --git a/tools/libs/core.sh b/tools/libs/core.sh index 796ea1e9..fc1104fe 100755 --- a/tools/libs/core.sh +++ b/tools/libs/core.sh @@ -48,6 +48,27 @@ is_raspbian() { fi } +test_load_module() { + if modprobe -n "${1}" &> /dev/null; then + echo 1 + else + echo 0 + fi +} + +shallow_cs_dependencies_check() { + # Update the number below if you update SHALLOW_CHECK_PKGLIST + SHALLOW_CHECK_PKGLIST="^(libavformat-dev|libavutil-dev|libavcodec-dev|libcamera-dev|libcamera-apps-lite)$" + SHALLOW_CHECK_MODULESLIST="bcm2835_codec" + + if [[ $(apt-cache search --names-only "${SHALLOW_CHECK_PKGLIST}") -eq 5 + && $(test_load_module ${SHALLOW_CHECK_MODULESLIST}) ]]; then + echo 1 + else + echo 0 + fi +} + link_pkglist_rpi() { sudo -u "${BASE_USER}" ln -sf "${SRC_DIR}/libs/pkglist-rpi.sh" "${SRC_DIR}/pkglist.sh" &> /dev/null || return 1 }