Skip to content

Commit 519053e

Browse files
committed
fix arm64 to aarch64
1 parent aa6503c commit 519053e

File tree

2 files changed

+57
-21
lines changed

2 files changed

+57
-21
lines changed

R/java_install.R

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#'
33
#' @description
44
#' Unpack Java distribution file into cache directory and link the installation into a project directory, optionally setting the `JAVA_HOME` and `PATH` environment variables to the Java version that was just installed.
5-
#'
5+
#'
66
#' @param java_distrib_path A `character` vector of length 1 containing the path to the Java distribution file.
77
#' @param project_path A `character` vector of length 1 containing the project directory where Java should be installed. If not specified or `NULL`, defaults to the current working directory.
88
#' @param autoset_java_env A `logical` indicating whether to set the `JAVA_HOME` and `PATH` environment variables to the installed Java directory. Defaults to `TRUE`.
@@ -13,7 +13,7 @@
1313
#'
1414
#' @examples
1515
#' \dontrun{
16-
#'
16+
#'
1717
#' # set cache dir to temporary directory
1818
#' options(rJavaEnv.cache_path = tempdir())
1919
#' # download, install and autoset environmnet variables for Java 17
@@ -47,12 +47,20 @@ java_install <- function(
4747
parts <- strsplit(gsub("\\.tar\\.gz|\\.zip", "", filename), "-")[[1]]
4848

4949
# Guess the version, architecture, and platform
50-
version <- parts[vapply(parts, function(x) x %in% java_versions, logical(1))][1]
50+
version <- parts[vapply(parts, function(x) x %in% java_versions, logical(1))][
51+
1
52+
]
5153
arch <- parts[vapply(parts, function(x) x %in% architectures, logical(1))][1]
5254
platform <- parts[vapply(parts, function(x) x %in% platforms, logical(1))][1]
5355

5456
# Create a symlink in the project directory
55-
project_version_path <- file.path(project_path, "rjavaenv", platform, arch, version)
57+
project_version_path <- file.path(
58+
project_path,
59+
"rjavaenv",
60+
platform,
61+
arch,
62+
version
63+
)
5664
if (!dir.exists(dirname(project_version_path))) {
5765
dir.create(dirname(project_version_path), recursive = TRUE)
5866
}
@@ -61,10 +69,14 @@ java_install <- function(
6169
if (.Platform$OS.type == "windows") {
6270
try(
6371
{
64-
if( file.exists(project_version_path) ){
72+
if (file.exists(project_version_path)) {
6573
unlink(project_version_path, recursive = TRUE)
6674
}
67-
cmd <- sprintf("mklink /J \"%s\" \"%s\"", gsub("/", "\\\\", project_version_path), gsub("/", "\\\\", installed_path))
75+
cmd <- sprintf(
76+
"mklink /J \"%s\" \"%s\"",
77+
gsub("/", "\\\\", project_version_path),
78+
gsub("/", "\\\\", installed_path)
79+
)
6880
result <- tryCatch(
6981
system2("cmd.exe", args = c("/c", cmd), stdout = TRUE, stderr = TRUE),
7082
warning = function(w) {
@@ -83,15 +95,24 @@ java_install <- function(
8395
silent = TRUE
8496
)
8597
if (!link_success) {
86-
if (!quiet) cli::cli_inform("Junction creation failed. This is likely because the project directory is not on the same disk as the R package cache directory. Java files will instead be copied to {.path {project_version_path}}")
98+
if (!quiet)
99+
cli::cli_inform(
100+
"Junction creation failed. This is likely because the project directory is not on the same disk as the R package cache directory. Java files will instead be copied to {.path {project_version_path}}"
101+
)
87102
dir.create(project_version_path, recursive = TRUE)
88-
file.copy(installed_path, project_version_path, recursive = TRUE, overwrite = TRUE)
89-
if (!quiet) cli::cli_inform("Java copied to project {.path {project_version_path}}")
103+
file.copy(
104+
installed_path,
105+
project_version_path,
106+
recursive = TRUE,
107+
overwrite = TRUE
108+
)
109+
if (!quiet)
110+
cli::cli_inform("Java copied to project {.path {project_version_path}}")
90111
}
91112
} else {
92113
tryCatch(
93114
{
94-
if( file.exists(project_version_path) ){
115+
if (file.exists(project_version_path)) {
95116
unlink(project_version_path, recursive = TRUE)
96117
}
97118
file.symlink(installed_path, project_version_path)
@@ -102,19 +123,34 @@ java_install <- function(
102123
error = function(e) {
103124
if (!quiet) cli::cli_inform("Error: {e}")
104125
dir.create(project_version_path, recursive = TRUE)
105-
file.copy(installed_path, project_version_path, recursive = TRUE, overwrite = TRUE)
106-
if (!quiet) cli::cli_inform("Symlink creation failed. Files copied to {.path {project_version_path}}")
126+
file.copy(
127+
installed_path,
128+
project_version_path,
129+
recursive = TRUE,
130+
overwrite = TRUE
131+
)
132+
if (!quiet)
133+
cli::cli_inform(
134+
"Symlink creation failed. Files copied to {.path {project_version_path}}"
135+
)
107136
}
108137
)
109138
}
110139

111-
112-
113140
# Write the JAVA_HOME to the .Rprofile and environment after installation
114141
if (autoset_java_env) {
115-
java_env_set(installed_path, where = "both", quiet = quiet, project_path = project_path)
142+
java_env_set(
143+
installed_path,
144+
where = "both",
145+
quiet = quiet,
146+
project_path = project_path
147+
)
116148
}
117149

118-
if (!quiet) cli::cli_inform("Java {version} ({filename}) for {platform} {arch} installed at {.path {installed_path}} and symlinked to {.path {project_version_path}}", .envir = environment())
150+
if (!quiet)
151+
cli::cli_inform(
152+
"Java {version} ({filename}) for {platform} {arch} installed at {.path {installed_path}} and symlinked to {.path {project_version_path}}",
153+
.envir = environment()
154+
)
119155
return(installed_path)
120156
}

inst/extdata/java_urls.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@
55
},
66
"linux": {
77
"x64": "https://corretto.aws/downloads/latest/amazon-corretto-{version}-x64-linux-jdk.tar.gz",
8-
"arm64": "https://corretto.aws/downloads/latest/amazon-corretto-{version}-aarch64-linux-jdk.tar.gz"
8+
"aarch64": "https://corretto.aws/downloads/latest/amazon-corretto-{version}-aarch64-linux-jdk.tar.gz"
99
},
1010
"macos": {
1111
"x64": "https://corretto.aws/downloads/latest/amazon-corretto-{version}-x64-macos-jdk.tar.gz",
12-
"arm64": "https://corretto.aws/downloads/latest/amazon-corretto-{version}-aarch64-macos-jdk.tar.gz"
12+
"aarch64": "https://corretto.aws/downloads/latest/amazon-corretto-{version}-aarch64-macos-jdk.tar.gz"
1313
},
1414
"alpine-linux": {
1515
"x64": "https://corretto.aws/downloads/latest/amazon-corretto-{version}-x64-alpine-jdk.tar.gz",
16-
"arm64": "https://corretto.aws/downloads/latest/amazon-corretto-{version}-aarch64-alpine-jdk.tar.gz"
16+
"aarch64": "https://corretto.aws/downloads/latest/amazon-corretto-{version}-aarch64-alpine-jdk.tar.gz"
1717
},
1818
"amazon-linux": {
1919
"x64": "https://corretto.aws/downloads/latest/amazon-corretto-{version}-x64-al2-jdk.rpm",
20-
"arm64": "https://corretto.aws/downloads/latest/amazon-corretto-{version}-aarch64-al2-jdk.rpm"
20+
"aarch64": "https://corretto.aws/downloads/latest/amazon-corretto-{version}-aarch64-al2-jdk.rpm"
2121
},
2222
"amazon-linux-2023": {
2323
"x64": "https://corretto.aws/downloads/latest/amazon-corretto-{version}-x64-al2023-jdk.rpm",
24-
"arm64": "https://corretto.aws/downloads/latest/amazon-corretto-{version}-aarch64-al2023-jdk.rpm"
24+
"aarch64": "https://corretto.aws/downloads/latest/amazon-corretto-{version}-aarch64-al2023-jdk.rpm"
2525
}
2626
}
2727
}

0 commit comments

Comments
 (0)