Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita9199a2

Browse files
committed
Improve sysreqs support detection
Cf.r-lib/pkgcache#121 (comment)
1 parentad37db2 commita9199a2

File tree

5 files changed

+121
-63
lines changed

5 files changed

+121
-63
lines changed

‎R/sysreqs.R‎

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,11 @@ parse_sysreqs_platform <- function(x) {
327327
stopifnot(length(x)==1)
328328

329329
# full form or only distro [+ version]
330-
if (sum(strsplit(x,"")[[1]]=="-")>=2) {
330+
if (
331+
sum(strsplit(x,"")[[1]]=="-")>=2&&
332+
!grepl("opensuse-leap",x)&&
333+
!grepl("opensuse-tumbleweed",x)
334+
) {
331335
osplt<- parse_platform(x)
332336
if (startsWith(osplt$os,"linux-")) {
333337
rest<- sub(
@@ -354,16 +358,25 @@ parse_sysreqs_platform <- function(x) {
354358
return(osplt)
355359
}
356360

357-
restpcs<- strsplit(rest,"-",fixed=TRUE)[[1]]
358-
if (length(restpcs)==1) {
359-
osplt$distribution<-restpcs
360-
}elseif (length(restpcs)==2) {
361-
osplt$distribution<-restpcs[1]
362-
osplt$version<-restpcs[2]
361+
if (grepl("^opensuse-leap-",rest)) {
362+
osplt$distribution<-"opensuse-leap"
363+
osplt$version<-sub("^opensuse-leap-","",rest)
364+
}elseif (grepl("^opensuse-tumbleweed-",rest)) {
365+
osplt$distribution<-"opensuse-tumbleweed"
366+
osplt$version<-sub("^opensuse-tumbleweed-","",rest)
363367
}else {
364-
osplt$distribution<-restpcs[1]
365-
osplt$version<- paste0(restpcs[-1],collapse="-")
368+
restpcs<- strsplit(rest,"-",fixed=TRUE)[[1]]
369+
if (length(restpcs)==1) {
370+
osplt$distribution<-restpcs
371+
}elseif (length(restpcs)==2) {
372+
osplt$distribution<-restpcs[1]
373+
osplt$version<-restpcs[2]
374+
}else {
375+
osplt$distribution<-restpcs[1]
376+
osplt$version<- paste0(restpcs[-1],collapse="-")
377+
}
366378
}
379+
367380
osplt
368381
}
369382

‎R/sysreqs2.R‎

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,26 @@ sysreqs2_cmds <- utils::read.table(
1212
header=TRUE,
1313
textConnection(
1414
"
15-
name os distribution version update_command install_command query_command
16-
'Ubuntu Linux' linux ubuntu * 'apt-get -y update' 'apt-get -y install' dpkg-query
17-
'Debian Linux' linux debian * 'apt-get -y update' 'apt-get -y install' dpkg-query
18-
'CentOS Linux' linux centos * NA 'yum install -y' rpm
19-
'Rocky Linux' linux rockylinux * NA 'dnf install -y' rpm
20-
'Red Hat Enterprise Linux' linux redhat 6 NA 'yum install -y' rpm
21-
'Red Hat Enterprise Linux' linux redhat 7 NA 'yum install -y' rpm
22-
'Red Hat Enterprise Linux' linux redhat * NA 'dnf install -y' rpm
23-
'Red Hat Enterprise Linux' linux rhel 7.0 NA 'yum install -y' rpm
24-
'Red Hat Enterprise Linux' linux rhel 7.1 NA 'yum install -y' rpm
25-
'Red Hat Enterprise Linux' linux rhel 7.2 NA 'yum install -y' rpm
26-
'Red Hat Enterprise Linux' linux rhel 7.3 NA 'yum install -y' rpm
27-
'Red Hat Enterprise Linux' linux rhel 7.4 NA 'yum install -y' rpm
28-
'Red Hat Enterprise Linux' linux rhel 7.5 NA 'yum install -y' rpm
29-
'Red Hat Enterprise Linux' linux rhel 7.6 NA 'yum install -y' rpm
30-
'Red Hat Enterprise Linux' linux rhel 7.7 NA 'yum install -y' rpm
31-
'Red Hat Enterprise Linux' linux rhel 7.8 NA 'yum install -y' rpm
32-
'Red Hat Enterprise Linux' linux rhel 7.9 NA 'yum install -y' rpm
33-
'Red Hat Enterprise Linux' linux rhel * NA 'dnf install -y' rpm
34-
'Fedora Linux' linux fedora * NA 'dnf install -y' rpm
35-
'openSUSE Linux' linux opensuse * NA 'zypper --non-interactive install' rpm
36-
'SUSE Linux Enterprise' linux sle * NA 'zypper --non-interactive install' rpm
37-
'Alpine Linux' linux alpine * NA 'apk add --no-cache' apk
15+
name os id distribution version version_match update_command install_command query_command
16+
'Ubuntu Linux' linux ubuntu ubuntu * NA 'apt-get -y update' 'apt-get -y install' dpkg-query
17+
'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 almalinux almalinux * NA NA 'dnf install -y' rpm
22+
'Red Hat Enterprise Linux' linux rhel redhat 6 major NA 'yum install -y' rpm
23+
'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
25+
'Red Hat Enterprise Linux' linux redhat redhat 6 major NA 'yum install -y' rpm
26+
'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
28+
'Fedora Linux' linux fedora fedora * NA NA 'dnf install -y' rpm
29+
'openSUSE Linux' linux opensuse opensuse * NA NA 'zypper --non-interactive install' rpm
30+
'openSUSE Linux' linux opensuse-leap opensuse * NA NA 'zypper --non-interactive install' rpm
31+
'openSUSE Linux' linux opensuse-tumbleweed opensuse * NA NA 'zypper --non-interactive install' rpm
32+
'SUSE Linux Enterprise' linux sles sle * NA NA 'zypper --non-interactive install' rpm
33+
'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
3835
"
3936
)
4037
)
@@ -43,10 +40,14 @@ find_sysreqs_platform <- function(sysreqs_platform = NULL) {
4340
sysreqs_platform<-sysreqs_platform %||%
4441
current_config()$get("sysreqs_platform")
4542
plt<- parse_sysreqs_platform(sysreqs_platform)
46-
idx<- which(
43+
plt$version_major<- sub("[.].*$","",plt$version)
44+
which(
4745
sysreqs2_cmds$os==plt$os&
48-
sysreqs2_cmds$distribution==plt$distribution&
49-
sysreqs2_cmds$version%in% c("*",plt$version)
46+
sysreqs2_cmds$id==plt$distribution&
47+
(sysreqs2_cmds$version%in%
48+
c("*",plt$version)|
49+
sysreqs2_cmds$version_match=="major"&
50+
sysreqs2_cmds$version==plt$version_major)
5051
)[1]
5152
}
5253

‎tests/testthat/_snaps/sysreqs.md‎

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,28 @@
33
Code
44
print(sysreqs_platforms(), n = Inf)
55
Output
6-
# A data frame: 22 x 7
7-
name os distribution version update_command install_command query_command
8-
<chr> <chr> <chr> <chr> <chr> <chr> <chr>
9-
1 Ubun~ linux ubuntu * apt-get -y up~ apt-get -y ins~ dpkg-query
10-
2 Debi~ linux debian * apt-get -y up~ apt-get -y ins~ dpkg-query
11-
3 Cent~ linux centos * <NA> yum install -y rpm
12-
4 Rock~ linux rockylinux * <NA> dnf install -y rpm
13-
5 Red ~ linux redhat 6 <NA> yum install -y rpm
14-
6 Red ~ linux redhat 7 <NA> yum install -y rpm
15-
7 Red ~ linux redhat * <NA> dnf install -y rpm
16-
8 Red ~ linux rhel 7.0 <NA> yum install -y rpm
17-
9 Red ~ linux rhel 7.1 <NA> yum install -y rpm
18-
10 Red ~ linux rhel 7.2 <NA> yum install -y rpm
19-
11 Red ~ linux rhel 7.3 <NA> yum install -y rpm
20-
12 Red ~ linux rhel 7.4 <NA> yum install -y rpm
21-
13 Red ~ linux rhel 7.5 <NA> yum install -y rpm
22-
14 Red ~ linux rhel 7.6 <NA> yum install -y rpm
23-
15 Red ~ linux rhel 7.7 <NA> yum install -y rpm
24-
16 Red ~ linux rhel 7.8 <NA> yum install -y rpm
25-
17 Red ~ linux rhel 7.9 <NA> yum install -y rpm
26-
18 Red ~ linux rhel * <NA> dnf install -y rpm
27-
19 Fedo~ linux fedora * <NA> dnf install -y rpm
28-
20 open~ linux opensuse * <NA> zypper --non-i~ rpm
29-
21 SUSE~ linux sle * <NA> zypper --non-i~ rpm
30-
22 Alpi~ linux alpine * <NA> apk add --no-c~ apk
6+
# A data frame: 19 x 9
7+
name os id distribution version version_match update_command install_command query_command
8+
<chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
9+
1 Ubuntu Linux linux ubuntu ubuntu * <NA> apt-get -y update apt-get -y install dpkg-query
10+
2 Debian Linux linux debian debian * <NA> apt-get -y update apt-get -y install dpkg-query
11+
3 CentOS Linux linux centos centos * <NA> <NA> yum install -y rpm
12+
4 Rocky Linux linux rocky rockylinux * <NA> <NA> dnf install -y rpm
13+
5 Rocky Linux linux rockylinux rockylinux * <NA> <NA> dnf install -y rpm
14+
6 AlmaLinux linux almalinux almalinux * <NA> <NA> dnf install -y rpm
15+
7 Red Hat Enterprise Linux linux rhel redhat 6 major <NA> yum install -y rpm
16+
8 Red Hat Enterprise Linux linux rhel redhat 7 major <NA> yum install -y rpm
17+
9 Red Hat Enterprise Linux linux rhel redhat * <NA> <NA> dnf install -y rpm
18+
10 Red Hat Enterprise Linux linux redhat redhat 6 major <NA> yum install -y rpm
19+
11 Red Hat Enterprise Linux linux redhat redhat 7 major <NA> yum install -y rpm
20+
12 Red Hat Enterprise Linux linux redhat redhat * <NA> <NA> dnf install -y rpm
21+
13 Fedora Linux linux fedora fedora * <NA> <NA> dnf install -y rpm
22+
14 openSUSE Linux linux opensuse opensuse * <NA> <NA> zypper --non-interactive install rpm
23+
15 openSUSE Linux linux opensuse-leap opensuse * <NA> <NA> zypper --non-interactive install rpm
24+
16 openSUSE Linux linux opensuse-tumbleweed opensuse * <NA> <NA> zypper --non-interactive install rpm
25+
17 SUSE Linux Enterprise linux sles sle * <NA> <NA> zypper --non-interactive install rpm
26+
18 SUSE Linux Enterprise linux sle sle * <NA> <NA> zypper --non-interactive install rpm
27+
19 Alpine Linux linux alpine alpine * <NA> <NA> apk add --no-cache apk
3128

3229
#sysreqs_db_list
3330

‎tests/testthat/test-sysreqs.R‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
test_that("sysreqs_platforms", {
2+
withr::local_options(width=200)
23
expect_snapshot(print(sysreqs_platforms(),n=Inf))
34
})
45

‎tests/testthat/test-sysreqs2.R‎

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,57 @@
11
test_that("sysreqs_is_supported", {
2+
expect_true(sysreqs_is_supported("ubuntu-20.04"))
23
expect_true(sysreqs_is_supported("ubuntu-22.04"))
4+
expect_true(sysreqs_is_supported("ubuntu-24.04"))
5+
6+
expect_true(sysreqs_is_supported("debian-11"))
7+
expect_true(sysreqs_is_supported("debian-12"))
38
expect_true(sysreqs_is_supported("debian-unstable"))
9+
10+
expect_true(sysreqs_is_supported("opensuse-15.4"))
11+
expect_true(sysreqs_is_supported("opensuse-15.5"))
12+
expect_true(sysreqs_is_supported("opensuse-15.6"))
13+
expect_true(sysreqs_is_supported("opensuse-leap-15.4"))
14+
expect_true(sysreqs_is_supported("opensuse-leap-15.5"))
15+
expect_true(sysreqs_is_supported("opensuse-leap-15.6"))
16+
expect_true(sysreqs_is_supported("opensuse-tumbleweed-20250509"))
17+
18+
expect_true(sysreqs_is_supported("centos-6"))
19+
expect_true(sysreqs_is_supported("centos-7"))
420
expect_true(sysreqs_is_supported("centos-8"))
5-
expect_true(sysreqs_is_supported("rockylinux-9"))
21+
22+
expect_true(sysreqs_is_supported("rhel-7"))
23+
expect_true(sysreqs_is_supported("rhel-7.9"))
24+
expect_true(sysreqs_is_supported("rhel-8"))
25+
expect_true(sysreqs_is_supported("rhel-8.10"))
26+
expect_true(sysreqs_is_supported("rhel-9"))
27+
expect_true(sysreqs_is_supported("rhel-9.6"))
28+
29+
expect_true(sysreqs_is_supported("fedora-39"))
30+
expect_true(sysreqs_is_supported("fedora-40"))
31+
expect_true(sysreqs_is_supported("fedora-41"))
32+
expect_true(sysreqs_is_supported("fedora-42"))
33+
expect_true(sysreqs_is_supported("fedora-43"))
34+
35+
expect_true(sysreqs_is_supported("sles-15.4"))
36+
expect_true(sysreqs_is_supported("sles-15.5"))
37+
expect_true(sysreqs_is_supported("sles-15.6"))
38+
39+
expect_true(sysreqs_is_supported("almalinux-8.10"))
40+
expect_true(sysreqs_is_supported("almalinux-9.6"))
41+
42+
expect_true(sysreqs_is_supported("rocky-8.9"))
43+
expect_true(sysreqs_is_supported("rocky-9.3"))
44+
45+
expect_true(sysreqs_is_supported("alpine-3.19"))
46+
expect_true(sysreqs_is_supported("alpine-3.20"))
47+
expect_true(sysreqs_is_supported("alpine-3.21"))
48+
expect_true(sysreqs_is_supported("alpine-edge"))
49+
50+
# these should not happen, these are the PPM names
651
expect_true(sysreqs_is_supported("redhat-8"))
7-
expect_true(sysreqs_is_supported("opensuse-15.4"))
8-
expect_true(sysreqs_is_supported("sle-15.4"))
52+
expect_true(sysreqs_is_supported("redhat-8.10"))
53+
expect_true(sysreqs_is_supported("rockylinux-8"))
54+
expect_true(sysreqs_is_supported("rockylinux-8.9"))
955

1056
expect_false(sysreqs_is_supported("foo-bar"))
1157
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp