Skip to content

Commit 0ed43e2

Browse files
committed
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
1 parent f7c9f4d commit 0ed43e2

File tree

3 files changed

+27
-19
lines changed

3 files changed

+27
-19
lines changed

doc/PreemptRt.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ Afterwards you can reboot your system (be sure to select the correct kernel!) an
9393

9494
##### 1.2.2.2 Manual installation
9595

96-
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.
96+
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.
9797

9898
Finally install it by opening a terminal in this folder and typing
9999

100100
```shell
101-
$ sudo dpkg -i linux-image-rt-amd64_5.10.106-1_amd64.deb
101+
$ sudo dpkg -i linux-image-5.10.0-33-rt-amd64_5.10.226-1_amd64.deb
102102
$ sudo apt-get install -f
103103
```
104104

src/lib_install_debian.sh

+16-9
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,27 @@ function get_debian_versions() {
1414
echo $(cat /etc/debian_version | tr / " ")
1515
}
1616

17-
function get_preemptrt_file() {
18-
declare desc="Get the PREEMPT_RT filename for the given Debian distribution by crawling the website"
17+
function get_architecture() {
18+
declare desc="Get the computer architecture"
19+
echo $(dpkg --print-architecture)
20+
}
21+
22+
function get_preemptrt_debian_package() {
23+
declare desc="Get the Debian package dependency referred to by the meta-package"
1924
local DEBIAN_VERSION=$1
20-
local ARCHITECTURE=$(dpkg --print-architecture)
21-
echo $(curl -Ls https://packages.debian.org/${DEBIAN_VERSION}/${ARCHITECTURE}/linux-image-rt-${ARCHITECTURE}/download | grep -o -P '(?<=<h2>Download Page for <kbd>)(linux-image-rt.*)(?=<\/kbd>)')
25+
local ARCHITECTURE=$2
26+
echo $(curl -Ls https://packages.debian.org/${DEBIAN_VERSION}/linux-image-rt-${ARCHITECTURE} | grep -o -P "(?<=<a href=\"\/${DEBIAN_VERSION}\/)(linux-image-.*-rt-${ARCHITECTURE})(?=\")")
2227
}
2328

2429
function select_debian_version() {
2530
declare desc="Select the Debian version from a list of given Debian versions"
2631
local POSSIBLE_DEBIAN_VERSIONS=$(get_debian_versions)
32+
local ARCHITECTURE=$(get_architecture)
2733
local DIALOG_POSSIBLE_DEBIAN_VERSIONS=""
2834
for VER in ${POSSIBLE_DEBIAN_VERSIONS}; do
29-
local PREEMPTRT_FILE=$(get_preemptrt_file "$VER")
30-
if [ ! -z "${PREEMPTRT_FILE}" ]; then
31-
DIALOG_POSSIBLE_DEBIAN_VERSIONS="${DIALOG_POSSIBLE_DEBIAN_VERSIONS} ${VER} ${PREEMPTRT_FILE}"
35+
local PREEMPTRT_DEBIAN_PACKAGE=$(get_preemptrt_debian_package "${VER}" "${ARCHITECTURE}")
36+
if [ ! -z "${PREEMPTRT_DEBIAN_PACKAGE}" ]; then
37+
DIALOG_POSSIBLE_DEBIAN_VERSIONS="${DIALOG_POSSIBLE_DEBIAN_VERSIONS} ${VER} ${PREEMPTRT_DEBIAN_PACKAGE}"
3238
fi
3339
done
3440
echo $(dialog --keep-tite --stdout --menu "Select the desired PREEMPT_RT kernel version:" 0 0 4 ${DIALOG_POSSIBLE_DEBIAN_VERSIONS})
@@ -37,8 +43,9 @@ function select_debian_version() {
3743
function get_download_locations() {
3844
declare desc="Get a list of available download servers for the PREEMPT_RT Debian package given the Debian version by crawling the website"
3945
local DEBIAN_VERSION=$1
40-
local ARCHITECTURE=$(dpkg --print-architecture)
41-
echo $(curl -Ls https://packages.debian.org/${DEBIAN_VERSION}/${ARCHITECTURE}/linux-image-rt-${ARCHITECTURE}/download | grep -o -P '(?<=<li><a href=\")(.*\.deb)(?=\">)')
46+
local ARCHITECTURE=$(get_architecture)
47+
local DEBIAN_PACKAGE=$(get_preemptrt_debian_package "${DEBIAN_VERSION}" "${ARCHITECTURE}")
48+
echo $(curl -Ls https://packages.debian.org/${DEBIAN_VERSION}/${ARCHITECTURE}/${DEBIAN_PACKAGE}/download | grep -o -P '(?<=<li><a href=\")(.*\.deb)(?=\">)')
4249
}
4350

4451
function select_download_location() {

test/test_lib_install_debian.bats

+9-8
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ function setup() {
2727
assert_regex "${DEBIAN_VERSIONS}" "^([a-z]( )?)+$"
2828
}
2929

30-
@test "Test get_preemptrt_file" {
30+
@test "Test get_preemptrt_debian_package" {
3131
declare desc="Test if a valid Debian file is returned for the given Debian version"
32-
local DEBIAN_VERSION="bullseye"
33-
local PREEMPTRT_FILE=$(get_preemptrt_file "${DEBIAN_VERSION}")
34-
assert_regex "${PREEMPTRT_FILE}" "^(linux-image-rt-).+(\.deb)$"
32+
local DEBIAN_VERSION="trixie"
33+
local ARCHITECTURE=$(get_architecture)
34+
local PREEMPTRT_FILE=$(get_preemptrt_debian_package "${DEBIAN_VERSION}" "${ARCHITECTURE}")
35+
assert_regex "${PREEMPTRT_FILE}" "^(linux-image-).+(-rt-${ARCHITECTURE})$"
3536
}
3637

3738
@test "Test select_debian_version" {
@@ -49,14 +50,14 @@ function setup() {
4950

5051
@test "Test get_download_locations" {
5152
declare desc="Test if a valid hyperlink is returned for the given Debian version"
52-
local DEBIAN_VERSION="bullseye"
53+
local DEBIAN_VERSION="trixie"
5354
local DOWNLOAD_LOCATION=$(get_download_locations "${DEBIAN_VERSION}")
5455
assert_regex "${DOWNLOAD_LOCATION}" "^(http://).+(\.deb)$"
5556
}
5657

5758
@test "Test select_download_location" {
5859
declare desc="Test if select download location dialog returns a single option only"
59-
local DEBIAN_VERSION="bullseye"
60+
local DEBIAN_VERSION="trixie"
6061
tmux new -d -A -s "bats_test_session"
6162
local TEST_FILE=$(test_file)
6263
tmux send-keys -t "bats_test_session" "source ${TEST_FILE}" Enter
@@ -70,8 +71,8 @@ function setup() {
7071

7172
@test "Test extract_filename" {
7273
declare desc="Test if filename is extracted correctly from hyperlink"
73-
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"
74+
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"
7475
local DOWNLOADED_FILE=$(extract_filename "${DOWNLOAD_LOCATION}")
75-
assert_regex "${DOWNLOADED_FILE}" "^(linux-image-rt-).+(\.deb)$"
76+
assert_regex "${DOWNLOADED_FILE}" "^(linux-image-).+(\.deb)$"
7677
}
7778

0 commit comments

Comments
 (0)