diff --git a/tooling/ReproducibleBuilds.MD b/tooling/ReproducibleBuilds.MD old mode 100644 new mode 100755 index bf930e86d..ad565403d --- a/tooling/ReproducibleBuilds.MD +++ b/tooling/ReproducibleBuilds.MD @@ -54,10 +54,10 @@ The patching process involves: #### Tooling setup: -1. The comparable patch tools, tooling/src/c/WindowsUpdateVsVersionInfo.c and src/java/temurin/tools/BinRepl.java need compiling +1. The comparable patch tools, (Windows only)tooling/src/c/WindowsUpdateVsVersionInfo.c and src/java/temurin/tools/BinRepl.java need compiling before the comparable_patch.sh can be run -2. Compile tooling/src/c/WindowsUpdateVsVersionInfo.c : +2. Compile tooling/src/c/WindowsUpdateVsVersionInfo.c (Windows only): - Ensure VS2022 SDK is installed and on PATH - Compile: @@ -70,12 +70,12 @@ before the comparable_patch.sh can be run - cd tooling/src/java - javac temurin/tools/BinRepl.java -4. Setting environment within a CYGWIN shell : +4. Setting environment within a shell : +- [Windows only] For WindowsUpdateVsVersionInfo.exe : export PATH=/tooling/src/c:$PATH +- [Windows only] For dumpbin.exe MSVC tool : export PATH=/cygdrive/c/progra\~1/micros\~2/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64:$PATH - For BinRepl : export CLASSPATH=/tooling/src/java:$CLASSPATH -- For WindowsUpdateVsVersionInfo.exe : export PATH=/tooling/src/c:$PATH -- For dumpbin.exe MSVC tool : export PATH=/cygdrive/c/progra\~1/micros\~2/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64:$PATH -- For running BinRepl java : export PATH=/bin:$PATH +- A JDK for running BinRepl java : export PATH=/bin:$PATH #### Running comparable_patch.sh: @@ -84,7 +84,7 @@ before the comparable_patch.sh can be run 2. Run comparable_patch.sh ```bash -bash comparable_patch.sh +bash comparable_patch.sh --jdk-dir "" --version-string "" --vendor-name "" --vendor_url "" --vendor-bug-url "" --vendor-vm-bug-url "" [--patch-vs-version-info] ``` The Vendor strings and urls can be found by running your jdk's "java -XshowSettings": @@ -102,7 +102,7 @@ java -XshowSettings: eg. ```bash -bash comparable_patch.sh jdk1/jdk-21.0.1+12 "Temurin-21.0.1+12" "Eclipse Adoptium" "https://adoptium.net/" "https://github.com/adoptium/adoptium-support/issues" "https://github.com/adoptium/adoptium-support/issues" +bash ./comparable_patch.sh --jdk-dir "jdk1/jdk-21.0.1+12" --version-string "Temurin-21.0.1+12" --vendor-name "Eclipse Adoptium" --vendor_url "https://adoptium.net/" --vendor-bug-url "https://github.com/adoptium/adoptium-support/issues" --vendor-vm-bug-url "https://github.com/adoptium/adoptium-support/issues" ``` 3. Unzip the other Vendor JDK to compare with, say into "jdk2", and run a similar comparable_patch.sh diff --git a/tooling/comparable_patch.sh b/tooling/comparable_patch.sh index 52003b1ba..d29722d9b 100755 --- a/tooling/comparable_patch.sh +++ b/tooling/comparable_patch.sh @@ -28,17 +28,59 @@ set -eu TEMURIN_TOOLS_BINREPL="temurin.tools.BinRepl" -if [ "$#" -ne 6 ]; then - echo "Syntax: comparable_patch.sh " +JDK_DIR="" +VERSION_REPL="" +VENDOR_NAME="" +VENDOR_URL="" +VENDOR_BUG_URL="" +VENDOR_VM_BUG_URL="" +PATCH_VS_VERSION_INFO=false + +# Parse arguments +while [[ $# -gt 0 ]] && [[ ."$1" = .-* ]] ; do + opt="$1"; + shift; + + case "$opt" in + "--jdk-dir" ) + JDK_DIR="$1"; shift;; + + "--version-string" ) + VERSION_REPL="$1"; shift;; + + "--vendor-name" ) + VENDOR_NAME="$1"; shift;; + + "--vendor_url" ) + VENDOR_URL="$1"; shift;; + + "--vendor-bug-url" ) + VENDOR_BUG_URL="$1"; shift;; + + "--vendor-vm-bug-url" ) + VENDOR_VM_BUG_URL="$1"; shift;; + + "--patch-vs-version-info" ) + PATCH_VS_VERSION_INFO=true;; + + *) echo >&2 "Invalid option: ${opt}"; exit 1;; + esac +done + +if [ -z "$JDK_DIR" ] || [ -z "$VERSION_REPL" ] || [ -z "$VENDOR_NAME" ] || [ -z "$VENDOR_URL" ] || [ -z "$VENDOR_BUG_URL" ] || [ -z "$VENDOR_VM_BUG_URL" ]; then + echo "Error: Missing argument" + echo 'Syntax: comparable_patch.sh --jdk-dir "" --version-string "" --vendor-name "" --vendor_url "" --vendor-bug-url "" --vendor-vm-bug-url "" [--patch-vs-version-info]' exit 1 fi -JDK_DIR="$1" -VERSION_REPL="$2" -VENDOR_NAME="$3" -VENDOR_URL="$4" -VENDOR_BUG_URL="$5" -VENDOR_VM_BUG_URL="$6" +echo "Patching:" +echo " JDK_DIR=$JDK_DIR" +echo " VERSION_REPL=$VERSION_REPL" +echo " VENDOR_NAME=$VENDOR_NAME" +echo " VENDOR_URL=$VENDOR_URL" +echo " VENDOR_BUG_URL=$VENDOR_BUG_URL" +echo " VENDOR_VM_BUG_URL=$VENDOR_VM_BUG_URL" +echo " PATCH_VS_VERSION_INFO=$PATCH_VS_VERSION_INFO" # Remove excluded files known to differ # NOTICE - Vendor specfic notice text file @@ -206,7 +248,13 @@ function removeSystemModulesHashBuilderParams() { # reprohex - A hex UUID to identify the binary version, again generated from binary content function removeWindowsNonComparableData() { echo "Removing EXE/DLL timestamps, CRC and debug repro hex from ${JDK_DIR}" - FILES=$(find "${JDK_DIR}" -type f -path '*.exe' && find "${JDK_DIR}" -type f -path '*.dll') + + # We need to do this for all executables if patching VS_VERSION_INFO + if [[ "$PATCH_VS_VERSION_INFO" = true ]]; then + FILES=$(find "${JDK_DIR}" -type f -path '*.exe' && find "${JDK_DIR}" -type f -path '*.dll') + else + FILES=$(find "${JDK_DIR}" -type f -name 'jvm.dll') + fi for f in $FILES do echo "Removing EXE/DLL non-comparable timestamp, CRC, debug repro hex from $f" @@ -314,12 +362,18 @@ function neutraliseVsVersionInfo() { # Remove Vendor name from all binaries function removeVendorName() { echo "Removing Vendor name: $VENDOR_NAME from binaries from ${JDK_DIR}" + if [[ "$OS" =~ CYGWIN* ]]; then - FILES=$(find "${JDK_DIR}" -type f -path '*.exe' && find "${JDK_DIR}" -type f -path '*.dll') + # We need to do this for all executables if patching VS_VERSION_INFO + if [[ "$PATCH_VS_VERSION_INFO" = true ]]; then + FILES=$(find "${JDK_DIR}" -type f -path '*.exe' && find "${JDK_DIR}" -type f -path '*.dll') + else + FILES=$(find "${JDK_DIR}" -type f -name 'jvm.dll') + fi elif [[ "$OS" =~ Darwin* ]]; then - FILES=$(find "${JDK_DIR}" -type f -path '*.dylib') + FILES=$(find "${JDK_DIR}" -type f -name 'libjvm.dylib') else - FILES=$(find "${JDK_DIR}" -type f -path '*.so') + FILES=$(find "${JDK_DIR}" -type f -name 'libjvm.so') fi for f in $FILES do @@ -467,16 +521,20 @@ echo "Successfully removed all Signatures from ${JDK_DIR}" removeExcludedFiles +# Needed due to vendor variation in jmod re-packing after signing, putting attributes in different order processModuleInfo -removeSystemModulesHashBuilderParams - -if [[ "$OS" =~ CYGWIN* ]]; then +# Patch Windows VS_VERSION_INFO[COMPANY_NAME] +if [[ "$OS" =~ CYGWIN* ]] && [[ "$PATCH_VS_VERSION_INFO" = true ]]; then + # Neutralise COMPANY_NAME neutraliseVsVersionInfo + + # SystemModules$*.class's differ due to hash differences from COMPANY_NAME + removeSystemModulesHashBuilderParams fi if [[ "$OS" =~ CYGWIN* ]]; then - removeWindowsNonComparableData + removeWindowsNonComparableData fi if [[ "$OS" =~ Darwin* ]]; then