Skip to content

Commit

Permalink
Fixes for Windows "Comparable Build" scripts to functioning correctly…
Browse files Browse the repository at this point in the history
… using cygpath's (#3897)

* Comparable builds need to patch SystemModule due to Vendor string differences

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Fixes for Windows comparable build script and doc update

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Fixes for Windows comparable build script and doc update

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Fixes for Windows comparable build script and doc update

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

---------

Signed-off-by: Andrew Leonard <anleonar@redhat.com>
  • Loading branch information
andrew-m-leonard authored Jul 31, 2024
1 parent dd82c15 commit 7dc73f3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 79 deletions.
3 changes: 2 additions & 1 deletion tooling/reproducible/ReproducibleBuilds.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ before the comparable_patch.sh can be run.

- [Windows only] For WindowsUpdateVsVersionInfo.exe : export PATH=<temurin-build>/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=<temurin-build>/tooling/src/java:$CLASSPATH
- [Windows only] For signtool.exe MSVS tool : export PATH=/cygdrive/c/progra\~2/wi3cf2\~1/10/bin/10.0.22621.0/x64:$PATH
- For BinRepl.class : export CLASSPATH=<temurin-build>/tooling/src/java:$CLASSPATH
- A JDK for running BinRepl java : export PATH=<jdk>/bin:$PATH

#### Running comparable_patch.sh:
Expand Down
88 changes: 10 additions & 78 deletions tooling/reproducible/comparable_patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,90 +105,14 @@ function removeExcludedFiles() {
echo "Successfully removed all excluded files from ${JDK_DIR}"
}

# Normalize the following ModuleAttributes that can be ordered differently
# depending on how the vendor has signed and re-packed the JMODs
# - ModuleResolution:
# - ModuleTarget:
# java.base also requires the dependent module "hash:" values to be excluded
# as they differ due to the Signatures and Vendor string differences
function processModuleInfo() {
echo "Normalizing ModuleAttributes order in module-info.class, converting to javap"

moduleAttr="ModuleResolution ModuleTarget"

FILES=$(find "${JDK_DIR}" -type f -name "module-info.class")
for f in $FILES
do
echo "javap and re-order ModuleAttributes for $f"
javap -v -sysinfo -l -p -c -s -constants "$f" > "$f.javap.tmp"
rm "$f"

cc=99
foundAttr=false
attrName=""
# Clear any attr tmp files
for attr in $moduleAttr
do
rm -f "$f.javap.$attr"
done

while IFS= read -r line
do
cc=$((cc+1))

# Module attr have only 1 line definition
if [[ "$foundAttr" = true ]] && [[ "$cc" -gt 1 ]]; then
foundAttr=false
attrName=""
fi

# If not processing an attr then check for attr
if [[ "$foundAttr" = false ]]; then
for attr in $moduleAttr
do
if [[ "$line" =~ .*"$attr:".* ]]; then
cc=0
foundAttr=true
attrName="$attr"
fi
done
fi

# Echo attr to attr tmp file, otherwise to tmp2
if [[ "$foundAttr" = true ]]; then
echo "$line" >> "$f.javap.$attrName"
else
echo "$line" >> "$f.javap.tmp2"
fi
done < "$f.javap.tmp"
rm "$f.javap.tmp"

# Remove javap Classfile and timestamp and SHA-256 hash
if [[ "$f" =~ .*"java.base".* ]]; then
grep -v "Last modified\|Classfile\|SHA-256 checksum\|hash:" "$f.javap.tmp2" > "$f.javap"
else
grep -v "Last modified\|Classfile\|SHA-256 checksum" "$f.javap.tmp2" > "$f.javap"
fi
rm "$f.javap.tmp2"

# Append any ModuleAttr tmp files
for attr in $moduleAttr
do
if [[ -f "$f.javap.$attr" ]]; then
cat "$f.javap.$attr" >> "$f.javap"
fi
rm -f "$f.javap.$attr"
done
done
}

# Neutralize Windows VS_VERSION_INFO CompanyName from the resource compiled PE section
function neutraliseVsVersionInfo() {
echo "Updating EXE/DLL VS_VERSION_INFO in ${JDK_DIR}"
FILES=$(find "${JDK_DIR}" -type f -path '*.exe' && find "${JDK_DIR}" -type f -path '*.dll')
for f in $FILES
do
echo "Removing EXE/DLL VS_VERSION_INFO from $f"
f=$(cygpath -w "$f")

# Neutralize CompanyName
WindowsUpdateVsVersionInfo "$f" "CompanyName=AAAAAA"
Expand Down Expand Up @@ -226,6 +150,9 @@ function removeVendorName() {
do
# Neutralize vendor string with 0x00 to same length
echo "Neutralizing $VENDOR_NAME in $f"
if [[ "$OS" =~ CYGWIN* ]]; then
f=$(cygpath -w "$f")
fi
if ! java "$TEMURIN_TOOLS_BINREPL" --inFile "$f" --outFile "$f" --string "${VENDOR_NAME}=" --pad 00; then
echo " Not found ==> java $TEMURIN_TOOLS_BINREPL --inFile \"$f\" --outFile \"$f\" --string \"${VENDOR_NAME}=\" --pad 00"
fi
Expand All @@ -248,7 +175,12 @@ function neutraliseVersionProps() {
for f in $FILES
do
echo "javap and remove vendor string lines from $f"
javap -v -sysinfo -l -p -c -s -constants "$f" > "$f.javap.tmp"
if [[ "$OS" =~ CYGWIN* ]]; then
ff=$(cygpath -w "$f")
else
ff=$f
fi
javap -v -sysinfo -l -p -c -s -constants "$ff" > "$f.javap.tmp"
rm "$f"
grep -v "Last modified\|$VERSION_REPL\|$VENDOR_NAME\|$VENDOR_URL\|$VENDOR_BUG_URL\|$VENDOR_VM_BUG_URL\|Classfile\|SHA-256" "$f.javap.tmp" > "$f.javap"
rm "$f.javap.tmp"
Expand Down

0 comments on commit 7dc73f3

Please sign in to comment.