mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-27 15:37:02 +00:00
fix: add cross-platform SHA256 checksum generation (#202)
- Add generate_sha256() function to handle cross-platform SHA256 generation - Use shasum -a 256 on macOS instead of sha256sum - Use sha256sum on Linux with shasum as fallback - Replace direct sha256sum usage in build script with new function - Fixes 'sha256sum: command not found' error on macOS builds
This commit is contained in:
+42
-1
@@ -53,6 +53,47 @@ detect_platform() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Cross-platform SHA256 checksum generation
|
||||||
|
generate_sha256() {
|
||||||
|
local file="$1"
|
||||||
|
local output_file="$2"
|
||||||
|
local os=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
|
case "$os" in
|
||||||
|
"linux")
|
||||||
|
if command -v sha256sum &> /dev/null; then
|
||||||
|
sha256sum "$file" > "$output_file"
|
||||||
|
elif command -v shasum &> /dev/null; then
|
||||||
|
shasum -a 256 "$file" > "$output_file"
|
||||||
|
else
|
||||||
|
print_message $RED "❌ No SHA256 command found (sha256sum or shasum)"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
"darwin")
|
||||||
|
if command -v shasum &> /dev/null; then
|
||||||
|
shasum -a 256 "$file" > "$output_file"
|
||||||
|
elif command -v sha256sum &> /dev/null; then
|
||||||
|
sha256sum "$file" > "$output_file"
|
||||||
|
else
|
||||||
|
print_message $RED "❌ No SHA256 command found (shasum or sha256sum)"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# Try common commands in order
|
||||||
|
if command -v sha256sum &> /dev/null; then
|
||||||
|
sha256sum "$file" > "$output_file"
|
||||||
|
elif command -v shasum &> /dev/null; then
|
||||||
|
shasum -a 256 "$file" > "$output_file"
|
||||||
|
else
|
||||||
|
print_message $RED "❌ No SHA256 command found"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
# Default values
|
# Default values
|
||||||
OUTPUT_DIR="target/release"
|
OUTPUT_DIR="target/release"
|
||||||
PLATFORM=$(detect_platform) # Auto-detect current platform
|
PLATFORM=$(detect_platform) # Auto-detect current platform
|
||||||
@@ -358,7 +399,7 @@ build_binary() {
|
|||||||
|
|
||||||
# Generate checksums
|
# Generate checksums
|
||||||
print_message $BLUE "🔐 Generating checksums..."
|
print_message $BLUE "🔐 Generating checksums..."
|
||||||
(cd "${OUTPUT_DIR}/${PLATFORM}" && sha256sum "${BINARY_NAME}" > "${BINARY_NAME}.sha256sum")
|
(cd "${OUTPUT_DIR}/${PLATFORM}" && generate_sha256 "${BINARY_NAME}" "${BINARY_NAME}.sha256sum")
|
||||||
|
|
||||||
# Verify binary functionality (if not skipped)
|
# Verify binary functionality (if not skipped)
|
||||||
if [ "$SKIP_VERIFICATION" = false ]; then
|
if [ "$SKIP_VERIFICATION" = false ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user