From 818f7176227d65e8aa489d8befc11d5b896e4159 Mon Sep 17 00:00:00 2001 From: Federico Di Pierro Date: Thu, 13 Oct 2022 08:45:22 +0200 Subject: [PATCH] chore(scripts,cmake): dialog is an optional dep, do not list it among deps. Cleaned up unused vars in postinst scripts. Finally, only show dialog window in interactive shells. Signed-off-by: Federico Di Pierro --- cmake/modules/CPackConfig.cmake | 4 +- docker/tester/Dockerfile | 2 +- scripts/debian/postinst.in | 69 +++++++++++++++++---------------- scripts/rpm/postinstall.in | 55 +++++++++++++------------- 4 files changed, 67 insertions(+), 63 deletions(-) diff --git a/cmake/modules/CPackConfig.cmake b/cmake/modules/CPackConfig.cmake index b9991761..794274cd 100644 --- a/cmake/modules/CPackConfig.cmake +++ b/cmake/modules/CPackConfig.cmake @@ -51,7 +51,7 @@ if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64") set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "arm64") endif() set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://www.falco.org") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "dkms (>= 2.1.0.0), dialog") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "dkms (>= 2.1.0.0)") set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_BINARY_DIR}/scripts/debian/postinst;${CMAKE_BINARY_DIR}/scripts/debian/prerm;${CMAKE_BINARY_DIR}/scripts/debian/postrm;${PROJECT_SOURCE_DIR}/cmake/cpack/debian/conffiles" ) @@ -59,7 +59,7 @@ set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA set(CPACK_RPM_PACKAGE_LICENSE "Apache v2.0") set(CPACK_RPM_PACKAGE_ARCHITECTURE, "amd64") set(CPACK_RPM_PACKAGE_URL "https://www.falco.org") -set(CPACK_RPM_PACKAGE_REQUIRES "dkms, kernel-devel, systemd, dialog") +set(CPACK_RPM_PACKAGE_REQUIRES "dkms, kernel-devel, systemd") set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_BINARY_DIR}/scripts/rpm/postinstall") set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_BINARY_DIR}/scripts/rpm/preuninstall") set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_BINARY_DIR}/scripts/rpm/postuninstall") diff --git a/docker/tester/Dockerfile b/docker/tester/Dockerfile index 5f8276ed..109f0ce5 100644 --- a/docker/tester/Dockerfile +++ b/docker/tester/Dockerfile @@ -15,7 +15,7 @@ RUN if [ "$TARGETARCH" = "amd64" ] ; then curl -L -o grpcurl.tar.gz \ https://github.com/fullstorydev/grpcurl/releases/download/v1.8.6/grpcurl_1.8.6_linux_arm64.tar.gz; \ fi; -RUN dnf install -y python-pip python docker findutils jq unzip && dnf clean all +RUN dnf install -y python-pip python docker findutils jq unzip sed curl && dnf clean all ENV PATH="/root/.local/bin/:${PATH}" RUN pip install --user avocado-framework==69.0 RUN pip install --user avocado-framework-plugin-varianter-yaml-to-mux==69.0 diff --git a/scripts/debian/postinst.in b/scripts/debian/postinst.in index c344a43b..eb9a2d82 100755 --- a/scripts/debian/postinst.in +++ b/scripts/debian/postinst.in @@ -17,42 +17,43 @@ # set -e -DKMS_PACKAGE_NAME="@PACKAGE_NAME@" -DKMS_VERSION="@DRIVER_VERSION@" -NAME="@PACKAGE_NAME@" - chosen_driver="kmod" -case "$1" in - configure) - if [ -x /usr/bin/dialog ]; then - CHOICE=$(dialog --clear --backtitle "Choose your preferred driver" --title "Falco driver" --menu "Choose one of the following options:" 15 40 4 \ - 1 "Kmod" \ - 2 "eBPF" \ - 3 "Don't start" \ - 2>&1 >/dev/tty) - clear - case $CHOICE in - 1) - chosen_driver="kmod" - ;; - 2) - chosen_driver="ebpf" - ;; - 3) - chosen_driver= - ;; - esac - fi - case "$chosen_driver" in - "kmod") - falco-driver-loader module - ;; - "ebpf") - falco-driver-loader bpf - ;; - esac - ;; +if [ -z "$PS1" ]; then + echo "Skipping driver selection in non-interactive mode" +else + case "$1" in + configure) + if [ -x /usr/bin/dialog ]; then + CHOICE=$(dialog --clear --backtitle "Choose your preferred driver" --title "Falco driver" --menu "Choose one of the following options:" 15 40 4 \ + 1 "Kmod" \ + 2 "eBPF" \ + 3 "Don't start" \ + 2>&1 >/dev/tty) + clear + case $CHOICE in + 1) + chosen_driver="kmod" + ;; + 2) + chosen_driver="ebpf" + ;; + 3) + chosen_driver= + ;; + esac + fi + ;; + esac +fi + +case "$chosen_driver" in + "kmod") + falco-driver-loader module + ;; + "ebpf") + falco-driver-loader bpf + ;; esac # Based off what debhelper dh_systemd_enable/13.3.4 would have added diff --git a/scripts/rpm/postinstall.in b/scripts/rpm/postinstall.in index a15648bb..29a2f5d5 100755 --- a/scripts/rpm/postinstall.in +++ b/scripts/rpm/postinstall.in @@ -16,36 +16,39 @@ # set -e -mod_version="@DRIVER_VERSION@" - chosen_driver="kmod" -if [ -x /usr/bin/dialog ]; then - CHOICE=$(dialog --clear --backtitle "Choose your preferred driver" --title "Falco driver" --menu "Choose one of the following options:" 15 40 4 \ - 1 "Kmod" \ - 2 "eBPF" \ - 3 "Don't start" \ - 2>&1 >/dev/tty) - clear - case $CHOICE in - 1) - chosen_driver="kmod" - ;; - 2) - chosen_driver="ebpf" - ;; - 3) - chosen_driver= - ;; - esac +if [ -z "$PS1" ]; then + echo "Skipping driver selection in non-interactive mode" +else + if [ -x /usr/bin/dialog ]; then + CHOICE=$(dialog --clear --backtitle "Choose your preferred driver" --title "Falco driver" --menu "Choose one of the following options:" 15 40 4 \ + 1 "Kmod" \ + 2 "eBPF" \ + 3 "Don't start" \ + 2>&1 >/dev/tty) + clear + case $CHOICE in + 1) + chosen_driver="kmod" + ;; + 2) + chosen_driver="ebpf" + ;; + 3) + chosen_driver= + ;; + esac + fi fi + case "$chosen_driver" in - "kmod") - falco-driver-loader module - ;; - "ebpf") - falco-driver-loader bpf - ;; + "kmod") + falco-driver-loader module + ;; + "ebpf") + falco-driver-loader bpf + ;; esac # validate rpm macros by `rpm -qp --scripts `