Copilot commented on code in PR #55492:
URL: https://github.com/apache/arrow/pull/55492#discussion_r4538308727
##########
r/tools/nixlibs.R:
##########
@@ -902,9 +970,68 @@ with_vendored_dependencies <- function(env_var_list) {
}
next
}
- env_var_list <- replace(env_var_list, env_varname, normalizePath(tarball))
+ checksum_varname <- sub("_URL$", "_BUILD_SHA256_CHECKSUM", env_varname)
+ entry <- manifest[manifest$filename == filename, , drop = FALSE]
+ # versions.txt has the vendored checksum if use_vendored_checksums() has
+ # already run on it (e.g. when installing from the r/ directory again)
+ matches <- nrow(entry) == 1 &&
+ unname(expected[checksum_varname]) %in% c(entry$upstream_sha256,
entry$vendored_sha256)
+ if (!matches) {
+ if (!quietly) {
+ lg(
+ "Vendored source for %s doesn't match %s, it will be downloaded if
needed",
+ env_varname,
+ file.path(src_dir, "thirdparty", "versions.txt"),
+ .indent = "****"
+ )
+ }
+ next
+ }
+ usable[[env_varname]] <- normalizePath(tarball)
}
- env_var_list
+ usable
+}
+
+# Read the checksums.txt that tools/vendor_dependencies.sh writes, with the
+# checksums of each vendored tarball before (upstream) and after trimming
+read_vendored_checksums <- function() {
+ manifest_file <- file.path(vendored_dependency_dir, "checksums.txt")
+ if (!file.exists(manifest_file)) {
+ return(NULL)
+ }
+ read.table(manifest_file, header = TRUE, stringsAsFactors = FALSE)
+}
+
+# The libarrow build checks the checksums of the thirdparty tarballs against
+# src_dir's versions.txt, so replace the upstream checksums of the vendored
+# tarballs that `env_var_list` points at with the trimmed tarballs' checksums.
+use_vendored_checksums <- function(src_dir, env_var_list, vendored) {
+ used <- vendored[vapply(
+ names(vendored),
+ function(env_varname) identical(env_var_list[[env_varname]],
vendored[[env_varname]]),
+ logical(1)
+ )]
+ if (length(used) == 0) {
+ return(invisible())
+ }
+ manifest <- read_vendored_checksums()
+ versions_txt <- file.path(src_dir, "thirdparty", "versions.txt")
+ lines <- readLines(versions_txt)
+ for (env_varname in names(used)) {
+ checksum_varname <- sub("_URL$", "_BUILD_SHA256_CHECKSUM", env_varname)
+ checksum <- manifest$vendored_sha256[manifest$filename ==
basename(used[[env_varname]])]
+ lines <- sub(paste0("^", checksum_varname, "=.*$"),
paste0(checksum_varname, "=", checksum), lines)
+ }
+ writeLines(lines, versions_txt)
Review Comment:
This permanently overwrites the source checksums, while subsequent calls
only update dependencies currently selected from `vendored`. Reinstalling from
the same source directory with `ARROW_URIPARSER_URL` or
`ARROW_THIRDPARTY_DEPENDENCY_DIR` pointing at an upstream archive therefore
leaves its previous trimmed checksum in place, and CMake rejects the valid
upstream archive. Restore the original checksums after the build, or reset
entries no longer using vendored archives to their upstream checksums.
--
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]