From 0ed43e2c13db7bc24c153862cce9b97e27222b5c Mon Sep 17 00:00:00 2001 From: 2b-t <53856473+2b-t@users.noreply.github.com> Date: Sun, 29 Dec 2024 20:03:40 +0000 Subject: [PATCH] Closes #10; fix: Fix installation from Debian packages by installing package that the meta-package refers to instead of just the meta-package, document the changes in the manual installation guide and update unit tests accordingly --- doc/PreemptRt.md | 4 ++-- src/lib_install_debian.sh | 25 ++++++++++++++++--------- test/test_lib_install_debian.bats | 17 +++++++++-------- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/doc/PreemptRt.md b/doc/PreemptRt.md index ed3f058..adfed27 100644 --- a/doc/PreemptRt.md +++ b/doc/PreemptRt.md @@ -93,12 +93,12 @@ Afterwards you can reboot your system (be sure to select the correct kernel!) an ##### 1.2.2.2 Manual installation -Have a look at the search results resulting from [this query on package.debian.org](https://packages.debian.org/search?keywords=linux-image-rt-amd64) (potentially changing the architecture!) and see if you can find a kernel close to yours, e.g. [this one](https://packages.debian.org/bullseye/linux-image-rt-amd64). If you can find one click on the architecture `amd64` under `Download linux-image-rt-amd64` on the bottom and select a geographically suiting mirror and save the image in a location of your choice. +Have a look at the search results resulting from [this query on package.debian.org](https://packages.debian.org/search?keywords=linux-image-rt-amd64) and see if you can find a kernel close to yours, e.g. [this one](https://packages.debian.org/bullseye/linux-image-rt-amd64). If you can find one click on the dependency `dep` and then on the architecture `amd64` under `Download linux-image-*-rt-amd64` on the bottom and select a geographically suiting mirror and save the Debian package in a location of your choice. Finally install it by opening a terminal in this folder and typing ```shell -$ sudo dpkg -i linux-image-rt-amd64_5.10.106-1_amd64.deb +$ sudo dpkg -i linux-image-5.10.0-33-rt-amd64_5.10.226-1_amd64.deb $ sudo apt-get install -f ``` diff --git a/src/lib_install_debian.sh b/src/lib_install_debian.sh index 4c21611..42ffce3 100755 --- a/src/lib_install_debian.sh +++ b/src/lib_install_debian.sh @@ -14,21 +14,27 @@ function get_debian_versions() { echo $(cat /etc/debian_version | tr / " ") } -function get_preemptrt_file() { - declare desc="Get the PREEMPT_RT filename for the given Debian distribution by crawling the website" +function get_architecture() { + declare desc="Get the computer architecture" + echo $(dpkg --print-architecture) +} + +function get_preemptrt_debian_package() { + declare desc="Get the Debian package dependency referred to by the meta-package" local DEBIAN_VERSION=$1 - local ARCHITECTURE=$(dpkg --print-architecture) - echo $(curl -Ls https://packages.debian.org/${DEBIAN_VERSION}/${ARCHITECTURE}/linux-image-rt-${ARCHITECTURE}/download | grep -o -P '(?<=

Download Page for )(linux-image-rt.*)(?=<\/kbd>)') + local ARCHITECTURE=$2 + echo $(curl -Ls https://packages.debian.org/${DEBIAN_VERSION}/linux-image-rt-${ARCHITECTURE} | grep -o -P "(?<=)') + local ARCHITECTURE=$(get_architecture) + local DEBIAN_PACKAGE=$(get_preemptrt_debian_package "${DEBIAN_VERSION}" "${ARCHITECTURE}") + echo $(curl -Ls https://packages.debian.org/${DEBIAN_VERSION}/${ARCHITECTURE}/${DEBIAN_PACKAGE}/download | grep -o -P '(?<=
  • )') } function select_download_location() { diff --git a/test/test_lib_install_debian.bats b/test/test_lib_install_debian.bats index 2a3a86d..2b5bfe1 100755 --- a/test/test_lib_install_debian.bats +++ b/test/test_lib_install_debian.bats @@ -27,11 +27,12 @@ function setup() { assert_regex "${DEBIAN_VERSIONS}" "^([a-z]( )?)+$" } -@test "Test get_preemptrt_file" { +@test "Test get_preemptrt_debian_package" { declare desc="Test if a valid Debian file is returned for the given Debian version" - local DEBIAN_VERSION="bullseye" - local PREEMPTRT_FILE=$(get_preemptrt_file "${DEBIAN_VERSION}") - assert_regex "${PREEMPTRT_FILE}" "^(linux-image-rt-).+(\.deb)$" + local DEBIAN_VERSION="trixie" + local ARCHITECTURE=$(get_architecture) + local PREEMPTRT_FILE=$(get_preemptrt_debian_package "${DEBIAN_VERSION}" "${ARCHITECTURE}") + assert_regex "${PREEMPTRT_FILE}" "^(linux-image-).+(-rt-${ARCHITECTURE})$" } @test "Test select_debian_version" { @@ -49,14 +50,14 @@ function setup() { @test "Test get_download_locations" { declare desc="Test if a valid hyperlink is returned for the given Debian version" - local DEBIAN_VERSION="bullseye" + local DEBIAN_VERSION="trixie" local DOWNLOAD_LOCATION=$(get_download_locations "${DEBIAN_VERSION}") assert_regex "${DOWNLOAD_LOCATION}" "^(http://).+(\.deb)$" } @test "Test select_download_location" { declare desc="Test if select download location dialog returns a single option only" - local DEBIAN_VERSION="bullseye" + local DEBIAN_VERSION="trixie" tmux new -d -A -s "bats_test_session" local TEST_FILE=$(test_file) tmux send-keys -t "bats_test_session" "source ${TEST_FILE}" Enter @@ -70,8 +71,8 @@ function setup() { @test "Test extract_filename" { declare desc="Test if filename is extracted correctly from hyperlink" - local DOWNLOAD_LOCATION="http://ftp.us.debian.org/debian/pool/main/l/linux-signed-amd64/linux-image-rt-amd64_5.10.127-1_amd64.deb" + local DOWNLOAD_LOCATION="http://ftp.us.debian.org/debian/pool/main/l/linux-signed-amd64/linux-image-6.12.6-rt-amd64_6.12.6-1_amd64.deb" local DOWNLOADED_FILE=$(extract_filename "${DOWNLOAD_LOCATION}") - assert_regex "${DOWNLOADED_FILE}" "^(linux-image-rt-).+(\.deb)$" + assert_regex "${DOWNLOADED_FILE}" "^(linux-image-).+(\.deb)$" }