Skip to content

Commit

Permalink
add alpine support
Browse files Browse the repository at this point in the history
  • Loading branch information
pat-s committed Sep 11, 2024
1 parent b9651b2 commit 39803c9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions R/sysreqs2.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ sysreqs2_cmds <- utils::read.table(
'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
'Alpine Linux' linux alpine * NA 'apk add --no-cache' apk
"))

find_sysreqs_platform <- function(sysreqs_platform = NULL) {
Expand Down
42 changes: 42 additions & 0 deletions R/system-packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ async_system_list_packages <- function(config = NULL) {
pkgtool <- sysreqs2_command(sysreqs_platform, "query")
if (pkgtool == "dpkg-query") {
async_system_list_packages_dpkg_query(config)
} else if (pkgtool == "apk") {
async_system_list_packages_apk(config)
} else {
async_system_list_packages_rpm(config)
}
Expand Down Expand Up @@ -124,3 +126,43 @@ parse_rpm_output <- function(lines) {
pkgs <- pkgs[order(tolower(pkgs$package)), ]
pkgs
}

# For APK, we need this query:

async_system_list_packages_apk <- function(config) {
args <- c(
"list",
"-I"
)
stdout <- tempfile()
external_process(function(...) {
processx::process$new(
"apk",
stdout = stdout,
stderr = stdout,
args = args,
...
)
})$
then(function(ret) {
parse_apk_output(strsplit(ret$stdout, "\n")[[1]])
})$
finally(function() unlink(stdout))
}

parse_apk_output <- function(lines) {

package = sub("-[0-9].*", "", lines)
version = sub(".*?-([0-9][^ ]*).*", "\\1", lines)
provides = ""

pkgs <- data_frame(
status = "ii",
package = package,
version = version,
provides = provides
)

pkgs <- pkgs[order(tolower(pkgs$package)), ]
pkgs
}

0 comments on commit 39803c9

Please sign in to comment.