From ca7836bf717c34f97719ba8aa3c3f6b07f0a591d Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sat, 21 Oct 2023 19:05:45 +0200 Subject: [PATCH 1/6] Remove now obsolete GLIBC version check Signed-off-by: DL6ER --- automated install/basic-install.sh | 9 --------- 1 file changed, 9 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index b9ed04a4..443ee85e 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1860,15 +1860,6 @@ get_binary_name() { local machine machine=$(uname -m) - # Get local GLIBC version (leave at "0.0" if no GLIBC, e.g., on musl) - local l_glibc_version="0.0" - if ldd --version 2>&1 | grep -q "GLIBC"; then - l_glibc_version=$(ldd --version | head -n1 | grep -o '[0-9.]*$') - printf "%b %b Detected GLIBC version %s\\n" "${OVER}" "${TICK}" "${l_glibc_version}" - else - printf "%b %b No GLIBC detected\\n" "${OVER}" "${CROSS}" - fi - local l_binary local str="Detecting processor" From 45687d675becf21f23953625c00efdb637531c21 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sat, 21 Oct 2023 19:13:45 +0200 Subject: [PATCH 2/6] Fix the binary detection for ARMv6 and simplify the router overall Signed-off-by: DL6ER --- automated install/basic-install.sh | 37 ++++++++++++++---------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 443ee85e..054d8eef 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1875,29 +1875,27 @@ get_binary_name() { local rev rev=$(echo "${cpu_arch}" | grep -o '[0-9]*') if [[ "${machine}" == "aarch64" ]]; then + # If AArch64 is found (e.g., BCM2711 in Raspberry Pi 4) printf "%b %b Detected AArch64 (64 Bit ARM) architecture\\n" "${OVER}" "${TICK}" - # set the binary to be used l_binary="pihole-FTL-arm64" - elif [[ "${cpu_arch}" == "armv6"* ]]; then + elif [[ "${cpu_arch}" == "v6"* ]]; then + # If ARMv6 is found (e.g., BCM2835 in Raspberry Pi 1 and Zero) printf "%b %b Detected ARMv6 architecture\\n" "${OVER}" "${TICK}" - # set the binary to be used (e.g., BCM2835 as found in Raspberry Pi Zero and Model 1) + l_binary="pihole-FTL-armv6" + elif [[ "${cpu_arch}" == "v7"* || "${rev}" -ge 7 ]]; then + # If ARMv7 or higher is found (e.g., BCM2836 in Raspberry PI 2 Mod. B) + # This path is also used for ARMv8 when the OS is in 32bit mode + # (e.g., BCM2837 in Raspberry Pi Model 3B, or BCM2711 in Raspberry Pi 4) + printf "%b %b Detected ARMv7 (or newer) architecture (%s)\\n" "${OVER}" "${TICK}" "${cpu_arch}" + l_binary="pihole-FTL-armv7" + elif [[ "${rev}" -gt 6 ]]; then + # Otherwise, if ARMv7 is found (e.g., BCM2836 in Raspberry Pi Model 2) + printf "%b %b Detected ARMv7 architecture (%s)\\n" "${OVER}" "${TICK}" "${cpu_arch}" l_binary="pihole-FTL-armv6" else - # If ARMv8 or higher is found (e.g., BCM2837 as found in Raspberry Pi Model 3B) - if [[ "${cpu_arch}" == "v7" || "${rev}" -gt 7 ]]; then - printf "%b %b Detected ARMv7 (or newer) architecture (%s)\\n" "${OVER}" "${TICK}" "${cpu_arch}" - # set the binary to be used - l_binary="pihole-FTL-armv7" - elif [[ "${rev}" -gt 6 ]]; then - # Otherwise, if ARMv7 is found (e.g., BCM2836 as found in Raspberry Pi Model 2) - printf "%b %b Detected ARMv7 architecture (%s)\\n" "${OVER}" "${TICK}" "${cpu_arch}" - # set the binary to be used - l_binary="pihole-FTL-armv6" - else - # Otherwise, Pi-hole does not support this architecture - printf "%b %b This processor architecture is not supported by Pi-hole (%s)\\n" "${OVER}" "${CROSS}" "${cpu_arch}" - l_binary="" - fi + # Otherwise, Pi-hole does not support this architecture + printf "%b %b This processor architecture is not supported by Pi-hole (%s)\\n" "${OVER}" "${CROSS}" "${cpu_arch}" + l_binary="" fi elif [[ "${machine}" == "x86_64" ]]; then # This gives the processor of packages dpkg installs (for example, "i386") @@ -1912,9 +1910,8 @@ get_binary_name() { printf "%b %b Detected 32bit (i686) architecture\\n" "${OVER}" "${TICK}" l_binary="pihole-FTL-386" else - # 64bit + # 64bit OS printf "%b %b Detected x86_64 architecture\\n" "${OVER}" "${TICK}" - # set the binary to be used l_binary="pihole-FTL-amd64" fi elif [[ "${machine}" == "riscv64" ]]; then From 30bfc7cc9f44cd9b0138ebc2e7400f4e592fbd42 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sat, 21 Oct 2023 19:15:10 +0200 Subject: [PATCH 3/6] Add binutils tot he OS check dependencies as we need it to check if the local system is abel to run any of our precompiled FTL binaries Signed-off-by: DL6ER --- automated install/basic-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 054d8eef..019cc3e3 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -302,9 +302,9 @@ package_manager_detect() { # Update package cache update_package_cache || exit 1 # Packages required to perform the os_check (stored as an array) - OS_CHECK_DEPS=(grep dnsutils) + OS_CHECK_DEPS=(grep dnsutils binutils) # Packages required to run this install script (stored as an array) - INSTALLER_DEPS=(git iproute2 dialog ca-certificates binutils) + INSTALLER_DEPS=(git iproute2 dialog ca-certificates) # Packages required to run Pi-hole (stored as an array) PIHOLE_DEPS=(cron curl iputils-ping psmisc sudo unzip idn2 libcap2-bin dns-root-data libcap2 netcat-openbsd procps jq) From 38ecc1693f50764209b8a0eff289064eef0ed881 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sat, 21 Oct 2023 19:28:59 +0200 Subject: [PATCH 4/6] Further simplify the ARMv6 test Signed-off-by: DL6ER --- automated install/basic-install.sh | 8 ++------ test/test_any_automated_install.py | 8 ++++---- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 019cc3e3..2d47a548 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1878,20 +1878,16 @@ get_binary_name() { # If AArch64 is found (e.g., BCM2711 in Raspberry Pi 4) printf "%b %b Detected AArch64 (64 Bit ARM) architecture\\n" "${OVER}" "${TICK}" l_binary="pihole-FTL-arm64" - elif [[ "${cpu_arch}" == "v6"* ]]; then + elif [[ "${rev}" -eq 6 ]]; then # If ARMv6 is found (e.g., BCM2835 in Raspberry Pi 1 and Zero) printf "%b %b Detected ARMv6 architecture\\n" "${OVER}" "${TICK}" l_binary="pihole-FTL-armv6" - elif [[ "${cpu_arch}" == "v7"* || "${rev}" -ge 7 ]]; then + elif [[ "${rev}" -ge 7 ]]; then # If ARMv7 or higher is found (e.g., BCM2836 in Raspberry PI 2 Mod. B) # This path is also used for ARMv8 when the OS is in 32bit mode # (e.g., BCM2837 in Raspberry Pi Model 3B, or BCM2711 in Raspberry Pi 4) printf "%b %b Detected ARMv7 (or newer) architecture (%s)\\n" "${OVER}" "${TICK}" "${cpu_arch}" l_binary="pihole-FTL-armv7" - elif [[ "${rev}" -gt 6 ]]; then - # Otherwise, if ARMv7 is found (e.g., BCM2836 in Raspberry Pi Model 2) - printf "%b %b Detected ARMv7 architecture (%s)\\n" "${OVER}" "${TICK}" "${cpu_arch}" - l_binary="pihole-FTL-armv6" else # Otherwise, Pi-hole does not support this architecture printf "%b %b This processor architecture is not supported by Pi-hole (%s)\\n" "${OVER}" "${CROSS}" "${cpu_arch}" diff --git a/test/test_any_automated_install.py b/test/test_any_automated_install.py index 1980f0b6..7d9d15f6 100644 --- a/test/test_any_automated_install.py +++ b/test/test_any_automated_install.py @@ -269,8 +269,8 @@ def test_FTL_detect_armv6_no_errors(host): mock_command_2( "readelf", { - "-A /bin/sh": ("Tag_CPU_arch: armv6KZ", "0"), - "-A /usr/bin/sh": ("Tag_CPU_arch: armv6KZ", "0"), + "-A /bin/sh": ("Tag_CPU_arch: armv6", "0"), + "-A /usr/bin/sh": ("Tag_CPU_arch: armv6", "0"), }, host, ) @@ -319,7 +319,7 @@ def test_FTL_detect_armv7l_no_errors(host): ) expected_stdout = info_box + " FTL Checks..." assert expected_stdout in detectPlatform.stdout - expected_stdout = tick_box + (" Detected ARMv7 architecture (armv7l)") + expected_stdout = tick_box + (" Detected ARMv7 (or newer) architecture") assert expected_stdout in detectPlatform.stdout expected_stdout = tick_box + " Downloading and Installing FTL" assert expected_stdout in detectPlatform.stdout @@ -352,7 +352,7 @@ def test_FTL_detect_armv7_no_errors(host): ) expected_stdout = info_box + " FTL Checks..." assert expected_stdout in detectPlatform.stdout - expected_stdout = tick_box + (" Detected ARMv7 architecture (armv7)") + expected_stdout = tick_box + (" Detected ARMv7 (or newer) architecture") assert expected_stdout in detectPlatform.stdout expected_stdout = tick_box + " Downloading and Installing FTL" assert expected_stdout in detectPlatform.stdout From 369ccf13a846bb64ac7b6d8a454f6bda4cf2a89a Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sat, 21 Oct 2023 21:40:21 +0200 Subject: [PATCH 5/6] Move FTL binary availability check after the supported OS check Signed-off-by: DL6ER --- automated install/basic-install.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 2d47a548..1ecde7a9 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -2088,16 +2088,6 @@ main() { fi fi - # Check if there is a usable FTL binary available on this architecture - do - # this early on as FTL is a hard dependency for Pi-hole - local funcOutput - funcOutput=$(get_binary_name) #Store output of get_binary_name here - # Abort early if this processor is not supported (get_binary_name returns empty string) - if [[ "${funcOutput}" == "" ]]; then - printf " %b Upgrade/install aborted\\n" "${CROSS}" "${DISTRO_NAME}" - exit 1 - fi - # Check if SELinux is Enforcing and exit before doing anything else checkSelinux @@ -2114,6 +2104,16 @@ main() { # Check that the installed OS is officially supported - display warning if not os_check + # Check if there is a usable FTL binary available on this architecture - do + # this early on as FTL is a hard dependency for Pi-hole + local funcOutput + funcOutput=$(get_binary_name) #Store output of get_binary_name here + # Abort early if this processor is not supported (get_binary_name returns empty string) + if [[ "${funcOutput}" == "" ]]; then + printf " %b Upgrade/install aborted\\n" "${CROSS}" "${DISTRO_NAME}" + exit 1 + fi + # Install packages used by this installation script printf " %b Checking for / installing Required dependencies for this install script...\\n" "${INFO}" install_dependent_packages "${INSTALLER_DEPS[@]}" From 842a9d7778e5de72f99d39b4fe78ed8523c94eb1 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 22 Oct 2023 08:32:52 +0200 Subject: [PATCH 6/6] Address review comments Signed-off-by: DL6ER --- automated install/basic-install.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 1ecde7a9..87bf1ea4 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -90,7 +90,6 @@ IPV6_ADDRESS=${IPV6_ADDRESS} QUERY_LOGGING=true WEBPORT=8080 PRIVACY_LEVEL=0 -CACHE_SIZE=10000 if [ -z "${USER}" ]; then USER="$(id -un)" @@ -301,11 +300,11 @@ package_manager_detect() { PKG_COUNT="${PKG_MANAGER} -s -o Debug::NoLocking=true upgrade | grep -c ^Inst || true" # Update package cache update_package_cache || exit 1 - # Packages required to perform the os_check (stored as an array) + # Packages required to perform the os_check and FTL binary detection OS_CHECK_DEPS=(grep dnsutils binutils) - # Packages required to run this install script (stored as an array) + # Packages required to run this install script INSTALLER_DEPS=(git iproute2 dialog ca-certificates) - # Packages required to run Pi-hole (stored as an array) + # Packages required to run Pi-hole PIHOLE_DEPS=(cron curl iputils-ping psmisc sudo unzip idn2 libcap2-bin dns-root-data libcap2 netcat-openbsd procps jq) # If apt-get is not found, check for rpm. @@ -1856,29 +1855,30 @@ remove_dir() { } get_binary_name() { - # Get the OS architecture (we cannot use uname -m as this may return an incorrect architecture when buildx-compiling with QEMU for arm) + local l_binary local machine machine=$(uname -m) - local l_binary - local str="Detecting processor" printf " %b %s..." "${INFO}" "${str}" - # If the machine is arm or aarch - if [[ "${machine}" == "arm"* || "${machine}" == *"aarch"* ]]; then - # ARM + + # If the machine is aarch64 (armv8) + if [[ "${machine}" == "aarch64" ]]; then + # If AArch64 is found (e.g., BCM2711 in Raspberry Pi 4) + printf "%b %b Detected AArch64 (64 Bit ARM) architecture\\n" "${OVER}" "${TICK}" + l_binary="pihole-FTL-arm64" + elif [[ "${machine}" == "arm"* ]]; then + # ARM 32 bit # Get supported processor from other binaries installed on the system + # We cannot really rely on the output of $(uname -m) above as this may + # return an incorrect architecture when buildx-compiling with QEMU local cpu_arch cpu_arch=$(readelf -A "$(command -v sh)" | grep Tag_CPU_arch | awk '{ print $2 }') # Get the revision from the CPU architecture local rev rev=$(echo "${cpu_arch}" | grep -o '[0-9]*') - if [[ "${machine}" == "aarch64" ]]; then - # If AArch64 is found (e.g., BCM2711 in Raspberry Pi 4) - printf "%b %b Detected AArch64 (64 Bit ARM) architecture\\n" "${OVER}" "${TICK}" - l_binary="pihole-FTL-arm64" - elif [[ "${rev}" -eq 6 ]]; then + if [[ "${rev}" -eq 6 ]]; then # If ARMv6 is found (e.g., BCM2835 in Raspberry Pi 1 and Zero) printf "%b %b Detected ARMv6 architecture\\n" "${OVER}" "${TICK}" l_binary="pihole-FTL-armv6"