Copilot commented on code in PR #13669:
URL: https://github.com/apache/gluten/pull/13669#discussion_r4646541745
##########
build/mvn:
##########
@@ -27,6 +27,54 @@ MVN_DOWNLOAD_DIR="${DOWNLOAD_DIR}/.mvn"
# Global variable for Maven binary path
MVN_BIN=""
+download_mvn() {
+ local URL="$1" DESTINATION="$2"
+ if command -v curl > /dev/null 2>&1; then
+ if curl -f -L --retry 3 --retry-delay 3 \
+ --connect-timeout 30 --max-time 600 \
+ -o "$DESTINATION" "$URL"; then
+ return 0
+ fi
+ elif command -v wget > /dev/null 2>&1; then
+ if wget --tries=3 --waitretry=3 \
+ --connect-timeout=30 --read-timeout=600 \
+ -O "$DESTINATION" "$URL"; then
+ return 0
+ fi
+ else
+ echo "ERROR: Neither curl nor wget found. Please install one of them
or install Maven manually." >&2
+ return 1
+ fi
+
+ echo "ERROR: Failed to download Maven from ${URL}" >&2
+ rm -f "$DESTINATION"
+ return 1
+}
+
+verify_mvn() {
+ local ARCHIVE="$1" CHECKSUM_FILE="$2" CHECKSUM
+ local SHA512
+ if command -v sha512sum > /dev/null 2>&1; then
+ SHA512=(sha512sum)
+ elif command -v shasum > /dev/null 2>&1; then
+ SHA512=(shasum -a 512)
+ else
+ echo "ERROR: Neither sha512sum nor shasum found. Install one to verify
the Maven distribution." >&2
+ return 1
+ fi
+
+ # Apache publishes a bare SHA-512 digest, not a checksum-tool manifest.
+ if ! CHECKSUM=$(tr -d '[:space:]' < "$CHECKSUM_FILE") ||
+ ! [[ "$CHECKSUM" =~ ^[0-9a-fA-F]{128}$ ]]; then
+ echo "ERROR: Invalid SHA-512 checksum in ${CHECKSUM_FILE}" >&2
+ return 1
+ fi
+ if ! printf '%s %s\n' "$CHECKSUM" "$ARCHIVE" | "${SHA512[@]}" -c - >&2;
then
Review Comment:
Passing the absolute archive path as an unescaped checksum-manifest entry
breaks bootstrapping when the checkout directory contains a backslash. For
example, a valid archive under a literal `checkout\name` directory fails
verification because `sha512sum -c` interprets `\n` in the path as a newline;
the wrapper then deletes the archive and exits. Verify from the archive
directory using its fixed basename, or hash the archive through standard input,
so valid checkout paths do not change checksum parsing.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]