Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 10 additions & 5 deletions R/check_sys_deps.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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}")
Expand Down
6 changes: 3 additions & 3 deletions R/os-helper-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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_
}
Expand Down
21 changes: 21 additions & 0 deletions tests/testthat/test-os-helper-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Loading