From b1b38791fa458c03d2e1bff1320f92f032974a1a Mon Sep 17 00:00:00 2001 From: pat-s Date: Wed, 11 Sep 2024 10:12:36 +0200 Subject: [PATCH 1/5] support rhel platform parsing --- R/sysreqs.R | 4 ++++ R/sysreqs2.R | 3 +++ 2 files changed, 7 insertions(+) diff --git a/R/sysreqs.R b/R/sysreqs.R index ebc0ce38..8cceb409 100644 --- a/R/sysreqs.R +++ b/R/sysreqs.R @@ -347,6 +347,10 @@ parse_sysreqs_platform <- function(x) { osplt$distribution <- restpcs[1] osplt$version <- paste0(restpcs[-1], collapse = "-") } + if (osplt$distribution == "rhel") { + osplt$distribution = "redhat" + osplt$version = strsplit(osplt$version, "[.]")[[1]][1] + } osplt } diff --git a/R/sysreqs2.R b/R/sysreqs2.R index c630329f..ee9c083e 100644 --- a/R/sysreqs2.R +++ b/R/sysreqs2.R @@ -26,6 +26,9 @@ sysreqs2_cmds <- utils::read.table( find_sysreqs_platform <- function(sysreqs_platform = NULL) { sysreqs_platform <- sysreqs_platform %||% current_config()$get("sysreqs_platform") plt <- parse_sysreqs_platform(sysreqs_platform) + if (plt$distribution == "rhel") { + plt$distribution = "redhat" + } idx <- which( sysreqs2_cmds$os == plt$os & sysreqs2_cmds$distribution == plt$distribution & From 5e56f564b96f3eac485dc8e455f0bb417033e3c6 Mon Sep 17 00:00:00 2001 From: pat-s Date: Wed, 11 Sep 2024 13:55:30 +0200 Subject: [PATCH 2/5] add rhel to os table, remove renaming workaround --- R/sysreqs2.R | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/R/sysreqs2.R b/R/sysreqs2.R index ee9c083e..2a57ec3b 100644 --- a/R/sysreqs2.R +++ b/R/sysreqs2.R @@ -18,6 +18,7 @@ sysreqs2_cmds <- utils::read.table( 'Red Hat Enterprise Linux' linux redhat 6 NA 'yum install -y' rpm 'Red Hat Enterprise Linux' linux redhat 7 NA 'yum install -y' rpm 'Red Hat Enterprise Linux' linux redhat * NA 'dnf install -y' rpm + 'Red Hat Enterprise Linux' linux rhel * NA 'dnf install -y' rpm 'Fedora Linux' linux fedora * NA 'dnf install -y' rpm 'openSUSE Linux' linux opensuse * NA 'zypper --non-interactive install' rpm 'SUSE Linux Enterprise' linux sle * NA 'zypper --non-interactive install' rpm @@ -26,9 +27,6 @@ sysreqs2_cmds <- utils::read.table( find_sysreqs_platform <- function(sysreqs_platform = NULL) { sysreqs_platform <- sysreqs_platform %||% current_config()$get("sysreqs_platform") plt <- parse_sysreqs_platform(sysreqs_platform) - if (plt$distribution == "rhel") { - plt$distribution = "redhat" - } idx <- which( sysreqs2_cmds$os == plt$os & sysreqs2_cmds$distribution == plt$distribution & From 8fb8044ca8c4c2e9e003d60293922d13e5c5882c Mon Sep 17 00:00:00 2001 From: pat-s Date: Wed, 11 Sep 2024 13:57:16 +0200 Subject: [PATCH 3/5] update version detection logic --- R/sysreqs.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/R/sysreqs.R b/R/sysreqs.R index 8cceb409..a5803a6e 100644 --- a/R/sysreqs.R +++ b/R/sysreqs.R @@ -347,8 +347,7 @@ parse_sysreqs_platform <- function(x) { osplt$distribution <- restpcs[1] osplt$version <- paste0(restpcs[-1], collapse = "-") } - if (osplt$distribution == "rhel") { - osplt$distribution = "redhat" + if (osplt$distribution == "rhel" || osplt$distribution == "redhat") { osplt$version = strsplit(osplt$version, "[.]")[[1]][1] } osplt From efdf5f68ba3b432cc0dbbec1d5ebb83357f79fc7 Mon Sep 17 00:00:00 2001 From: pat-s Date: Wed, 11 Sep 2024 14:03:01 +0200 Subject: [PATCH 4/5] tests --- tests/testthat/_snaps/sysreqs.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/testthat/_snaps/sysreqs.md b/tests/testthat/_snaps/sysreqs.md index 8dd67f53..9fd4629f 100644 --- a/tests/testthat/_snaps/sysreqs.md +++ b/tests/testthat/_snaps/sysreqs.md @@ -3,7 +3,7 @@ Code sysreqs_platforms() Output - # A data frame: 10 x 7 + # A data frame: 11 x 7 name os distribution version update_command install_command query_command 1 Ubun~ linux ubuntu * apt-get -y up~ apt-get -y ins~ dpkg-query @@ -13,9 +13,10 @@ 5 Red ~ linux redhat 6 yum install -y rpm 6 Red ~ linux redhat 7 yum install -y rpm 7 Red ~ linux redhat * dnf install -y rpm - 8 Fedo~ linux fedora * dnf install -y rpm - 9 open~ linux opensuse * zypper --non-i~ rpm - 10 SUSE~ linux sle * zypper --non-i~ rpm + 8 Red ~ linux rhel * dnf install -y rpm + 9 Fedo~ linux fedora * dnf install -y rpm + 10 open~ linux opensuse * zypper --non-i~ rpm + 11 SUSE~ linux sle * zypper --non-i~ rpm # sysreqs_db_list From 06d0d42c240386a8a505f5481ef916585e3b3798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Wed, 11 Sep 2024 18:08:37 +0200 Subject: [PATCH 5/5] Simplify RHEL detection * add 7.x versions explicitly to distro table * remove rhel special casing. --- R/sysreqs.R | 3 --- R/sysreqs2.R | 10 ++++++++++ tests/testthat/_snaps/sysreqs.md | 24 +++++++++++++++++------- tests/testthat/test-sysreqs.R | 2 +- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/R/sysreqs.R b/R/sysreqs.R index a5803a6e..ebc0ce38 100644 --- a/R/sysreqs.R +++ b/R/sysreqs.R @@ -347,9 +347,6 @@ parse_sysreqs_platform <- function(x) { osplt$distribution <- restpcs[1] osplt$version <- paste0(restpcs[-1], collapse = "-") } - if (osplt$distribution == "rhel" || osplt$distribution == "redhat") { - osplt$version = strsplit(osplt$version, "[.]")[[1]][1] - } osplt } diff --git a/R/sysreqs2.R b/R/sysreqs2.R index 535ffc34..9cad649a 100644 --- a/R/sysreqs2.R +++ b/R/sysreqs2.R @@ -18,6 +18,16 @@ sysreqs2_cmds <- utils::read.table( 'Red Hat Enterprise Linux' linux redhat 6 NA 'yum install -y' rpm 'Red Hat Enterprise Linux' linux redhat 7 NA 'yum install -y' rpm 'Red Hat Enterprise Linux' linux redhat * NA 'dnf install -y' rpm + 'Red Hat Enterprise Linux' linux rhel 7.0 NA 'yum install -y' rpm + 'Red Hat Enterprise Linux' linux rhel 7.1 NA 'yum install -y' rpm + 'Red Hat Enterprise Linux' linux rhel 7.2 NA 'yum install -y' rpm + 'Red Hat Enterprise Linux' linux rhel 7.3 NA 'yum install -y' rpm + 'Red Hat Enterprise Linux' linux rhel 7.4 NA 'yum install -y' rpm + 'Red Hat Enterprise Linux' linux rhel 7.5 NA 'yum install -y' rpm + 'Red Hat Enterprise Linux' linux rhel 7.6 NA 'yum install -y' rpm + 'Red Hat Enterprise Linux' linux rhel 7.7 NA 'yum install -y' rpm + 'Red Hat Enterprise Linux' linux rhel 7.8 NA 'yum install -y' rpm + 'Red Hat Enterprise Linux' linux rhel 7.9 NA 'yum install -y' rpm 'Red Hat Enterprise Linux' linux rhel * NA 'dnf install -y' rpm 'Fedora Linux' linux fedora * NA 'dnf install -y' rpm 'openSUSE Linux' linux opensuse * NA 'zypper --non-interactive install' rpm diff --git a/tests/testthat/_snaps/sysreqs.md b/tests/testthat/_snaps/sysreqs.md index 1ffea690..8ca6f5a1 100644 --- a/tests/testthat/_snaps/sysreqs.md +++ b/tests/testthat/_snaps/sysreqs.md @@ -1,9 +1,9 @@ # sysreqs_platforms Code - sysreqs_platforms() + print(sysreqs_platforms(), n = Inf) Output - # A data frame: 12 x 7 + # A data frame: 22 x 7 name os distribution version update_command install_command query_command 1 Ubun~ linux ubuntu * apt-get -y up~ apt-get -y ins~ dpkg-query @@ -13,11 +13,21 @@ 5 Red ~ linux redhat 6 yum install -y rpm 6 Red ~ linux redhat 7 yum install -y rpm 7 Red ~ linux redhat * dnf install -y rpm - 8 Red ~ linux rhel * dnf install -y rpm - 9 Fedo~ linux fedora * dnf install -y rpm - 10 open~ linux opensuse * zypper --non-i~ rpm - 11 SUSE~ linux sle * zypper --non-i~ rpm - 12 Alpi~ linux alpine * apk add --no-c~ apk + 8 Red ~ linux rhel 7.0 yum install -y rpm + 9 Red ~ linux rhel 7.1 yum install -y rpm + 10 Red ~ linux rhel 7.2 yum install -y rpm + 11 Red ~ linux rhel 7.3 yum install -y rpm + 12 Red ~ linux rhel 7.4 yum install -y rpm + 13 Red ~ linux rhel 7.5 yum install -y rpm + 14 Red ~ linux rhel 7.6 yum install -y rpm + 15 Red ~ linux rhel 7.7 yum install -y rpm + 16 Red ~ linux rhel 7.8 yum install -y rpm + 17 Red ~ linux rhel 7.9 yum install -y rpm + 18 Red ~ linux rhel * dnf install -y rpm + 19 Fedo~ linux fedora * dnf install -y rpm + 20 open~ linux opensuse * zypper --non-i~ rpm + 21 SUSE~ linux sle * zypper --non-i~ rpm + 22 Alpi~ linux alpine * apk add --no-c~ apk # sysreqs_db_list diff --git a/tests/testthat/test-sysreqs.R b/tests/testthat/test-sysreqs.R index cd33717b..bd63c78f 100644 --- a/tests/testthat/test-sysreqs.R +++ b/tests/testthat/test-sysreqs.R @@ -1,6 +1,6 @@ test_that("sysreqs_platforms", { - expect_snapshot(sysreqs_platforms()) + expect_snapshot(print(sysreqs_platforms(), n = Inf)) }) test_that("sysreqs_db_list", {