Skip to content

Commit

Permalink
MINOR: [R] Make update-checksums.R work on macOS out of the box (#45617)
Browse files Browse the repository at this point in the history
### Rationale for this change

For R release managers on macOS, the update-checksums.R script we use doesn't run because the sed command we use in that script only works on GNU sed and not BSD sed.

### What changes are included in this PR?

- Makes update-checksum-R work on macOS by assuming the user has gsed available from Homebrew and using that always

### Are these changes tested?

Yes

### Are there any user-facing changes?

No.

Authored-by: Bryce Mecum <[email protected]>
Signed-off-by: Bryce Mecum <[email protected]>
  • Loading branch information
amoeba authored Feb 24, 2025
1 parent a01a812 commit bcda71d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion r/tools/update-checksums.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ args <- commandArgs(TRUE)
VERSION <- args[1]
tools_root <- ""

# Use gsed on macOS and sed otherwise
if (identical(unname(Sys.info()["sysname"]), "Darwin")) {
SED_BIN <- "gsed"
} else {
SED_BIN <- "sed"
}

if (length(args) != 1) {
stop("Usage: Rscript tools/update-checksums.R <version>")
}
Expand Down Expand Up @@ -62,7 +69,7 @@ for (path in binary_paths) {
if (grepl("windows", path)) {
cat(paste0("Converting ", path, " to windows style line endings\n"))
# UNIX style line endings cause errors with mysys2 sha512sum
sed_status <- system2("sed", args = c("-i", "s/\\\\r//", file))
sed_status <- system2(SED_BIN, args = c("-i", "s/\\\\r//", file))
if (sed_status != 0) {
stop("Failed to remove \\r from windows checksum file. Exit code: ", sed_status)
}
Expand Down

0 comments on commit bcda71d

Please sign in to comment.