diff --git a/test/system/reproducibleCompare/playlist.xml b/test/system/reproducibleCompare/playlist.xml index 12b3c8a6b..ddae35c60 100644 --- a/test/system/reproducibleCompare/playlist.xml +++ b/test/system/reproducibleCompare/playlist.xml @@ -38,4 +38,23 @@ os.linux + + Rebuild_Same_JDK_Reproducibility_Test_win + $(TEST_ROOT)$(D)system$(D)reproducibleCompare$(D)windows_repro_build_compare.sh $(SBOM_FILE) $(JDK_FILE) $(REPORTDIR); \ + $(TEST_STATUS) + + + dev + + + system + + + eclipse + + + 21+ + + os.win + \ No newline at end of file diff --git a/test/system/reproducibleCompare/reproducible.mk b/test/system/reproducibleCompare/reproducible.mk index ed058b386..3c901fff6 100644 --- a/test/system/reproducibleCompare/reproducible.mk +++ b/test/system/reproducibleCompare/reproducible.mk @@ -15,6 +15,11 @@ ifndef SBOM_FILE SBOM_FILE := $(shell ls $(TEST_ROOT)/../jdkbinary/ | grep "sbom" | grep -v "metadata") SBOM_FILE := $(TEST_ROOT)/../jdkbinary/$(SBOM_FILE) endif +ifndef JDK_FILE + ifneq (,$(findstring win,$(SPEC))) + JDK_FILE := $(shell find $(TEST_ROOT)/../jdkbinary/ -type f -name '*-jdk_*.zip') + endif +endif ifneq (,$(findstring linux,$(SPEC))) SBOM_FILE := $(subst $(TEST_ROOT)/../jdkbinary,/home/jenkins/test,$(SBOM_FILE)) diff --git a/tooling/reproducible/repro_common.sh b/tooling/reproducible/repro_common.sh index c83f03617..2eb440b9a 100755 --- a/tooling/reproducible/repro_common.sh +++ b/tooling/reproducible/repro_common.sh @@ -210,6 +210,17 @@ function processModuleInfo() { fi } +# Remove windowns generate classes jdk/bin/server/classes.jsa & jdk/bin/server/classes_nocoops.jsa +function removeGeneratedClasses() { + local JDK_DIR="$1" + local OS="$2" + + if [[ "$OS" =~ CYGWIN* ]]; then + rm -rf "$JDK_DIR/bin/server/classes.jsa" + rm -rf "$JDK_DIR/bin/server/classes_nocoops.jsa" + fi +} + # Remove all Signatures function removeSignatures() { local JDK_DIR="$1" diff --git a/tooling/reproducible/repro_compare.sh b/tooling/reproducible/repro_compare.sh index 2b82f3d2b..69bc1f529 100755 --- a/tooling/reproducible/repro_compare.sh +++ b/tooling/reproducible/repro_compare.sh @@ -53,7 +53,7 @@ done files1=$(find "${JDK_DIR1}" -type f | wc -l) echo "Number of files: ${files1}" rc=0 -output="repro_diff.out" +output="reprotest.diff" echo "Comparing ${JDK_DIR1} with ${JDK_DIR2} ... output to file: ${output}" diff -r -q "${JDK_DIR1}" "${JDK_DIR2}" > "${output}" || rc=$? diff --git a/tooling/reproducible/repro_process.sh b/tooling/reproducible/repro_process.sh index c83219641..d63373cae 100755 --- a/tooling/reproducible/repro_process.sh +++ b/tooling/reproducible/repro_process.sh @@ -23,8 +23,9 @@ OS="$2" expandJDK "$JDK_DIR" "$OS" - +removeGeneratedClasses "$JDK_DIR" "$OS" if [[ "$OS" =~ CYGWIN* ]] || [[ "$OS" =~ Darwin* ]]; then + # Remove existing signature removeSignatures "$JDK_DIR" "$OS" diff --git a/tooling/reproducible/windows_repro_build_compare.sh b/tooling/reproducible/windows_repro_build_compare.sh old mode 100644 new mode 100755 index 41ecc2c92..b4a9942ed --- a/tooling/reproducible/windows_repro_build_compare.sh +++ b/tooling/reproducible/windows_repro_build_compare.sh @@ -34,12 +34,12 @@ fi # Read Parameters SBOM_URL="$1" TARBALL_URL="$2" +REPORT_DIR="$3" # Constants Required By This Script # These Values Should Be Updated To Reflect The Build Environment # The Defaults Below Are Suitable For An Adoptium Windows Build Environment # Which Has Been Created Via The Ansible Infrastructure Playbooks - WORK_DIR="/cygdrive/c/comp-jdk-build" ANT_VERSION="1.10.5" ANT_CONTRIB_VERSION="1.0b3" @@ -62,8 +62,8 @@ NOTUSE_ARGS=("--assemble-exploded-image" "--configure-args") # Addiitonal Working Variables Defined For Use By This Script SBOMLocalPath="$WORK_DIR/src_sbom.json" DISTLocalPath="$WORK_DIR/src_jdk_dist.zip" -ScriptPath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - +ScriptPath=$(dirname "$(realpath "$0")") +rc=0 # Function to check if a string is a valid URL is_url() { local url=$1 @@ -172,9 +172,6 @@ Install_PreReqs() { apt-cyg install jq libjq1 libonig5 fi fi - - # Install JQ Where Not Already Installed - } Get_SBOM_Values() { @@ -203,7 +200,7 @@ Get_SBOM_Values() { msvsCCompiler=$(echo "$sbomContent" | jq -r '.metadata.tools[] | select(.name == "MSVS C Compiler Version").version') msvsCppCompiler=$(echo "$sbomContent" | jq -r '.metadata.tools[] | select(.name == "MSVS C++ Compiler Version").version') msvsSDKver=$(echo "$sbomContent" | jq -r '.metadata.tools[] | select(.name == "MS Windows SDK Version").version') - bootJDK=$(echo "$sbomContent" | jq -r '.metadata.tools[] | select(.name == "BOOTJDK").version') + bootJDK=$(echo "$sbomContent" | jq -r '.metadata.tools[] | select(.name == "BOOTJDK").version' | sed -e 's#-LTS$##') buildArch=$(echo "$sbomContent" | jq -r '.metadata.properties[] | select(.name == "OS architecture").value') buildSHA=$(echo "$sbomContent" | jq -r '.components[0].properties[] | select(.name == "Temurin Build Ref").value' | awk -F'/' '{print $NF}') buildStamp=$(echo "$sbomContent" | jq -r '.components[0].properties[] | select(.name == "Build Timestamp").value') @@ -557,13 +554,13 @@ Clone_Build_Repo() { Prepare_Env_For_Build() { echo "Setting Variables" export BOOTJDK_HOME=$WORK_DIR/jdk-${bootJDK} - echo "Parsing Make JDK Any Platform ARGS For Build" # Split the string into an array of words IFS=' ' read -ra words <<< "$buildArgs" # Add The Build Time Stamp In Case It Wasnt In The SBOM ARGS - words+=( "--build-reproducible-date \"$buildStamp\"" ) + words+=("--build-reproducible-date") + words+=("\"$buildStamp\"") # Initialize variables param="" @@ -582,12 +579,12 @@ Prepare_Env_For_Build() { param="$word" value="" else - value+=" $word" + value+="$word " fi done - + # Add the last parameter to the array - params+=("$param = $value") + params+=("$param=$value") # Read the separated parameters and values into a new array export fixed_param="" @@ -604,16 +601,12 @@ Prepare_Env_For_Build() { fixed_param="${prefixed_param%%[[:space:]]}" prepped_value=${parts[1]} fixed_value=$(echo "$prepped_value" | awk '{$1=$1};1') - # Handle Special parameters - if [ "$fixed_param" == "-b" ]; then fixed_value="$fixed_value " ; fi - if [ "$fixed_param" == "--jdk-boot-dir" ]; then fixed_value="$BOOTJDK_HOME " ; fi - if [ "$fixed_param" == "--freetype-dir" ]; then fixed_value="$fixed_value " ; fi - if [ "$fixed_param" == "--with-toolchain-version" ]; then fixed_value="$visualStudioVersion " ; fi + if [ "$fixed_param" == "--jdk-boot-dir" ]; then fixed_value="$BOOTJDK_HOME" ; fi + if [ "$fixed_param" == "--with-toolchain-version" ]; then fixed_value="$visualStudioVersion" ; fi if [ "$fixed_param" == "--with-ucrt-dll-dir" ]; then fixed_value="temporary_speech_mark_placeholder${UCRT_PARAM_PATH}temporary_speech_mark_placeholder " ; fi - if [ "$fixed_param" == "--target-file-name" ]; then target_file="$fixed_value" ; fixed_value="$fixed_value " ; fi - if [ "$fixed_param" == "--tag" ]; then fixed_value="$fixed_value " ; fi - + if [ "$fixed_param" == "--target-file-name" ]; then target_file="$fixed_value" ; fi + if [ "$fixed_param" == "--user-openjdk-build-root-directory" ]; then fixed_value="$WORK_DIR/temurin-build/workspace/build/openjdkbuild" ; fi # Fix Build Variant Parameter To Strip JDK Version @@ -654,15 +647,9 @@ Prepare_Env_For_Build() { fi done - for element in "${BUILD_ARRAY[@]}"; do - build_string+="$element" - done - - for element in "${CONFIG_ARRAY[@]}"; do - config_string+="$element" - done - - final_params="$build_string--configure-args \"$config_string\" $jdk" + IFS=' ' build_string="${BUILD_ARRAY[*]}" + IFS=' ' config_string=$"${CONFIG_ARRAY[*]}" + final_params="$build_string --configure-args \"$config_string\" $jdk" echo "Make JDK Any Platform Argument List = " echo "$final_params" @@ -677,23 +664,14 @@ Build_JDK() { cd "$WORK_DIR" echo "cd temurin-build && ./makejdk-any-platform.sh $final_params 2>&1 | tee build.$$.log" | sh # Copy The Built JDK To The Working Directory - cp "$WORK_DIR/temurin-build/workspace/target/$target_file" "$WORK_DIR/built_jdk.zip" + cp "$WORK_DIR/temurin-build/workspace/target/$target_file" "$WORK_DIR/reproJDK.zip" } Compare_JDK() { echo "Comparing JDKs" - echo "" mkdir "$WORK_DIR/compare" cp "$WORK_DIR/src_jdk_dist.zip" "$WORK_DIR/compare" - cp "$WORK_DIR/built_jdk.zip" "$WORK_DIR/compare" - - # Get The Current Versions Of The Reproducible Build Scripts - wget -O "$WORK_DIR/compare/repro_common.sh" "https://raw.githubusercontent.com/adoptium/temurin-build/master/tooling/reproducible/repro_common.sh" - wget -O "$WORK_DIR/compare/repro_compare.sh" "https://raw.githubusercontent.com/adoptium/temurin-build/master/tooling/reproducible/repro_compare.sh" - wget -O "$WORK_DIR/compare/repro_process.sh" "https://raw.githubusercontent.com/adoptium/temurin-build/master/tooling/reproducible/repro_process.sh" - - # Set Permissions - chmod +x "$WORK_DIR/compare/"*sh + cp "$WORK_DIR/reproJDK.zip" "$WORK_DIR/compare" cd "$WORK_DIR/compare" # Unzip And Rename The Source JDK @@ -704,29 +682,10 @@ Compare_JDK() { #Unzip And Rename The Target JDK echo "Unzip Target" - unzip -q -o built_jdk.zip + unzip -q -o reproJDK.zip original_directory_name=$(find . -maxdepth 1 -type d | grep -v src_jdk | tail -1) mv "$original_directory_name" tar_jdk - # These Two Files Are Generate Classes And Should Be Removed Prior To Running The Comparison - # jdk/bin/server/classes.jsa & jdk/bin/server/classes_nocoops.jsa - - if [ -f "$WORK_DIR/compare/src_jdk/bin/server/classes.jsa" ] ; then - rm -rf "$WORK_DIR/compare/src_jdk/bin/server/classes.jsa" - fi - - if [ -f "$WORK_DIR/compare/tar_jdk/bin/server/classes.jsa" ] ; then - rm -rf "$WORK_DIR/compare/tar_jdk/bin/server/classes.jsa" - fi - - if [ -f "$WORK_DIR/compare/src_jdk/bin/server/classes_nocoops.jsa" ] ; then - rm -rf "$WORK_DIR/compare/src_jdk/bin/server/classes_nocoops.jsa" - fi - - if [ -f "$WORK_DIR/compare/tar_jdk/bin/server/classes_nocoops.jsa" ] ; then - rm -rf "$WORK_DIR/compare/tar_jdk/bin/server/classes_nocoops.jsa" - fi - # Ensure Signtool Is In The Path TOOLCOUNT=$(find "$SIGNTOOL_BASE" | grep $msvsArch | grep -ic "signtool.exe$") @@ -760,20 +719,29 @@ Compare_JDK() { export PATH="$PATH:$CPW" # Run Comparison Script - echo "cd $WORK_DIR/compare && ./repro_compare.sh temurin src_jdk temurin tar_jdk CYGWIN 2>&1" | sh & - wait + set +e + cd "$ScriptPath" || exit 1 + ./repro_compare.sh temurin $WORK_DIR/compare/src_jdk temurin $WORK_DIR/compare/tar_jdk CYGWIN 2>&1 & + pid=$! + wait $pid - # Display The Content Of repro_diff.out + rc=$? + set -e + cd "$WORK_DIR" + # Display The Content Of reprotest.diff echo "" echo "---------------------------------------------" echo "Output From JDK Comparison Script" echo "---------------------------------------------" - cat "$WORK_DIR/compare/repro_diff.out" + cat "$ScriptPath/reprotest.diff" echo "" echo "---------------------------------------------" - echo "Copying Output To $(dirname "$0")" - cp "$WORK_DIR/compare/repro_diff.out" "$ScriptPath" + if [ -n "$REPORT_DIR" ]; then + echo "Copying Output To $REPORT_DIR" + cp "$ScriptPath/reprotest.diff" "$REPORT_DIR" + cp "$WORK_DIR/reproJDK.zip" "$REPORT_DIR" + fi } Clean_Up_Everything() { @@ -829,3 +797,4 @@ echo "---------------------------------------------" Compare_JDK echo "---------------------------------------------" Clean_Up_Everything +exit $rc