jonkeane commented on code in PR #39587:
URL: https://github.com/apache/arrow/pull/39587#discussion_r1451771497


##########
r/tools/nixlibs.R:
##########
@@ -116,33 +105,56 @@ download_binary <- function(lib) {
   # validate binary checksum for CRAN release only
   if (!skip_checksum && dir.exists(checksum_path) && is_release ||
     enforce_checksum) {
+    # Munge the path to the correct sha file which we include during the
+    # release process
     checksum_file <- sub(".+/bin/(.+\\.zip)", "\\1\\.sha512", binary_url)
     checksum_file <- file.path(checksum_path, checksum_file)
-    checksum_cmd <- "shasum"
-    checksum_args <- c("--status", "-a", "512", "-c", checksum_file)
-
-    # shasum is not available on all linux versions
-    status_shasum <- try(
-      suppressWarnings(
-        system2("shasum", args = c("--help"), stdout = FALSE, stderr = FALSE)
-      ),
-      silent = TRUE
-    )
 
-    if (inherits(status_shasum, "try-error") || is.integer(status_shasum) && 
status_shasum != 0) {
+    # Check for `shasum`, and try `sha512sum` if not found
+    if (nzchar(Sys.which("shasum"))) {
+      checksum_cmd <- "shasum"
+      checksum_args <- c("--status", "-a", "512", "-c", checksum_file)
+    } else {
       checksum_cmd <- "sha512sum"
       checksum_args <- c("--status", "-c", checksum_file)
     }
 
-    checksum_ok <- system2(checksum_cmd, args = checksum_args)
+    checksum_ok <- system2(checksum_cmd, args = checksum_args) == 0

Review Comment:
   This now (and maybe it did before and I just didn't notice it) will produce 
output in the log from the command. See below when I'm enforcing checksumming 
on a non-release (with no checksum file):
   
   ```
   *** Latest available nightly for 14.0.2.9000: 14.0.2.100000424
   *** Found libcurl and OpenSSL >= 3.0.0
   shasum: 
tools/checksums/darwin-x86_64-openssl-3.0/arrow-14.0.2.100000424.zip.sha512: No 
such file or directory
   *** Checksum validation failed for libarrow
   *** Unable to retrieve libarrow for version 14.0.2.100000424 
(darwin-x86_64-openssl-3.0)
   *** Found local C++ source: 'tools/cpp'
   *** Building libarrow from source
   ```
   
   This is probably ok (and in fact @nealrichardson asked if this is what we 
wanted in another comment), but I wanted to confirm with everyone here this is 
the behavior + what we will get. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to