Skip to content

Commit

Permalink
Tidy up output from repro_compare.sh
Browse files Browse the repository at this point in the history
Signed-off-by: Stewart X Addison <[email protected]>
  • Loading branch information
sxa committed Oct 31, 2024
1 parent 62ecfba commit 0123cbc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 29 deletions.
44 changes: 22 additions & 22 deletions tooling/reproducible/repro_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ function expandJDK() {
JDK_ROOT=$(realpath ${JDK_DIR}/../../)
JDK_BIN_DIR="${JDK_ROOT}_CP/Contents/Home/bin"
fi

echo "$(date +%T) : Expanding various components to enable comparisons ${JDK_DIR} (original files will be removed):"
mkdir "${JDK_ROOT}_CP"
cp -R ${JDK_ROOT}/* ${JDK_ROOT}_CP
echo "Expanding the 'modules' Image to compare extracted files"

echo "$(date +%T) : Using 'jimage extract' to expand lib/modules image into lib/modules_extracted"
modulesFile="${JDK_DIR}/lib/modules"
mkdir "${JDK_DIR}/lib/modules_extracted"
extractedDir="${JDK_DIR}/lib/modules_extracted"
Expand All @@ -38,11 +39,11 @@ function expandJDK() {
fi
"${JDK_BIN_DIR}/jimage" extract --dir "${extractedDir}" "${modulesFile}"
rm "${JDK_DIR}/lib/modules"
echo "Expanding the 'src.zip' to normalize file permissions"
unzip "${JDK_DIR}/lib/src.zip" -d "${JDK_DIR}/lib/src_zip_expanded" 1> /dev/null
echo "$(date +%T) : Unzipping lib/src.zip to normalize file permissions, then removing src.zip"
unzip -q "${JDK_DIR}/lib/src.zip" -d "${JDK_DIR}/lib/src_zip_expanded"
rm "${JDK_DIR}/lib/src.zip"

echo "Expanding jmods to process binaries within"
echo "$(date +%T) : Using 'jmod extract' to expand all jmods to jmods/expanded_ directories"
FILES=$(find "${JDK_DIR}" -type f -path '*.jmod')
for f in $FILES
do
Expand All @@ -58,21 +59,21 @@ function expandJDK() {
rm "$f"
done

echo "Expanding the 'jrt-fs.jar' to remove signatures from within.."
echo "$(date +%T) : Expanding lib/jrt-fs.jar to lib/jrt-fs-exanded to remove signatures from within.."
mkdir "${JDK_DIR}/lib/jrt-fs-expanded"
unzip -d "${JDK_DIR}/lib/jrt-fs-expanded" "${JDK_DIR}/lib/jrt-fs.jar" 1> /dev/null
unzip -qd "${JDK_DIR}/lib/jrt-fs-expanded" "${JDK_DIR}/lib/jrt-fs.jar"
rm "${JDK_DIR}/lib/jrt-fs.jar"

mkdir -p "${JDK_DIR}/jmods/expanded_java.base.jmod/lib/jrt-fs-expanded"
unzip -d "${JDK_DIR}/jmods/expanded_java.base.jmod/lib/jrt-fs-expanded" "${JDK_DIR}/jmods/expanded_java.base.jmod/lib/jrt-fs.jar" 1> /dev/null
unzip -qd "${JDK_DIR}/jmods/expanded_java.base.jmod/lib/jrt-fs-expanded" "${JDK_DIR}/jmods/expanded_java.base.jmod/lib/jrt-fs.jar"
rm "${JDK_DIR}/jmods/expanded_java.base.jmod/lib/jrt-fs.jar"

echo "Expanding 'ct.sym' to workaround zip timestamp differences (https://bugs.openjdk.org/browse/JDK-8327466)"
echo "$(date +%T) : Expanding lib/ct.sym to workaround zip timestamp differences (https://bugs.openjdk.org/browse/JDK-8327466)"
mkdir "${JDK_DIR}/lib/ct-sym-expanded"
unzip -d "${JDK_DIR}/lib/ct-sym-expanded" "${JDK_DIR}/lib/ct.sym" 1> /dev/null
unzip -qd "${JDK_DIR}/lib/ct-sym-expanded" "${JDK_DIR}/lib/ct.sym"
rm "${JDK_DIR}/lib/ct.sym"
mkdir -p "${JDK_DIR}/jmods/expanded_jdk.compiler.jmod/lib/ct-sym-expanded"
unzip -d "${JDK_DIR}/jmods/expanded_jdk.compiler.jmod/lib/ct-sym-expanded" "${JDK_DIR}/jmods/expanded_jdk.compiler.jmod/lib/ct.sym" 1> /dev/null
unzip -qd "${JDK_DIR}/jmods/expanded_jdk.compiler.jmod/lib/ct-sym-expanded" "${JDK_DIR}/jmods/expanded_jdk.compiler.jmod/lib/ct.sym"
rm "${JDK_DIR}/jmods/expanded_jdk.compiler.jmod/lib/ct.sym"

rm -rf "${JDK_ROOT}_CP"
Expand Down Expand Up @@ -141,7 +142,7 @@ function removeSystemModulesHashBuilderParams() {
done
done

echo "Successfully removed all SystemModules jdk.jpackage hash differences from ${JDK_DIR}"
echo "$(date +%T) : Successfully removed all SystemModules jdk.jpackage hash differences from ${JDK_DIR}"
}

# Required for Vendor "Comparable Builds"
Expand All @@ -153,7 +154,7 @@ function removeSystemModulesHashBuilderParams() {
# checksum - A checksum value of the binary
# 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}"
echo "$(date +%T) : Removing EXE/DLL timestamps, CRC and debug repro hex from ${JDK_DIR}"
# 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')
Expand All @@ -163,13 +164,13 @@ function removeWindowsNonComparableData() {
for ff in $FILES
do
f=$(cygpath -w $ff)
echo "Removing EXE/DLL non-comparable timestamp, CRC, debug repro hex from $f"
echo "$(date +%T) : Removing EXE/DLL non-comparable timestamp, CRC, debug repro hex from $f"

# Determine non-comparable data using dumpbin
dmpfile="$ff.dumpbin.tmp"
rm -f "$dmpfile"
if ! dumpbin "$f" /HEADERS > "$dmpfile"; then
echo " FAILED == > dumpbin \"$f\" /ALL > $dmpfile"
echo "$(date +%T) : FAILED == > dumpbin \"$f\" /ALL > $dmpfile"
exit 1
fi

Expand Down Expand Up @@ -254,8 +255,8 @@ function processModuleInfo() {
local JDK_DIR="$1"
local OS="$2"
local work_JDK="$3"
echo "process Module Info from ${JDK_DIR}"
echo "Normalizing ModuleAttributes order in module-info.class, converting to javap"
echo "$(date +%T) : Process Module Info from ${JDK_DIR}"
echo "$(date +%T) : 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
Expand Down Expand Up @@ -343,7 +344,7 @@ function removeSignatures() {
if [[ "$OS" =~ CYGWIN* ]]; then
# signtool should be on PATH
signToolPath="signtool"
echo "Removing all Signatures from ${JDK_DIR}"
echo "$(date +%T) : Removing all signatures from exe and dll files in ${JDK_DIR}"
FILES=$(find "${JDK_DIR}" -type f -name '*.exe' -o -name '*.dll')
for f in $FILES
do
Expand Down Expand Up @@ -384,9 +385,9 @@ function tempSign() {
if [[ "$OS" =~ CYGWIN* ]]; then
# signtool should be on PATH
signToolPath="signtool"
echo "Adding temp Signatures for ${JDK_DIR}"
echo "Generating temp signatures with openssl and adding them to exe/dll files in ${JDK_DIR}"
selfCert="test"
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout $selfCert.key -out $selfCert.crt -subj "/CN=example.com" -addext "subjectAltName=DNS:example.com,DNS:*.example.com,IP:10.0.0.1"
openssl req -x509 -quiet -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout $selfCert.key -out $selfCert.crt -subj "/CN=example.com" -addext "subjectAltName=DNS:example.com,DNS:*.example.com,IP:10.0.0.1"
openssl pkcs12 -export -passout pass:test -out $selfCert.pfx -inkey $selfCert.key -in $selfCert.crt
FILES=$(find "${JDK_DIR}" -type f -name '*.exe' -o -name '*.dll')
for f in $FILES
Expand Down Expand Up @@ -416,8 +417,7 @@ function tempSign() {
function cleanTemurinFiles() {
local DIR="$1"

echo "Cleaning Temurin build-scripts specific files and metadata from ${DIR}"
echo "Removing Temurin NOTICE file from $DIR"
echo "$(date +%T): Cleaning Temurin NOTICE file and build-scripts specific files and metadata from ${DIR}"
rm "${DIR}"/NOTICE

if [[ $(uname) =~ Darwin* ]]; then
Expand Down
7 changes: 4 additions & 3 deletions tooling/reproducible/repro_compare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ do
exit 1
fi

echo "Pre-processing ${JDK_DIR}"
echo "$(date +%T) : Pre-processing ${JDK_DIR}"
rc=0
source "$(dirname "$0")"/repro_process.sh "${JDK_DIR}" "${OS}" || rc=$?
if [ $rc != 0 ]; then
echo "Pre-process of ${JDK_DIR} ${OS} failed"
echo "$(date +%T): Pre-processing of ${JDK_DIR} ${OS} failed"
exit 1
fi

Expand All @@ -59,8 +59,9 @@ files1=$(find "${JDK_DIR1}" -type f | wc -l)
echo "Number of files: ${files1}"
rc=0
output="reprotest.diff"
echo "Comparing ${JDK_DIR1} with ${JDK_DIR2} ... output to file: ${output}"
echo "$(date +%T) : Comparing expanded JDKs from ${JDK_DIR1} with ${JDK_DIR2} ..."
diff -r -q "${JDK_DIR1}" "${JDK_DIR2}" > "${output}" || rc=$?
echo "$(date +%T) : diff complete - rc=$rc. Output written to file: ${output}"

cat "${output}"

Expand Down
6 changes: 2 additions & 4 deletions tooling/reproducible/repro_process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,5 @@ fi

patchManifests "${JDK_DIR}"

echo "***********"
echo " Preprocess ${JDK_DIR} SUCCESS :-)"
echo "***********"

echo "$(date +%T) : Pre-processing of ${JDK_DIR} SUCCESSFUL :-)"
echo "" # blank line separator in log file

0 comments on commit 0123cbc

Please sign in to comment.