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

Update reproducible comparing on linux #3921

Merged
merged 11 commits into from
Sep 6, 2024
4 changes: 3 additions & 1 deletion test/system/reproducibleCompare/reproducible.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ endif

ifneq (,$(findstring linux,$(SPEC)))
SBOM_FILE := $(subst $(TEST_ROOT)/../jdkbinary,/home/jenkins/test,$(SBOM_FILE))
endif
endif

RM_DEBUGINFO := $(shell find $(TEST_JDK_HOME) -type f -name "*.debuginfo" -delete)
36 changes: 13 additions & 23 deletions tooling/reproducible/linux_repro_build_compare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ ANT_VERSION=1.10.5
ANT_SHA=9028e2fc64491cca0f991acc09b06ee7fe644afe41d1d6caf72702ca25c4613c
ANT_CONTRIB_VERSION=1.0b3
ANT_CONTRIB_SHA=4d93e07ae6479049bb28071b069b7107322adaee5b70016674a0bffd4aac47f9
isJdkDir=false
USING_DEVKIT="false"
ScriptPath=$(dirname "$(realpath "$0")")

installPrereqs() {
if test -r /etc/redhat-release; then
# Replace mirrorlist to vault as centos7 reached EOL.
Expand Down Expand Up @@ -88,12 +89,6 @@ setAntEnvironment() {
export PATH="${LOCALGCCDIR}/bin:/usr/local/bin:/usr/bin:$PATH:/usr/local/apache-ant-${ANT_VERSION}/bin"
}

cleanBuildInfo() {
local DIR="$1"
# BUILD_INFO name of OS level build was built on will likely differ
sed -i '/^BUILD_INFO=.*$/d' "${DIR}/release"
}

setTemurinBuildArgs() {
local buildArgs="$1"
local bootJdk="$2"
Expand Down Expand Up @@ -185,41 +180,36 @@ if [ -z "$JDK_PARAM" ] && [ ! -d "jdk-${TEMURIN_VERSION}" ] ; then
JDK_PARAM="https://api.adoptium.net/v3/binary/version/jdk-${TEMURIN_VERSION}/linux/${NATIVE_API_ARCH}/jdk/hotspot/normal/eclipse?project=jdk"
fi

sourceJDK="jdk-${TEMURIN_VERSION}"
mkdir "${sourceJDK}"
if [[ $JDK_PARAM =~ ^https?:// ]]; then
echo Retrieving original tarball from adoptium.net && curl -L "$JDK_PARAM" | tar xpfz - && ls -lart "$PWD/jdk-${TEMURIN_VERSION}" || exit 1
elif [[ $JDK_PARAM =~ tar.gz ]]; then
mkdir "$PWD/jdk-${TEMURIN_VERSION}"
tar xpfz "$JDK_PARAM" --strip-components=1 -C "$PWD/jdk-${TEMURIN_VERSION}"
else
echo "Local jdk dir"
isJdkDir=true
fi

comparedDir="jdk-${TEMURIN_VERSION}"
if [ "${isJdkDir}" = true ]; then
comparedDir=$JDK_PARAM
#Local jdk dir
sophia-guo marked this conversation as resolved.
Show resolved Hide resolved
cp -R "${JDK_PARAM}"/* "${sourceJDK}"
fi

echo "Rebuild args for makejdk_any_platform.sh are: $TEMURIN_BUILD_ARGS"
echo " cd temurin-build && ./makejdk-any-platform.sh $TEMURIN_BUILD_ARGS 2>&1 | tee build.$$.log" | sh

echo Comparing ...
mkdir compare.$$
tar xpfz temurin-build/workspace/target/OpenJDK*-jdk_*tar.gz -C compare.$$
mkdir tarJDK
tar xpfz temurin-build/workspace/target/OpenJDK*-jdk_*tar.gz -C tarJDK
cp temurin-build/workspace/target/OpenJDK*-jdk_*tar.gz reproJDK.tar.gz
cp "$SBOM" SBOM.json

cleanBuildInfo "${comparedDir}"
cleanBuildInfo "compare.$$/jdk-$TEMURIN_VERSION"
cp "$ScriptPath"/repro_*.sh "$PWD"
chmod +x "$PWD"/repro_*.sh
rc=0

# shellcheck disable=SC2069
diff -r "${comparedDir}" "compare.$$/jdk-$TEMURIN_VERSION" 2>&1 > "reprotest.diff" || rc=$?
set +e
./repro_compare.sh temurin "$sourceJDK" temurin tarJDK/jdk-"$TEMURIN_VERSION" Linux 2>&1 || rc=$?
set -e

if [ $rc -eq 0 ]; then
echo "Compare identical !"
else
cat "reprotest.diff"
echo "Differences found..., logged in: reprotest.diff"
fi

Expand Down
31 changes: 17 additions & 14 deletions tooling/reproducible/repro_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,24 @@ function processModuleInfo() {
fi
}

# Remove windowns generate classes jdk/bin/server/classes.jsa & jdk/bin/server/classes_nocoops.jsa
function removeGeneratedClasses() {
# Remove excluded files known to differ
# NOTICE - Vendor specfic notice text file
# cacerts - Vendors use different cacerts
# classlist - Used to generate CDS archives, can vary due to different build machine environment
# classes.jsa, classes_nocoops.jsa - CDS archive caches will differ due to Vendor string differences
function removeExcludedFiles() {
local JDK_DIR="$1"
local OS="$2"

if [[ "$OS" =~ CYGWIN* ]] || [[ "$OS" =~ Darwin* ]]; then
rm -rf "$JDK_DIR/bin/server/classes.jsa"
rm -rf "$JDK_DIR/bin/server/classes_nocoops.jsa"
fi
excluded="NOTICE cacerts classlist classes.jsa classes_nocoops.jsa"
sophia-guo marked this conversation as resolved.
Show resolved Hide resolved
echo "Removing excluded files known to differ: ${excluded}"
for exclude in $excluded
do
FILES=$(find "${JDK_DIR}" -type f -name "$exclude")
for f in $FILES
do
echo "Removing $f"
rm -f "$f"
done
done
}

# Remove all Signatures
Expand Down Expand Up @@ -421,9 +430,6 @@ function cleanTemurinFiles() {

echo "Cleaning Temurin build-scripts specific files and metadata from ${DIR}"

echo "Removing Temurin NOTICE file from $DIR"
rm "${DIR}"/NOTICE
sophia-guo marked this conversation as resolved.
Show resolved Hide resolved

if [[ $(uname) =~ Darwin* ]]; then
echo "Removing Temurin specific lines from release file in $DIR"
sed -i "" '/^BUILD_SOURCE=.*$/d' "${DIR}/release"
Expand Down Expand Up @@ -454,9 +460,6 @@ function cleanTemurinFiles() {
sed -i '/^SOURCE=.*$/d' "${DIR}/release"
fi

echo "Removing cacerts file, as Temurin builds with different Mozilla cacerts"
find "${DIR}" -type f -name "cacerts" -delete
sophia-guo marked this conversation as resolved.
Show resolved Hide resolved

echo "Removing any JDK image files not shipped by Temurin(*.pdb, *.pdb, demo) in $DIR"
find "${DIR}" -type f -name "*.pdb" -delete
find "${DIR}" -type f -name "*.map" -delete
Expand Down
4 changes: 2 additions & 2 deletions tooling/reproducible/repro_process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ OS="$2"

expandJDK "$JDK_DIR" "$OS"

removeGeneratedClasses "$JDK_DIR" "$OS"
removeExcludedFiles "$JDK_DIR"
sophia-guo marked this conversation as resolved.
Show resolved Hide resolved
if [[ "$OS" =~ CYGWIN* ]] || [[ "$OS" =~ Darwin* ]]; then

# Remove existing signature
Expand All @@ -39,6 +39,6 @@ fi
patchManifests "${JDK_DIR}"

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

Loading