Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows and Mac reproducible comparison script update #3415

Merged
merged 3 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 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.

28 changes: 18 additions & 10 deletions tooling/repro_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,20 @@
# Expand JDK jmods & zips to process binaries within
function expandJDK() {
local JDK_DIR="$1"
mkdir "${JDK_DIR}_CP"
cp -R ${JDK_DIR}/* ${JDK_DIR}_CP
local OS="$2"
local JDK_ROOT="$1"
local JDK_BIN_DIR="${JDK_ROOT}_CP/bin"
if [[ "$OS" =~ Darwin* ]]; then
JDK_ROOT=$(realpath ${JDK_DIR}/../../)
JDK_BIN_DIR="${JDK_ROOT}_CP/Contents/Home/bin"
fi

sleep 200
mkdir "${JDK_ROOT}_CP"
cp -R ${JDK_ROOT}/* ${JDK_ROOT}_CP
echo "Expanding the 'modules' Image to remove signatures from within.."
"${JDK_DIR}_CP/bin/jimage" extract --dir "${JDK_DIR}/lib/modules_extracted" "${JDK_DIR}/lib/modules"
"${JDK_BIN_DIR}/jimage" extract --dir "${JDK_DIR}/lib/modules_extracted" "${JDK_DIR}/lib/modules"
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
rm "${JDK_DIR}/lib/src.zip"
Expand All @@ -34,8 +42,7 @@ function expandJDK() {
dir=$(dirname "$f")
expand_dir="${dir}/expanded_${base}"
mkdir -p "${expand_dir}"
"${JDK_DIR}_CP/bin/jmod" extract --dir "${expand_dir}" "$f"
rm "$f"
"${JDK_BIN_DIR}/jmod" extract --dir "${expand_dir}" "$f"
done

echo "Expanding the 'jrt-fs.jar' to remove signatures from within.."
Expand Down Expand Up @@ -81,7 +88,7 @@ function removeSignatures() {
for f in $FILES
do
echo "Removing signature from $f"
codesign --remove-signature "$f"
codesign --remove-signature "$f" 1> /dev/null
done
fi
}
Expand All @@ -90,16 +97,16 @@ 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}"
openssl genpkey -algorithm RSA -pass pass:test -outform PEM -out SELF_CERT.key -pkeyopt rsa_keygen_bits:2048
openssl rsa -in SELF_CERT.key -passin pass:test -pubout -out SELF_CERT_PUBLIC.key
FILES=$(find "${JDK_DIR}" -type f -path '*.exe' && find "${JDK_DIR}" -type f -path '*.dll')
for f in $FILES
do
echo "Signing $f"
if signtool sign /f "$SELF_CERT" /p "$SELF_CERT_PASS" "$f" ; then
if signtool sign /f SELF_CERT.key /p SELF_CERT_PPUBLIC.key "$f" ; then
echo " ==> Successfully signed $f"
else
echo " ==> $f failed to be signed!!"
Expand All @@ -109,6 +116,7 @@ function tempSign() {
elif [[ "$OS" =~ Darwin* ]]; then
MAC_JDK_ROOT="${JDK_DIR}/../../Contents"
echo "Adding temp Signatures for ${MAC_JDK_ROOT}"
#TODO Generate locally certificate SELF_CERT

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
Expand Down
60 changes: 25 additions & 35 deletions tooling/linux_repro_compare.sh → tooling/repro_compare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,43 @@
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################

source repro_common.sh

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
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

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_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

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
# 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

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

# 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

# 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)

echo "Number of files: ${files1}"
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=$?
Expand Down
32 changes: 12 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,28 @@
# 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
expandJDK "$JDK_DIR" "$OS"

OS=$("uname")

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

# Remove existing signature
removeSignatures "$JDK_DIR" "$OS"
# Add the SELF_SIGN temporary signature
tempSign "$JDK_DIR" "$OS"

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

# 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
Loading