From f127ad2dcf4ee86eb24df0399f57e8d273cf3fb9 Mon Sep 17 00:00:00 2001 From: db39 <88856877+db39@users.noreply.github.com> Date: Thu, 28 Nov 2024 13:41:30 +0000 Subject: [PATCH] Fix install blocks (#1858) Resolves #1857 This change refactors our installation blocks to use single conditions, fixing a bug when checking for Raspbian-based systems that allowed installations to proceed on 64-bit systems regardless of the OS version. This also adds a check for a `FORCE_INSTALL` flag - setting the `FORCE_INSTALL` environment variable allows you to bypass the system checks to attempt an install on unsupported systems. Review
on CodeApprove --- bundler/bundle/install | 70 +++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 29 deletions(-) diff --git a/bundler/bundle/install b/bundler/bundle/install index 791705abb..c09df133e 100755 --- a/bundler/bundle/install +++ b/bundler/bundle/install @@ -11,35 +11,7 @@ set -u # Echo commands before executing them, by default to stderr. set -x -# Prevent installation on the Raspberry Pi 3. -if grep -q "^Model *: Raspberry Pi 3" /proc/cpuinfo ; then - echo 'You are trying to install on incompatible hardware.' >&2 - echo 'Visit https://github.com/tiny-pilot/tinypilot/ for more details.' >&2 - exit 1 -fi - -# Prevent installation on OS versions lower than Raspberry Pi OS 11 "Bullseye". -# Note: the distro ID is called "Raspbian" because the 32-bit version of the -# Raspberry Pi operating system is based on Raspbian repos (an independent -# open-source project). Similarly, the the 64-bit version of the Raspberry Pi -# operating system is based on Debian and its distro ID would be "Debian". -if [[ "$(lsb_release --id --short)" == 'Raspbian' ]] \ - && (( "$(lsb_release --release --short)" < 11 )); then - echo "TinyPilot no longer supports Raspberry Pi OS 10 \"Buster\" or lower." >&2 - echo "To install TinyPilot, you'll need to upgrade your operating system to Raspberry Pi OS 11 \"Bullseye\"." >&2 - exit 1 -fi - -# Prevent installation on Raspberry Pi OS 12 "Bookworm". -if [[ "$(lsb_release --id --short)" == 'Raspbian' ]] \ - && (( "$(lsb_release --release --short)" > 11 )); then - echo "TinyPilot is not yet compatible with Raspberry Pi OS 12 \"Bookworm\"." >&2 - echo "You can track our progress by visiting https://github.com/tiny-pilot/tinypilot/issues/1668" >&2 - echo "To install TinyPilot, you'll need to downgrade your operating system to Raspberry Pi OS 11 \"Bullseye\"." >&2 - exit 1 -fi - -# Abort installation if the read-only filesystem is enabled +# Abort installation if the read-only filesystem is enabled. if grep -q "boot=overlay" /proc/cmdline ; then echo 'The read-only filesystem is enabled.' >&2 echo 'Disable the read-only filesystem before proceeding.' >&2 @@ -47,6 +19,46 @@ if grep -q "boot=overlay" /proc/cmdline ; then exit 1 fi +# Check if the user is forcing an install. +if [[ -n "${FORCE_INSTALL+x}" ]]; then + echo 'Forcing installation on unsupported setup.' +else + # Restrict installation to only specific configurations. + + # Install only on Raspberry Pi 4 Model B. + if ! grep --quiet "^Model\s*: Raspberry Pi 4 Model B" /proc/cpuinfo ; then + echo 'You are trying to install on unsupported hardware.' >&2 + echo 'Visit https://github.com/tiny-pilot/tinypilot/ for more details.' >&2 + exit 1 + fi + + # Prevent installation on 64-bit operating systems. + # Note: the distro ID is called "Raspbian" because the 32-bit version of the + # Raspberry Pi operating system is based on Raspbian repos (an independent + # open-source project). Similarly, the the 64-bit version of the Raspberry Pi + # operating system is based on Debian and its distro ID would be "Debian". + if [[ "$(lsb_release --id --short)" != 'Raspbian' ]]; then + echo "TinyPilot currently only supports the 32-bit version of Raspberry Pi OS 11 \"Bullseye\"." >&2 + echo "To install TinyPilot, you'll need Raspberry Pi OS 11 \"Bullseye\" (32-bit)." >&2 + exit 1 + fi + + # Prevent installation on OS versions lower than Raspberry Pi OS 11 "Bullseye". + if (( "$(lsb_release --release --short)" < 11 )); then + echo "TinyPilot no longer supports Raspberry Pi OS 10 \"Buster\" or lower." >&2 + echo "To install TinyPilot, you'll need to upgrade your operating system to Raspberry Pi OS 11 \"Bullseye\" (32-bit)." >&2 + exit 1 + fi + + # Prevent installation on Raspberry Pi OS 12 "Bookworm". + if (( "$(lsb_release --release --short)" > 11 )); then + echo "TinyPilot is not yet compatible with Raspberry Pi OS 12 \"Bookworm\"." >&2 + echo "You can track our progress by visiting https://github.com/tiny-pilot/tinypilot/issues/1668" >&2 + echo "To install TinyPilot, you'll need to downgrade your operating system to Raspberry Pi OS 11 \"Bullseye\" (32-bit)." >&2 + exit 1 + fi +fi + # Get the filename of the Janus Debian package. JANUS_DEBIAN_PACKAGE="$(ls janus*.deb)" readonly JANUS_DEBIAN_PACKAGE