Skip to content

Commit

Permalink
Reconstruct mac and windows reproducible comparison script
Browse files Browse the repository at this point in the history
Signed-off-by: Sophia Guo <[email protected]>
  • Loading branch information
sophia-guo committed Jun 26, 2023
1 parent 1823a19 commit 0496476
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 309 deletions.
31 changes: 0 additions & 31 deletions tooling/linux_repro_process.sh

This file was deleted.

83 changes: 0 additions & 83 deletions tooling/mac_repro_compare.sh

This file was deleted.

8 changes: 4 additions & 4 deletions tooling/repro_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ function removeSignatures() {
function tempSign() {
local JDK_DIR="$1"
local OS="$2"
local SELF_CERT="$3"
local SELF_CERT_PASS="$4"

if [[ "$OS" =~ CYGWIN* ]]; then
echo "Adding temp Signatures for ${JDK_DIR}"
Expand All @@ -109,13 +107,15 @@ function tempSign() {
elif [[ "$OS" =~ Darwin* ]]; then
MAC_JDK_ROOT="${JDK_DIR}/../../Contents"
echo "Adding temp Signatures for ${MAC_JDK_ROOT}"

openssl genpkey -algorithm RSA -pass pass:test -outform PEM -out privatePemFile -pkeyopt rsa_keygen_bits:2048
echo "public key"
openssl rsa -in ${privatePemFile} -passin pass:test -pubout -out publicPemFile
FILES=$(find "${MAC_JDK_ROOT}" \( -type f -and -path '*.dylib' -or -path '*/bin/*' -or -path '*/lib/jspawnhelper' -not -path '*/modules_extracted/*' -or -path '*/jpackageapplauncher*' \))
for f in $FILES
do
echo "Signing $f with a local certificate"
# Sign both with same local Certificate, this adjusts __LINKEDIT vmsize identically
codesign -s "$SELF_CERT" --options runtime -f --timestamp "$f"
codesign -s "$privatePemFile" --options runtime -f --timestamp "$f"
done
fi
}
Expand Down
62 changes: 25 additions & 37 deletions tooling/linux_repro_compare.sh → tooling/repro_compare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,51 +19,39 @@ BLD_TYPE1="$1"
JDK_DIR1="$2"
BLD_TYPE2="$3"
JDK_DIR2="$4"
OS="$5"

if [ ! -d "${JDK_DIR1}" ]; then
echo "$JDK_DIR1 does not exist"
echo "linux_repro_compare.sh (temurin|openjdk) JDK_DIR1 (temurin|openjdk) JDK_DIR2"
exit 1
fi

if [ ! -d "${JDK_DIR2}" ]; then
echo "$JDK_DIR2 does not exist"
echo "linux_repro_compare.sh (temurin|openjdk) JDK_DIR1 (temurin|openjdk) JDK_DIR2"
exit 1
fi

echo "Pre-processing ${JDK_DIR1}"
rc=0
source ./linux_repro_process.sh "${JDK_DIR1}" || rc=$?
if [ $rc != 0 ]; then
echo "Pre-process of ${JDK_DIR1} failed"
exit 1
fi
JDK_DIR_Arr=("${JDK_DIR1}" "${JDK_DIR2}")
for JDK_DIR in "${JDK_DIR_Arr[@]}"
do
if [[ ! -d "${JDK_DIR}" ]] || [[ ! -d "${JDK_DIR}/bin" ]]; then
echo "$JDK_DIR does not exist or does not point at a JDK"
echo "repro_compare.sh (temurin|openjdk) JDK_DIR1 (temurin|openjdk) JDK_DIR2 OS"
exit 1
fi

echo "Pre-processing ${JDK_DIR2}"
source ./linux_repro_process.sh "${JDK_DIR2}" || rc=$?
if [ $rc != 0 ]; then
echo "Pre-process of ${JDK_DIR2} failed"
exit 1
fi
echo "Pre-processing ${JDK_DIR}"
rc=0
source ./repro_process.sh "${JDK_DIR}" "${OS}" || rc=$?
if [ $rc != 0 ]; then
echo "Pre-process of ${JDK_DIR} "${OS}" failed"
exit 1
fi

# If comparing a plain openjdk build to a Temurin built one clean Temurin script specific content
if [ "$BLD_TYPE1" != "$BLD_TYPE2" ]; then
cleanTemurinFiles "${JDK_DIR1}"
cleanTemurinFiles "${JDK_DIR2}"
fi
# If comparing a plain openjdk build to a Temurin built one clean Temurin script specific content
if [ "$BLD_TYPE1" != "$BLD_TYPE2" ]; then
cleanTemurinFiles "${JDK_DIR}"
fi
# release file build machine OS level and builds-scripts SHA can/will be different
cleanTemurinBuildInfo "${JDK_DIR}"
done

# release file build machine OS level and builds-scripts SHA can/will be different
cleanTemurinBuildInfo "${JDK_DIR1}"
cleanTemurinBuildInfo "${JDK_DIR2}"

files1=$(find "${JDK_DIR1}" -type f | wc -l)

rc=0
output="repro_diff.out"
echo "Comparing ${JDK_DIR1} with ${JDK_DIR2} ... output to file: ${output}"
diff -r "${JDK_DIR1}" "${JDK_DIR2}" > "${output}"
rc=$?
echo "diff rc=${rc}"
diff -r "${JDK_DIR1}" "${JDK_DIR2}" > "${output}" || rc=$?

num_differences=$(wc -l < "${output}")
echo "Number of differences: ${num_differences}"
Expand Down
Empty file added tooling/repro_diff.out
Empty file.
31 changes: 11 additions & 20 deletions tooling/mac_repro_process.sh → tooling/repro_process.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# shellcheck disable=SC2086,SC1091
# shellcheck disable=SC1091
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -11,36 +11,27 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################

################################################################################
source repro_common.sh

set -e

JDK_DIR="$1"
SELF_CERT="$2"
SELF_CERT_PASS="$3"
OS="$2"

# This script unpacks the JDK_DIR and removes windows signing Signatures in a neutral way
# ensuring identical output once Signature is removed.

if [[ ! -d "${JDK_DIR}" ]] || [[ ! -d "${JDK_DIR}/bin" ]]; then
echo "$JDK_DIR does not exist or does not point at a JDK"
exit 1
fi

OS="Darwin"

expandJDK "$JDK_DIR"

# Remove existing signature
removeSignatures "$JDK_DIR" "$OS"
if [[ "$OS" =~ CYGWIN* ]] || [[ "$OS" =~ Darwin* ]]; then
# Remove existing signature
removeSignatures "$JDK_DIR" "$OS"

# Add the SELF_SIGN temporary signature
tempSign "$JDK_DIR" "$OS" "$SELF_CERT" "$SELF_CERT_PASS"
# Add the SELF_SIGN temporary signature
tempSign "$JDK_DIR" "$OS"

# Remove temporary SELF_SIGN signature, which will then normalize binary length
removeSignatures "$JDK_DIR" "$OS"
# Remove temporary SELF_SIGN signature, which will then normalize binary length
# removeSignatures "$JDK_DIR" "$OS"
fi

patchManifests "${JDK_DIR}"

Expand Down
83 changes: 0 additions & 83 deletions tooling/windows_repro_compare.sh

This file was deleted.

Loading

0 comments on commit 0496476

Please sign in to comment.