Skip to content

Commit

Permalink
Some fixes for Windows comparable build script (#3471)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Leonard <[email protected]>
  • Loading branch information
andrew-m-leonard authored Sep 5, 2023
1 parent dcd7b6f commit fe5f881
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
22 changes: 10 additions & 12 deletions tooling/comparable_patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ set -eu
TEMURIN_TOOLS_BINREPL="temurin.tools.BinRepl"

JDK_DIR="$1"
SELF_CERT="$2"
SELF_CERT_PASS="$3"
VERSION_REPL="$4"
VENDOR_NAME="$5"
VENDOR_URL="$6"
VENDOR_BUG_URL="$7"
VENDOR_VM_BUG_URL="$8"
VERSION_REPL="$2"
VENDOR_NAME="$3"
VENDOR_URL="$4"
VENDOR_BUG_URL="$5"
VENDOR_VM_BUG_URL="$6"

# Remove excluded files known to differ
function removeExcludedFiles() {
Expand Down Expand Up @@ -132,7 +130,7 @@ function removeMacOSNonComparableData() {
echo " FAILED ==> java \"$TEMURIN_TOOLS_BINREPL\" --inFile \"$f\" --outFile \"$f\" --hex \"${uuidhex}-AA:AA:AA:AA:AA:AA:AA:AA:AA:AA:AA:AA:AA:AA:AA:AA\" --firstOnly"
exit 1
fi
fi
fi
done

echo "Successfully removed all MacOS dylib non-comparable UUID from ${JDK_DIR}"
Expand Down Expand Up @@ -261,8 +259,8 @@ function neutraliseReleaseFile() {
fi
}

if [ "$#" -ne 8 ]; then
echo "Syntax: cmd <jdk_dir> <cert_file> <cert_pass> <version_str> <vendor_name> <vendor_url> <vendor_bug_url> <vendor_vm_bug_url>"
if [ "$#" -ne 6 ]; then
echo "Syntax: cmd <jdk_dir> <version_str> <vendor_name> <vendor_url> <vendor_bug_url> <vendor_vm_bug_url>"
exit 1
fi

Expand All @@ -284,15 +282,15 @@ else
exit 1
fi

expandJDK "$JDK_DIR"
expandJDK "$JDK_DIR" "$OS"

echo "Removing all Signatures from ${JDK_DIR} in a deterministic way"

# Remove original certs
removeSignatures "$JDK_DIR" "$OS"

# Sign with temporary cert, so we can remove it and end up with a deterministic result
tempSign "$JDK_DIR" "$OS" "$SELF_CERT" "$SELF_CERT_PASS"
tempSign "$JDK_DIR" "$OS"

# Remove temporary cert
removeSignatures "$JDK_DIR" "$OS"
Expand Down
15 changes: 10 additions & 5 deletions tooling/repro_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function expandJDK() {
expand_dir=$(cygpath -w $expand_dir)
fi
"${JDK_BIN_DIR}/jmod" extract --dir "${expand_dir}" "$f"
rm "$f"
done

echo "Expanding the 'jrt-fs.jar' to remove signatures from within.."
Expand All @@ -63,6 +64,8 @@ function expandJDK() {
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
rm "${JDK_DIR}/jmods/expanded_java.base.jmod/lib/jrt-fs.jar"

rm -rf "${JDK_ROOT}_CP"
}

# Remove all Signatures
Expand All @@ -71,7 +74,8 @@ function removeSignatures() {
local OS="$2"

if [[ "$OS" =~ CYGWIN* ]]; then
signToolPath="/cygdrive/c/Program Files (x86)/Windows Kits/10/bin/10.0.17763.0/x64/signtool.exe"
# signtool should be on PATH
signToolPath="signtool"
echo "Removing all Signatures from ${JDK_DIR}"
FILES=$(find "${JDK_DIR}" -type f -name '*.exe' -o -name '*.dll')
for f in $FILES
Expand Down Expand Up @@ -110,7 +114,8 @@ function tempSign() {
local OS="$2"

if [[ "$OS" =~ CYGWIN* ]]; then
signToolPath="/cygdrive/c/Program Files (x86)/Windows Kits/10/bin/10.0.17763.0/x64/signtool.exe"
# signtool should be on PATH
signToolPath="signtool"
echo "Adding temp Signatures for ${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"
Expand Down Expand Up @@ -159,7 +164,7 @@ function cleanTemurinFiles() {
sed -i "" '/^JVM_VARIANT=.*$/d' "${DIR}/release"
sed -i "" '/^JVM_VERSION=.*$/d' "${DIR}/release"
sed -i "" '/^IMAGE_TYPE=.*$/d' "${DIR}/release"

echo "Removing SOURCE= from ${DIR}/release file, as Temurin builds from Adoptium mirror repo _adopt tag"
sed -i "" '/^SOURCE=.*$/d' "${DIR}/release"
else
Expand Down Expand Up @@ -190,7 +195,7 @@ function cleanTemurinFiles() {
# Temurin release file metadata BUILD_INFO/SOURCE can/will be different
function cleanTemurinBuildInfo() {
local DIR="$1"

echo "Cleaning any Temurin build-scripts release file BUILD_INFO from ${DIR}"

if [[ $(uname) =~ Darwin* ]]; then
Expand All @@ -199,7 +204,7 @@ function cleanTemurinBuildInfo() {
sed -i "" '/^BUILD_INFO=.*$/d' "${DIR}/release"
else
sed -i '/^BUILD_SOURCE=.*$/d' "${DIR}/release"
sed -i '/^BUILD_SOURCE_REPO=.*$/d' "${DIR}/release"
sed -i '/^BUILD_SOURCE_REPO=.*$/d' "${DIR}/release"
sed -i '/^BUILD_INFO=.*$/d' "${DIR}/release"
fi
}
Expand Down

0 comments on commit fe5f881

Please sign in to comment.