@@ -15,42 +15,77 @@ sysreqs2_cmds <- utils::read.table(
1515 name os id distribution version version_match update_command install_command query_command
1616 'Ubuntu Linux' linux ubuntu ubuntu * NA 'apt-get -y update' 'apt-get -y install' dpkg-query
1717 'Debian Linux' linux debian debian * NA 'apt-get -y update' 'apt-get -y install' dpkg-query
18- 'CentOS Linux' linux centos centos *NA NA 'yum install -y' rpm
19- 'Rocky Linux' linux rocky rockylinux *NA NA 'dnf install -y' rpm
20- 'Rocky Linux' linux rockylinux rockylinux *NA NA 'dnf install -y' rpm
21- 'AlmaLinux' linux almalinuxalmalinux *NA NA 'dnf install -y' rpm
18+ 'CentOS Linux' linux centos centos *major NA 'yum install -y' rpm
19+ 'Rocky Linux' linux rocky rockylinux *major NA 'dnf install -y' rpm
20+ 'Rocky Linux' linux rockylinux rockylinux *major NA 'dnf install -y' rpm
21+ 'AlmaLinux' linux almalinuxrockylinux *major NA 'dnf install -y' rpm
2222 'Red Hat Enterprise Linux' linux rhel redhat 6 major NA 'yum install -y' rpm
2323 'Red Hat Enterprise Linux' linux rhel redhat 7 major NA 'yum install -y' rpm
24- 'Red Hat Enterprise Linux' linux rhel redhat *NA NA 'dnf install -y' rpm
24+ 'Red Hat Enterprise Linux' linux rhel redhat *major NA 'dnf install -y' rpm
2525 'Red Hat Enterprise Linux' linux redhat redhat 6 major NA 'yum install -y' rpm
2626 'Red Hat Enterprise Linux' linux redhat redhat 7 major NA 'yum install -y' rpm
27- 'Red Hat Enterprise Linux' linux redhat redhat *NA NA 'dnf install -y' rpm
27+ 'Red Hat Enterprise Linux' linux redhat redhat *major NA 'dnf install -y' rpm
2828 'Fedora Linux' linux fedora fedora * NA NA 'dnf install -y' rpm
2929 'openSUSE Linux' linux opensuse opensuse * NA NA 'zypper --non-interactive install' rpm
3030 'openSUSE Linux' linux opensuse-leap opensuse * NA NA 'zypper --non-interactive install' rpm
3131 'openSUSE Linux' linux opensuse-tumbleweed opensuse * NA NA 'zypper --non-interactive install' rpm
3232 'SUSE Linux Enterprise' linux sles sle * NA NA 'zypper --non-interactive install' rpm
3333 'SUSE Linux Enterprise' linux sle sle * NA NA 'zypper --non-interactive install' rpm
34- 'Alpine Linux' linux alpine alpine *NA NA 'apk add --no-cache' apk
34+ 'Alpine Linux' linux alpine alpine *minor NA 'apk add --no-cache' apk
3535"
3636 )
3737)
3838
39- find_sysreqs_platform <- function (sysreqs_platform = NULL ) {
40- sysreqs_platform <- sysreqs_platform %|| %
41- current_config()$ get(" sysreqs_platform" )
42- plt <- parse_sysreqs_platform(sysreqs_platform )
43- plt $ version_major <- sub(" [.].*$" ," " ,plt $ version )
39+ # do not use package_version, in case the distro is nor semver
40+ get_major_version <- function (x ) {
41+ sub(" [.].*$" ," " ,x )
42+ }
43+ get_minor_version <- function (x ) {
44+ sub(" ([.][^.]+)[.].*$" ," \\ 1" ,x )
45+ }
46+
47+ find_sysreqs_platform <- function (sysreqs_platform = NULL ,parsed = NULL ) {
48+ plt <- parsed %|| %
49+ parse_sysreqs_platform(
50+ sysreqs_platform %|| % current_config()$ get(" sysreqs_platform" )
51+ )
52+ plt $ version_major <- get_major_version(plt $ version )
53+ plt $ version_minor <- get_minor_version(plt $ version )
4454 which(
4555sysreqs2_cmds $ os == plt $ os &
4656sysreqs2_cmds $ id == plt $ distribution &
4757 (sysreqs2_cmds $ version %in%
4858 c(" *" ,plt $ version )|
49- sysreqs2_cmds $ version_match == " major" &
50- sysreqs2_cmds $ version == plt $ version_major )
59+ (sysreqs2_cmds $ version_match == " major" &
60+ sysreqs2_cmds $ version == plt $ version_major )|
61+ (sysreqs2_cmds $ version_match == " minor" &
62+ sysreqs2_cmds $ version == plt $ version_minor ))
5163 )[1 ]
5264}
5365
66+ canonize_sysreqs_platform <- function (sysreqs_platform ) {
67+ parsed <- parse_sysreqs_platform(sysreqs_platform )
68+ known <- find_sysreqs_platform(parsed = parsed )
69+ if (is.na(known )) {
70+ sysreqs_platform
71+ }else {
72+ plt <- sysreqs_platforms()[known , ]
73+ paste0(
74+ plt $ distribution ,
75+ " -" ,
76+ if (plt $ version != " *" ) {
77+ plt $ version
78+ }else if (identical(plt $ version_match ," major" )) {
79+ get_major_version(parsed $ version )
80+ }else if (identical(plt $ version_match ," minor" )) {
81+ get_minor_version(parsed $ version )
82+ }else {
83+ parsed $ version
84+ }
85+ )
86+ }
87+ }
88+
5489sysreqs2_command <- function (
5590sysreqs_platform = NULL ,
5691cmd = c(" install_command" ," update_command" ," query_command" )
@@ -99,6 +134,7 @@ sysreqs2_async_resolve <- function(sysreqs, sysreqs_platform, config, ...) {
99134}
100135
101136sysreqs2_scripts <- function (recs ,sysreqs_platform ,missing = FALSE ) {
137+ sysreqs_platform <- canonize_sysreqs_platform(sysreqs_platform )
102138plt <- parse_sysreqs_platform(sysreqs_platform )
103139flatrecs <- unlist(recs ,recursive = FALSE )
104140upd <- sysreqs2_command(sysreqs_platform ," update" )
@@ -239,9 +275,9 @@ sysreqs2_match <- function(
239275todo <- ! is.na(sysreqs )& sysreqs != " "
240276
241277config <- config %|| % current_config()
242- plt <- parse_sysreqs_platform(
278+ plt <- parse_sysreqs_platform(canonize_sysreqs_platform(
243279sysreqs_platform %|| %config $ get(" sysreqs_platform" )
244- )
280+ ))
245281
246282rsysreqs <- sysreqs [todo ]
247283for (r in rules ) {