diff --git a/DESCRIPTION b/DESCRIPTION index c438f49..5c0b459 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: audit.base Title: Base package for Posit Checks -Version: 0.7.6 +Version: 0.7.7 Authors@R: person("Jumping", "Rivers", , "info@jumpingrivers.com", role = c("aut", "cre")) Description: Base package for sharing classes between posit audit diff --git a/NEWS.md b/NEWS.md index d341d67..d57a451 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,6 @@ +# audit.base 0.7.7 _2026-10-16_ + * fix: `clean_libs()` strips only the architecture from RHEL package names, so names with dots, such as `java-1.8.0-openjdk-devel`, `libgit2_1.7-devel` and `gdal3.4`, are no longer reported missing. `get_installed_libs()` lists names with `rpm -qa`, which also works on SUSE (#59) + # audit.base 0.7.6 _2026-10-16_ * fix: `check_sys_deps()` reads the distribution from os-release `ID` and `ID_LIKE`, and passes `VERSION_ID` to Posit Package Manager, so Ubuntu 26.04, RHEL 10, Debian, Rocky Linux and AlmaLinux work. If P3M or the package listing doesn't support a system, it warns with the reason and returns `NA` rather than stopping the audit (#58) * fix: System requirements come from `packagemanager.posit.co`, Posit Package Manager's current address diff --git a/R/check_sys_deps.R b/R/check_sys_deps.R index 174920f..267d52e 100644 --- a/R/check_sys_deps.R +++ b/R/check_sys_deps.R @@ -64,9 +64,9 @@ get_installed_libs = function() { if (identical(tool, "apt")) { libs = processx::run("apt", args = c("list", "--installed")) libs = stringr::str_split(libs$stdout, "\n")[[1]][-1] - } else if (identical(tool, "yum")) { - libs = processx::run("yum", args = c("list", "installed"))$stdout - libs = stringr::str_split(libs, "\n")[[1]][-(1:2)] + } else if (identical(tool, "rpm")) { + libs = processx::run("rpm", args = c("-qa", "--qf", "%{NAME}\\n"))$stdout + libs = stringr::str_split(libs, "\n")[[1]] } else { libs = character(0) } @@ -83,8 +83,13 @@ clean_libs = function(os_release, libs) { if (identical(tool, "apt")) { libs = stringr::str_match(libs, "^[^/]*")[, 1] libs = switch_ubuntu_aliases(libs) - } else if (identical(tool, "yum")) { - libs = stringr::str_match(libs, "^[^\\.]*")[, 1] + } else if (identical(tool, "rpm")) { + # rpm -qa gives bare names; `yum list installed` lines start name.arch. + # Names can contain dots (java-1.8.0-openjdk), so strip only the architecture. + libs = libs[!stringr::str_detect(libs, "^(Installed Packages|Last metadata)")] + libs = stringr::str_extract(libs, "^\\S+") + libs = stringr::str_remove(libs, "\\.(x86_64|noarch|i[3-6]86|aarch64|ppc64le|s390x)$") + libs = libs[!is.na(libs) & nzchar(libs)] } else { os_name = os_release_value(os_release_df, "pretty_name") # nolint cli::cli_warn("Can't list the installed system libraries on {os_name}") diff --git a/R/os-helper-functions.R b/R/os-helper-functions.R index 6c65720..d8b7182 100644 --- a/R/os-helper-functions.R +++ b/R/os-helper-functions.R @@ -22,13 +22,13 @@ get_p3m_system = function(os_release_df) { list(distribution = distribution, release = release) } -# apt or yum, which list installed packages in different formats; NA for any other OS +# apt or rpm, which list installed packages in different formats; NA for any other OS get_package_tool = function(os_release_df) { distribution = get_p3m_system(os_release_df)$distribution if (distribution %in% c("ubuntu", "debian")) { "apt" - } else if (distribution %in% c("redhat", "centos")) { - "yum" + } else if (distribution %in% c("redhat", "centos", "opensuse", "sle")) { + "rpm" } else { NA_character_ } diff --git a/tests/testthat/test-os-helper-functions.R b/tests/testthat/test-os-helper-functions.R index 7d6f47e..6675b72 100644 --- a/tests/testthat/test-os-helper-functions.R +++ b/tests/testthat/test-os-helper-functions.R @@ -50,3 +50,24 @@ test_that("P3M's reason for rejecting a system reaches the user", { expect_warning(get_pkg_requirements("rockylinux", "8"), "Unsupported system") expect_identical(suppressWarnings(get_pkg_requirements("rockylinux", "8")), NA) }) + +test_that("clean_libs() keeps the dots in RHEL package names", { + rhel = c("ID=\"rhel\"", "ID_LIKE=\"fedora\"", "VERSION_ID=\"8.10\"") + yum = c( + "Installed Packages", + "java-1.8.0-openjdk-devel.x86_64 1:1.8.0.412 @appstream", + "libgit2_1.7-devel.x86_64 1.7.2 @epel", + "gdal3.4-devel.x86_64 3.4.3-1 @epel", + "a-very-long-package-name-that-yum-wraps.noarch", + " 1.0-1 @appstream" + ) + expected = c( + "a-very-long-package-name-that-yum-wraps", + "gdal3.4-devel", + "java-1.8.0-openjdk-devel", + "libgit2_1.7-devel" + ) + expect_identical(clean_libs(rhel, yum), expected) + # rpm -qa --qf "%{NAME}\\n" gives the names as they are + expect_identical(clean_libs(rhel, expected), expected) +})