assignUser commented on code in PR #38115:
URL: https://github.com/apache/arrow/pull/38115#discussion_r1355152051


##########
r/tools/nixlibs.R:
##########
@@ -103,6 +104,42 @@ download_binary <- function(lib) {
     }
     libfile <- NULL
   }
+  # Explicitly setting the env var to "false" will skip checksum validation
+  # e.g. in case the included checksums are stale.
+  skip_checksum <- env_is("ARROW_R_ENFORCE_CHECKSUM", "false")
+  enforce_checksum <- env_is("ARROW_R_ENFORCE_CHECKSUM", "true")
+  # validate binary checksum for CRAN release only
+  if (!skip_checksum && dir.exists(checksum_path) && is_release ||
+    enforce_checksum) {
+    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) {
+      checksum_cmd <- "sha512sum"
+      checksum_args <- c("--status", "-c", checksum_file)
+    }
+
+    checksum_ok <- system2(checksum_cmd, args = checksum_args)

Review Comment:
   I didn't want to add the openssl package as a dependency hard dependency 
(suggests would work due to potential checks without suggests causing the 
windows build to fail?)
   
   We could add openssl as the first candidate and fall back to the other 
commands if needed? That should cover both nix and windows use case? (or would 
openssl be available via rtools aswell?)



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to