From 96189f5df736ebcca2048309fe84a733de1c0233 Mon Sep 17 00:00:00 2001 From: Sophia Guo Date: Thu, 10 Oct 2024 10:36:09 -0400 Subject: [PATCH 1/5] aarch64 mac --- test/system/reproducibleCompare/build.xml | 1 + test/system/reproducibleCompare/playlist.xml | 21 ++ .../reproducibleCompare/reproducible.mk | 1 + .../reproducible/macos_repro_build_compare.sh | 217 ++++-------------- tooling/reproducible/repro_common.sh | 12 +- tooling/reproducible/repro_compare.sh | 6 +- tooling/reproducible/repro_process.sh | 2 +- 7 files changed, 75 insertions(+), 185 deletions(-) diff --git a/test/system/reproducibleCompare/build.xml b/test/system/reproducibleCompare/build.xml index 015fbacad..75db0f1d9 100644 --- a/test/system/reproducibleCompare/build.xml +++ b/test/system/reproducibleCompare/build.xml @@ -65,6 +65,7 @@ + diff --git a/test/system/reproducibleCompare/playlist.xml b/test/system/reproducibleCompare/playlist.xml index c3c61ba26..9fd60ce40 100644 --- a/test/system/reproducibleCompare/playlist.xml +++ b/test/system/reproducibleCompare/playlist.xml @@ -60,4 +60,25 @@ os.win + + Rebuild_Same_JDK_Reproducibility_Test_Mac + unset SPEC;\ + ls -l $(TEST_ROOT)$(D)system$(D)reproducibleCompare$(D);\ + $(TEST_ROOT)$(D)system$(D)reproducibleCompare$(D)macos_repro_build_compare.sh $(SBOM_FILE) $(JDK_FILE) $(REPORTDIR); \ + $(TEST_STATUS) + + + dev + + + system + + + eclipse + + + 21+ + + os.osx,arch.aarch64 + \ No newline at end of file diff --git a/test/system/reproducibleCompare/reproducible.mk b/test/system/reproducibleCompare/reproducible.mk index 34b3b0342..e6fbfb2a1 100644 --- a/test/system/reproducibleCompare/reproducible.mk +++ b/test/system/reproducibleCompare/reproducible.mk @@ -16,6 +16,7 @@ ifndef SBOM_FILE SBOM_FILE := $(TEST_ROOT)/../jdkbinary/$(SBOM_FILE) endif ifndef JDK_FILE + JDK_FILE := $(shell find $(TEST_ROOT)/../jdkbinary/ -type f -name '*-jdk_*.tar.gz') ifneq (,$(findstring win,$(SPEC))) JDK_FILE := $(shell find $(TEST_ROOT)/../jdkbinary/ -type f -name '*-jdk_*.zip') endif diff --git a/tooling/reproducible/macos_repro_build_compare.sh b/tooling/reproducible/macos_repro_build_compare.sh index edf0f7562..ffbe45433 100755 --- a/tooling/reproducible/macos_repro_build_compare.sh +++ b/tooling/reproducible/macos_repro_build_compare.sh @@ -46,16 +46,11 @@ REPORT_DIR="$3" # The Defaults Below Are Suitable For An Adoptium Mac OS X Build Environment # Which Has Been Created Via The Ansible Infrastructure Playbooks -WORK_DIR=~/comp-jdk-build +WORK_DIR=$(realpath "$(dirname "$0")")/comp-jdk-build MAC_COMPILER_BASE=/Applications MAC_COMPILER_APP_PREFIX=Xcode MAC_SDK_LOCATION=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -# These 3 variables dictate which parameters passed to makejdk_any_platform.sh are config arguments, build arguments or should be ignored. -CONFIG_ARGS=("--disable-warnings-as-errors" "--openjdk-target" "--with-sysroot" "--with-extra-cxxflags='" "--enable-dtrace" "--with-version-opt") -NOTUSE_ARGS=("--assemble-exploded-image" "--configure-args") -FINAL_ARG=("--build-variant") - # These variables relate to the pre-requisite ant installation ANT_VERSION="1.10.5" ANT_CONTRIB_VERSION="1.0b3" @@ -76,17 +71,6 @@ is_url() { fi } -# Function to check if a value is in the array -containsElement () { - local e - for e in "${@:2}"; do - if [ "$e" == "$1" ]; then - return 0 # Match found - fi - done - return 1 # No match found -} - Create_WorkDir() { # Check if the folder exists & remove if it does echo "Checking If Working Directory: $WORK_DIR Exists" @@ -371,13 +355,13 @@ Check_And_Install_Ant() { echo "Ant Doesnt Exist At The Correct Version - Installing" # Ant Version Not Found... Check And Create Paths echo Downloading ant for SBOM creation: - curl https://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.zip > $WORK_DIR/apache-ant-${ANT_VERSION}-bin.zip - (cd $WORK_DIR && unzip -qn ./apache-ant-${ANT_VERSION}-bin.zip) - rm $WORK_DIR/apache-ant-${ANT_VERSION}-bin.zip + curl https://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.zip > ${WORK_DIR}/apache-ant-${ANT_VERSION}-bin.zip + (cd "$WORK_DIR" && unzip -qn ./apache-ant-${ANT_VERSION}-bin.zip) + rm "$WORK_DIR"/apache-ant-${ANT_VERSION}-bin.zip echo Downloading ant-contrib-${ANT_CONTRIB_VERSION}: - curl -L https://sourceforge.net/projects/ant-contrib/files/ant-contrib/${ANT_CONTRIB_VERSION}/ant-contrib-${ANT_CONTRIB_VERSION}-bin.zip > $WORK_DIR/ant-contrib-${ANT_CONTRIB_VERSION}-bin.zip - (unzip -qnj $WORK_DIR/ant-contrib-${ANT_CONTRIB_VERSION}-bin.zip ant-contrib/ant-contrib-${ANT_CONTRIB_VERSION}.jar -d $WORK_DIR/apache-ant-${ANT_VERSION}/lib) - rm $WORK_DIR/ant-contrib-${ANT_CONTRIB_VERSION}-bin.zip + curl -L https://sourceforge.net/projects/ant-contrib/files/ant-contrib/${ANT_CONTRIB_VERSION}/ant-contrib-${ANT_CONTRIB_VERSION}-bin.zip > "$WORK_DIR"/ant-contrib-${ANT_CONTRIB_VERSION}-bin.zip + (unzip -qnj "$WORK_DIR"/ant-contrib-${ANT_CONTRIB_VERSION}-bin.zip ant-contrib/ant-contrib-${ANT_CONTRIB_VERSION}.jar -d "$WORK_DIR"/apache-ant-${ANT_VERSION}/lib) + rm "$WORK_DIR"/ant-contrib-${ANT_CONTRIB_VERSION}-bin.zip else echo "Ant Version: $ANT_VERSION Is Already Installed" fi @@ -441,118 +425,22 @@ Prepare_Env_For_Build() { echo "Setting Variables" export BOOTJDK_HOME=$WORK_DIR/jdk-${bootJDK}/Contents/Home - 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\"" ) - - # Initialize variables - param="" - value="" - params=() - - # Loop through the words - for word in "${words[@]}"; do - # Check if the word starts with '--' - if [[ $word == --* ]] || [[ $word == -b* ]]; then - # If a parameter already exists, store it in the params array - if [[ -n $param ]]; then - params+=("$param $value") - fi - # Reset variables for the new parameter - param="$word" - value="" - else - value+=" $word" - fi - done - - # Add the last parameter to the array - params+=("$param $value") - - # Loop Through The Parameters And Reformat Appropriately - export fixed_param="" - export fixed_value="" - export fixed_params=() - export new_params="" - CONFIG_ARRAY=() - BUILD_ARRAY=() - FINAL_ARRAY=() - for element in "${params[@]}"; do - IFS=' ' read -ra parts <<< "$element" - prepped_part0=${parts[0]} - prepped_part1=${parts[1]} - prepped_part2=${parts[2]} - - fixed_param="$prepped_part0" - fixed_value="$prepped_part1 $prepped_part2" - - # Handle Special Parameters ( overrides and = seperated ) - if [ "$fixed_param" == "--jdk-boot-dir" ]; then fixed_value=" $BOOTJDK_HOME " ; fi - if [[ "$fixed_param" == "--with-sysroot="* ]]; then - IFS='=' read -r split_param split_value <<< "$fixed_param" - fixed_param="$split_param" - fixed_value="=$MAC_SDK_LOCATION " ; - fi - if [[ "$fixed_param" == "--openjdk-target="* ]]; then - IFS='=' read -r split_param split_value <<< "$fixed_param" - fixed_param="$split_param" - fixed_value="=$split_value " - fi - if [[ "$fixed_param" == "--with-version-opt="* ]]; then - IFS='=' read -r split_param split_value <<< "$fixed_param" - fixed_param="$split_param" - fixed_value="=$split_value" - fi - if [ "$fixed_param" == "--tag" ]; then fixed_param="-b" fixed_value=" $fixed_value" ; fi - if [ "$fixed_param" == "--target-file-name" ]; then - target_file="$(echo -e "${fixed_value}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" - fixed_value=" $fixed_value" - fi - if [ "$fixed_param" == "--freetype-dir" ]; then fixed_value=" $fixed_value" ; fi - if [ "$fixed_param" == "--user-openjdk-build-root-directory" ]; then fixed_value=" $WORK_DIR/temurin-build/workspace/build/openjdkbuild/ " ; fi - if [ "$fixed_param" == "--build-variant" ]; then fixed_value=" $fixed_value " ; fi - if [ "$fixed_param" == "--build-reproducible-date" ]; then fixed_value=" $fixed_value" ; fi - - if containsElement "$fixed_param" "${CONFIG_ARGS[@]}"; then - # Check if fixed_param is in CONFIG_ARGS - STRINGTOADD="$fixed_param$fixed_value" - CONFIG_ARRAY+=("$STRINGTOADD") - elif containsElement "$fixed_param" "${NOTUSE_ARGS[@]}"; then - # Check if fixed_param is in NOTUSE_ARGS - STRINGTOADD="$fixed_param$fixed_value" - IGNORED_ARRAY+=("$STRINGTOADD") - elif containsElement "$fixed_param" "${FINAL_ARG[@]}"; then - # Check if parameter should be at the end, usually just version & variant - STRINGTOADD="$fixed_param$fixed_value" - FINAL_ARRAY+=("$STRINGTOADD") - else - # Neither Config Or Ignore, so Build - STRINGTOADD="$fixed_param$fixed_value" - BUILD_ARRAY+=("$STRINGTOADD") - fi - done - - # Construct Final Parameter String - for element in "${BUILD_ARRAY[@]}"; do - build_string+="$element" - done - - for element in "${CONFIG_ARRAY[@]}"; do - config_string+="$element" - done - - for element in "${FINAL_ARRAY[@]}"; do - final_string+="$element" - done - - final_params="$build_string --configure-args \"$config_string\" $final_string" + # set --build-reproducible-date if not yet + if [[ "${buildArgs}" != *"--build-reproducible-date"* ]]; then + buildArgs="--build-reproducible-date \"${buildStamp}\" ${buildArgs}" + fi + # reset --jdk-boot-dir + # shellcheck disable=SC2001 + buildArgs="$(echo "$buildArgs" | sed -e "s|--jdk-boot-dir [^ ]*|--jdk-boot-dir ${BOOTJDK_HOME}|")" + buildArgs="$(echo "$buildArgs" | sed -e "s|--with-sysroot=[^ ]*|--with-sysroot=${MAC_SDK_LOCATION}|")" + buildArgs="$(echo "$buildArgs" | sed -e "s|--user-openjdk-build-root-directory [^ ]*|--user-openjdk-build-root-directory ${WORK_DIR}/temurin-build/workspace/build/openjdkbuild/|")" + # remove ingored options + buildArgs=${buildArgs/--assemble-exploded-image /} + buildArgs=${buildArgs/--enable-sbom-strace /} -echo "" + echo "" echo "Make JDK Any Platform Argument List = " - echo "$final_params" + echo "$buildArgs" echo "" echo "Parameters Parsed Successfully" } @@ -562,79 +450,58 @@ Build_JDK() { # Trigger Build cd "$WORK_DIR" - echo "cd temurin-build && ./makejdk-any-platform.sh $final_params 2>&1 | tee build.$$.log" | sh + echo "cd temurin-build && ./makejdk-any-platform.sh $buildArgs 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/reproJDK.tar.gz + cp "$WORK_DIR"/temurin-build/workspace/target/OpenJDK*-jdk_*tar.gz $WORK_DIR/reproJDK.tar.gz } Compare_JDK() { echo "Comparing JDKs" echo "" mkdir "$WORK_DIR/compare" - cp $WORK_DIR/src_jdk_dist.tar.gz $WORK_DIR/compare - cp $WORK_DIR/reproJDK.tar.gz $WORK_DIR/compare - - - # Check The Comparison Scripts Are Present And Copy To The Working Directory + cp "$WORK_DIR"/src_jdk_dist.tar.gz "$WORK_DIR"/compare + cp "$WORK_DIR"/reproJDK.tar.gz "$WORK_DIR"/compare + cp "$(dirname "$0")"/repro_*.sh "$WORK_DIR"/compare/ - if [ -f ./repro_common.sh ]; then - cp ./repro_common.sh $WORK_DIR/compare/repro_common.sh - else - wget -O "$WORK_DIR/compare/repro_common.sh" "https://raw.githubusercontent.com/adoptium/temurin-build/master/tooling/reproducible/repro_common.sh" - fi - if [ -f ./repro_compare.sh ]; then - cp ./repro_compare.sh $WORK_DIR/compare/repro_compare.sh - else - wget -O "$WORK_DIR/compare/repro_compare.sh" "https://raw.githubusercontent.com/adoptium/temurin-build/master/tooling/reproducible/repro_compare.sh" - fi - if [ -f ./repro_process.sh ]; then - cp ./repro_process.sh $WORK_DIR/compare/repro_process.sh - else - wget -O "$WORK_DIR/compare/repro_process.sh" "https://raw.githubusercontent.com/adoptium/temurin-build/master/tooling/reproducible/repro_process.sh" - fi - # Set Permissions chmod +x "$WORK_DIR/compare/"*sh cd "$WORK_DIR/compare" # Unzip And Rename The Source JDK echo "Unzip Source" - tar xvfz src_jdk_dist.tar.gz + tar xfz src_jdk_dist.tar.gz original_directory_name=$(find . -maxdepth 1 -type d | tail -1) mv "$original_directory_name" src_jdk #Unzip And Rename The Target JDK echo "Unzip Target" - tar xvfz reproJDK.tar.gz + tar xfz reproJDK.tar.gz original_directory_name=$(find . -maxdepth 1 -type d | grep -v src_jdk | tail -1) mv "$original_directory_name" tar_jdk # Ensure Java Home Is Set export JAVA_HOME=$BOOTJDK_HOME export PATH=$JAVA_HOME/bin:$PATH - echo "cd $WORK_DIR/compare && ./repro_compare.sh temurin src_jdk/Contents/Home temurin tar_jdk/Contents/Home Darwin 2>&1" | sh & - wait - rc=$? - set -e + rc=0 + ./repro_compare.sh temurin src_jdk/Contents/Home temurin tar_jdk/Contents/Home Darwin 2>&1 || rc=$? cd "$WORK_DIR" - # Display The Content Of reprotest.diff - echo "" - echo "---------------------------------------------" - echo "Output From JDK Comparison Script" - echo "---------------------------------------------" - cat $WORK_DIR/compare/reprotest.diff - echo "" - echo "---------------------------------------------" - echo "Copying Output To $(dirname "$0")" - cp $WORK_DIR/compare/reprotest.diff $WORK_DIR/reprotest.diff - + + if [ $rc -eq 0 ]; then + echo "Compare identical !" + else + echo "Differences found..., logged in: reprotest.diff" + fi + if [ -n "$REPORT_DIR" ]; then echo "Copying Output To $REPORT_DIR" - cp $WORK_DIR/compare/reprotest.diff "$REPORT_DIR" - cp $WORK_DIR/reproJDK.tar.gz "$REPORT_DIR" + cp "$WORK_DIR"/compare/reprotest.diff "$REPORT_DIR" + cp "$WORK_DIR"/reproJDK.tar.gz "$REPORT_DIR" fi + exit $rc + } + # Clean_Up_Everything() { # Remove Working Directorys diff --git a/tooling/reproducible/repro_common.sh b/tooling/reproducible/repro_common.sh index 8f7ca2942..d6a6d317a 100755 --- a/tooling/reproducible/repro_common.sh +++ b/tooling/reproducible/repro_common.sh @@ -89,8 +89,8 @@ function removeSystemModulesHashBuilderParams() { moduleHashesFunction="// Method jdk/internal/module/ModuleHashes\$Builder.hashForModule:(Ljava/lang/String;[B)Ljdk/internal/module/ModuleHashes\$Builder;" moduleString="// String " virtualFunction="invokevirtual" - local JDK_DIR="$1" systemModules="SystemModules\$0.class SystemModules\$all.class SystemModules\$default.class" + local JDK_DIR="$1" for systemModule in $systemModules do FILES=$(find "${JDK_DIR}" -type f -name "$systemModule") @@ -101,11 +101,11 @@ function removeSystemModulesHashBuilderParams() { else ff=$f fi - javap -v -sysinfo -l -p -c -s -constants "$ff" > "$f.javap.tmp" + "${JDK_DIR}"/bin/javap -v -sysinfo -l -p -c -s -constants "$ff" > "$f.javap.tmp" rm "$f" # Remove "instruction number:" prefix, so we can just match code - if [[ $(uname) =~ Darwin* ]]; then + if [[ "$OS" =~ Darwin* ]]; then sed -i "" -E 's/^[[:space:]]+[0-9]+:(.*)/\1/' "$f.javap.tmp" else sed -i -E 's/^[[:space:]]+[0-9]+:(.*)/\1/' "$f.javap.tmp" @@ -153,7 +153,6 @@ function removeSystemModulesHashBuilderParams() { # reprohex - A hex UUID to identify the binary version, again generated from binary content function removeWindowsNonComparableData() { echo "Removing EXE/DLL timestamps, CRC and debug repro hex from ${JDK_DIR}" - # We need to do this for all executables if patching VS_VERSION_INFO if [[ "$PATCH_VS_VERSION_INFO" = true ]]; then FILES=$(find "${JDK_DIR}" -type f -path '*.exe' && find "${JDK_DIR}" -type f -path '*.dll') @@ -223,7 +222,7 @@ function removeWindowsNonComparableData() { # See https://github.com/adoptium/temurin-build/issues/2899#issuecomment-1153757419 function removeMacOSNonComparableData() { echo "Removing MacOS dylib non-comparable UUID from ${JDK_DIR}" - + MAC_JDK_ROOT="${JDK_DIR}/../../Contents" 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 @@ -251,6 +250,7 @@ function removeMacOSNonComparableData() { # java.base also requires the dependent module "hash:" values to be excluded # as they differ due to the Signatures function processModuleInfo() { + echo "process Module Info from ${JDK_DIR}" if [[ "$OS" =~ CYGWIN* ]] || [[ "$OS" =~ Darwin* ]]; then echo "Normalizing ModuleAttributes order in module-info.class, converting to javap" @@ -264,7 +264,7 @@ function processModuleInfo() { else ff=$f fi - javap -v -sysinfo -l -p -c -s -constants "$ff" > "$f.javap.tmp" + "${JDK_DIR}"/bin/javap -v -sysinfo -l -p -c -s -constants "$ff" > "$f.javap.tmp" rm "$f" cc=99 diff --git a/tooling/reproducible/repro_compare.sh b/tooling/reproducible/repro_compare.sh index dd707fa87..691b8de24 100755 --- a/tooling/reproducible/repro_compare.sh +++ b/tooling/reproducible/repro_compare.sh @@ -13,7 +13,7 @@ # ******************************************************************************** # shellcheck disable=SC1091 -source repro_common.sh +source $(dirname "$0")/repro_common.sh BLD_TYPE1="$1" JDK_DIR1="$2" @@ -32,7 +32,7 @@ do echo "Pre-processing ${JDK_DIR}" rc=0 - source ./repro_process.sh "${JDK_DIR}" "${OS}" || rc=$? + source $(dirname "$0")/repro_process.sh "${JDK_DIR}" "${OS}" || rc=$? if [ $rc != 0 ]; then echo "Pre-process of ${JDK_DIR} ${OS} failed" exit 1 @@ -46,7 +46,7 @@ do cleanTemurinBuildInfo "${JDK_DIR}" if [[ "$OS" =~ CYGWIN* ]] || [[ "$OS" =~ Darwin* ]]; then - removeSystemModulesHashBuilderParams "${JDK_DIR}" + removeSystemModulesHashBuilderParams "${JDK_DIR}" "${OS}" fi processModuleInfo done diff --git a/tooling/reproducible/repro_process.sh b/tooling/reproducible/repro_process.sh index 92b246f2a..7dbbe6ed4 100755 --- a/tooling/reproducible/repro_process.sh +++ b/tooling/reproducible/repro_process.sh @@ -13,7 +13,7 @@ # ******************************************************************************** # shellcheck disable=SC1091 -source repro_common.sh +source $(dirname "$0")/repro_common.sh JDK_DIR="$1" OS="$2" From 06d39b17bbde28f28748e340e0a6f2aeabfcab83 Mon Sep 17 00:00:00 2001 From: Sophia Guo Date: Thu, 10 Oct 2024 11:42:54 -0400 Subject: [PATCH 2/5] update javap path --- tooling/reproducible/repro_common.sh | 9 +++++++-- tooling/reproducible/repro_compare.sh | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/tooling/reproducible/repro_common.sh b/tooling/reproducible/repro_common.sh index d6a6d317a..0d247ad80 100755 --- a/tooling/reproducible/repro_common.sh +++ b/tooling/reproducible/repro_common.sh @@ -91,6 +91,8 @@ function removeSystemModulesHashBuilderParams() { virtualFunction="invokevirtual" systemModules="SystemModules\$0.class SystemModules\$all.class SystemModules\$default.class" local JDK_DIR="$1" + local OS="$2" + local work_JDK="$3" for systemModule in $systemModules do FILES=$(find "${JDK_DIR}" -type f -name "$systemModule") @@ -101,7 +103,7 @@ function removeSystemModulesHashBuilderParams() { else ff=$f fi - "${JDK_DIR}"/bin/javap -v -sysinfo -l -p -c -s -constants "$ff" > "$f.javap.tmp" + "${work_JDK}"/bin/javap -v -sysinfo -l -p -c -s -constants "$ff" > "$f.javap.tmp" rm "$f" # Remove "instruction number:" prefix, so we can just match code @@ -250,6 +252,9 @@ function removeMacOSNonComparableData() { # java.base also requires the dependent module "hash:" values to be excluded # as they differ due to the Signatures function processModuleInfo() { + local JDK_DIR="$1" + local OS="$2" + local work_JDK="$3" echo "process Module Info from ${JDK_DIR}" if [[ "$OS" =~ CYGWIN* ]] || [[ "$OS" =~ Darwin* ]]; then echo "Normalizing ModuleAttributes order in module-info.class, converting to javap" @@ -264,7 +269,7 @@ function processModuleInfo() { else ff=$f fi - "${JDK_DIR}"/bin/javap -v -sysinfo -l -p -c -s -constants "$ff" > "$f.javap.tmp" + "${work_JDK}"/bin/javap -v -sysinfo -l -p -c -s -constants "$ff" > "$f.javap.tmp" rm "$f" cc=99 diff --git a/tooling/reproducible/repro_compare.sh b/tooling/reproducible/repro_compare.sh index 691b8de24..459256e8d 100755 --- a/tooling/reproducible/repro_compare.sh +++ b/tooling/reproducible/repro_compare.sh @@ -21,6 +21,10 @@ BLD_TYPE2="$3" JDK_DIR2="$4" OS="$5" +mkdir "${JDK_DIR}_BK" +cp -R "${JDK_DIR1}"/* "${JDK_DIR}"_BK +BK_JDK_DIR=$(realpath "${JDK_DIR}"_BK/) + JDK_DIR_Arr=("${JDK_DIR1}" "${JDK_DIR2}") for JDK_DIR in "${JDK_DIR_Arr[@]}" do @@ -46,9 +50,9 @@ do cleanTemurinBuildInfo "${JDK_DIR}" if [[ "$OS" =~ CYGWIN* ]] || [[ "$OS" =~ Darwin* ]]; then - removeSystemModulesHashBuilderParams "${JDK_DIR}" "${OS}" + removeSystemModulesHashBuilderParams "${JDK_DIR}" "${OS}" "${BK_JDK_DIR}" fi - processModuleInfo + processModuleInfo "${JDK_DIR}" "${OS}" "${BK_JDK_DIR}" done From 02bcd402ad1323d0b312e0c50991df40ecb07913 Mon Sep 17 00:00:00 2001 From: Sophia Guo Date: Thu, 10 Oct 2024 12:31:30 -0400 Subject: [PATCH 3/5] cleanup --- tooling/reproducible/macos_repro_build_compare.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tooling/reproducible/macos_repro_build_compare.sh b/tooling/reproducible/macos_repro_build_compare.sh index ffbe45433..bf5320d96 100755 --- a/tooling/reproducible/macos_repro_build_compare.sh +++ b/tooling/reproducible/macos_repro_build_compare.sh @@ -355,7 +355,7 @@ Check_And_Install_Ant() { echo "Ant Doesnt Exist At The Correct Version - Installing" # Ant Version Not Found... Check And Create Paths echo Downloading ant for SBOM creation: - curl https://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.zip > ${WORK_DIR}/apache-ant-${ANT_VERSION}-bin.zip + curl https://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.zip > "${WORK_DIR}"/apache-ant-${ANT_VERSION}-bin.zip (cd "$WORK_DIR" && unzip -qn ./apache-ant-${ANT_VERSION}-bin.zip) rm "$WORK_DIR"/apache-ant-${ANT_VERSION}-bin.zip echo Downloading ant-contrib-${ANT_CONTRIB_VERSION}: @@ -452,7 +452,7 @@ Build_JDK() { cd "$WORK_DIR" echo "cd temurin-build && ./makejdk-any-platform.sh $buildArgs 2>&1 | tee build.$$.log" | sh # Copy The Built JDK To The Working Directory - cp "$WORK_DIR"/temurin-build/workspace/target/OpenJDK*-jdk_*tar.gz $WORK_DIR/reproJDK.tar.gz + cp "$WORK_DIR"/temurin-build/workspace/target/OpenJDK*-jdk_*tar.gz "$WORK_DIR"/reproJDK.tar.gz } Compare_JDK() { @@ -497,9 +497,8 @@ Compare_JDK() { cp "$WORK_DIR"/compare/reprotest.diff "$REPORT_DIR" cp "$WORK_DIR"/reproJDK.tar.gz "$REPORT_DIR" fi - - exit $rc - + Clean_Up_Everything + exit $rc } # @@ -541,6 +540,3 @@ echo "---------------------------------------------" Build_JDK echo "---------------------------------------------" Compare_JDK -echo "---------------------------------------------" -Clean_Up_Everything -exit $rc From 48acf8d0783003dc4d85459cd48385b56345fd46 Mon Sep 17 00:00:00 2001 From: Sophia Guo Date: Thu, 10 Oct 2024 12:40:18 -0400 Subject: [PATCH 4/5] linter issue --- tooling/reproducible/macos_repro_build_compare.sh | 2 ++ tooling/reproducible/repro_compare.sh | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tooling/reproducible/macos_repro_build_compare.sh b/tooling/reproducible/macos_repro_build_compare.sh index bf5320d96..4831c76c5 100755 --- a/tooling/reproducible/macos_repro_build_compare.sh +++ b/tooling/reproducible/macos_repro_build_compare.sh @@ -432,7 +432,9 @@ Prepare_Env_For_Build() { # reset --jdk-boot-dir # shellcheck disable=SC2001 buildArgs="$(echo "$buildArgs" | sed -e "s|--jdk-boot-dir [^ ]*|--jdk-boot-dir ${BOOTJDK_HOME}|")" + # shellcheck disable=SC2001 buildArgs="$(echo "$buildArgs" | sed -e "s|--with-sysroot=[^ ]*|--with-sysroot=${MAC_SDK_LOCATION}|")" + # shellcheck disable=SC2001 buildArgs="$(echo "$buildArgs" | sed -e "s|--user-openjdk-build-root-directory [^ ]*|--user-openjdk-build-root-directory ${WORK_DIR}/temurin-build/workspace/build/openjdkbuild/|")" # remove ingored options buildArgs=${buildArgs/--assemble-exploded-image /} diff --git a/tooling/reproducible/repro_compare.sh b/tooling/reproducible/repro_compare.sh index 459256e8d..18743f7e9 100755 --- a/tooling/reproducible/repro_compare.sh +++ b/tooling/reproducible/repro_compare.sh @@ -13,7 +13,7 @@ # ******************************************************************************** # shellcheck disable=SC1091 -source $(dirname "$0")/repro_common.sh +source "$(dirname "$0")"/repro_common.sh BLD_TYPE1="$1" JDK_DIR1="$2" @@ -36,7 +36,7 @@ do echo "Pre-processing ${JDK_DIR}" rc=0 - source $(dirname "$0")/repro_process.sh "${JDK_DIR}" "${OS}" || rc=$? + source "$(dirname "$0")"/repro_process.sh "${JDK_DIR}" "${OS}" || rc=$? if [ $rc != 0 ]; then echo "Pre-process of ${JDK_DIR} ${OS} failed" exit 1 From a8307017222a62b771daaa3d5e5a8f008bbaf673 Mon Sep 17 00:00:00 2001 From: Sophia Guo Date: Thu, 10 Oct 2024 12:54:29 -0400 Subject: [PATCH 5/5] update --- tooling/reproducible/repro_common.sh | 134 ++++++++++++-------------- tooling/reproducible/repro_compare.sh | 3 +- tooling/reproducible/repro_process.sh | 2 +- 3 files changed, 65 insertions(+), 74 deletions(-) diff --git a/tooling/reproducible/repro_common.sh b/tooling/reproducible/repro_common.sh index 0d247ad80..5648fef81 100755 --- a/tooling/reproducible/repro_common.sh +++ b/tooling/reproducible/repro_common.sh @@ -98,14 +98,12 @@ function removeSystemModulesHashBuilderParams() { FILES=$(find "${JDK_DIR}" -type f -name "$systemModule") for f in $FILES do + ff=$f if [[ "$OS" =~ CYGWIN* ]]; then ff=$(cygpath -w $f) - else - ff=$f fi "${work_JDK}"/bin/javap -v -sysinfo -l -p -c -s -constants "$ff" > "$f.javap.tmp" - rm "$f" - + # Remove "instruction number:" prefix, so we can just match code if [[ "$OS" =~ Darwin* ]]; then sed -i "" -E 's/^[[:space:]]+[0-9]+:(.*)/\1/' "$f.javap.tmp" @@ -139,6 +137,7 @@ function removeSystemModulesHashBuilderParams() { rm "$f.javap.tmp" grep -v "Last modified\|Classfile\|SHA-256 checksum" "$f.javap.tmp2" > "$f.javap" rm "$f.javap.tmp2" + rm "$f" done done @@ -256,80 +255,73 @@ function processModuleInfo() { local OS="$2" local work_JDK="$3" echo "process Module Info from ${JDK_DIR}" - if [[ "$OS" =~ CYGWIN* ]] || [[ "$OS" =~ Darwin* ]]; then - echo "Normalizing ModuleAttributes order in module-info.class, converting to javap" - - moduleAttr="ModuleResolution ModuleTarget" + echo "Normalizing ModuleAttributes order in module-info.class, converting to javap" + moduleAttr="ModuleResolution ModuleTarget" + FILES=$(find "${JDK_DIR}" -type f -name "module-info.class") + for f in $FILES + do + ff=$f + if [[ "$OS" =~ CYGWIN* ]]; then + ff=$(cygpath -w $f) + fi + "${work_JDK}"/bin/javap -v -sysinfo -l -p -c -s -constants "$ff" > "$f.javap.tmp" + cc=99 + foundAttr=false + attrName="" + # Clear any attr tmp files + for attr in $moduleAttr + do + rm -f "$f.javap.$attr" + done - FILES=$(find "${JDK_DIR}" -type f -name "module-info.class") - for f in $FILES + while IFS= read -r line do - if [[ "$OS" =~ CYGWIN* ]]; then - ff=$(cygpath -w $f) - else - ff=$f + cc=$((cc+1)) + + # Module attr have only 1 line definition + if [[ "$foundAttr" = true ]] && [[ "$cc" -gt 1 ]]; then + foundAttr=false + attrName="" fi - "${work_JDK}"/bin/javap -v -sysinfo -l -p -c -s -constants "$ff" > "$f.javap.tmp" - rm "$f" - cc=99 - foundAttr=false - attrName="" - # Clear any attr tmp files - for attr in $moduleAttr - do - rm -f "$f.javap.$attr" - done - - while IFS= read -r line - do - cc=$((cc+1)) - - # Module attr have only 1 line definition - if [[ "$foundAttr" = true ]] && [[ "$cc" -gt 1 ]]; then - foundAttr=false - attrName="" - fi - - # If not processing an attr then check for attr - if [[ "$foundAttr" = false ]]; then - for attr in $moduleAttr - do - if [[ "$line" =~ .*"$attr:".* ]]; then - cc=0 - foundAttr=true - attrName="$attr" - fi - done - fi - - # Echo attr to attr tmp file, otherwise to tmp2 - if [[ "$foundAttr" = true ]]; then - echo "$line" >> "$f.javap.$attrName" - else - echo "$line" >> "$f.javap.tmp2" - fi - done < "$f.javap.tmp" - rm "$f.javap.tmp" - - # Remove javap Classfile and timestamp and SHA-256 hash - if [[ "$f" =~ .*"java.base".* ]]; then - grep -v "Last modified\|Classfile\|SHA-256 checksum\|hash:" "$f.javap.tmp2" > "$f.javap" + # If not processing an attr then check for attr + if [[ "$foundAttr" = false ]]; then + for attr in $moduleAttr + do + if [[ "$line" =~ .*"$attr:".* ]]; then + cc=0 + foundAttr=true + attrName="$attr" + fi + done + fi + + # Echo attr to attr tmp file, otherwise to tmp2 + if [[ "$foundAttr" = true ]]; then + echo "$line" >> "$f.javap.$attrName" else - grep -v "Last modified\|Classfile\|SHA-256 checksum" "$f.javap.tmp2" > "$f.javap" + echo "$line" >> "$f.javap.tmp2" fi - rm "$f.javap.tmp2" - - # Append any ModuleAttr tmp files - for attr in $moduleAttr - do - if [[ -f "$f.javap.$attr" ]]; then - cat "$f.javap.$attr" >> "$f.javap" - fi - rm -f "$f.javap.$attr" - done + done < "$f.javap.tmp" + rm "$f.javap.tmp" + rm "$f" + # Remove javap Classfile and timestamp and SHA-256 hash + if [[ "$f" =~ .*"java.base".* ]]; then + grep -v "Last modified\|Classfile\|SHA-256 checksum\|hash:" "$f.javap.tmp2" > "$f.javap" + else + grep -v "Last modified\|Classfile\|SHA-256 checksum" "$f.javap.tmp2" > "$f.javap" + fi + rm "$f.javap.tmp2" + + # Append any ModuleAttr tmp files + for attr in $moduleAttr + do + if [[ -f "$f.javap.$attr" ]]; then + cat "$f.javap.$attr" >> "$f.javap" + fi + rm -f "$f.javap.$attr" done - fi + done } # Remove windowns generate classes jdk/bin/server/classes.jsa & jdk/bin/server/classes_nocoops.jsa diff --git a/tooling/reproducible/repro_compare.sh b/tooling/reproducible/repro_compare.sh index 18743f7e9..2ee8616fb 100755 --- a/tooling/reproducible/repro_compare.sh +++ b/tooling/reproducible/repro_compare.sh @@ -51,11 +51,10 @@ do if [[ "$OS" =~ CYGWIN* ]] || [[ "$OS" =~ Darwin* ]]; then removeSystemModulesHashBuilderParams "${JDK_DIR}" "${OS}" "${BK_JDK_DIR}" + processModuleInfo "${JDK_DIR}" "${OS}" "${BK_JDK_DIR}" fi - processModuleInfo "${JDK_DIR}" "${OS}" "${BK_JDK_DIR}" done - files1=$(find "${JDK_DIR1}" -type f | wc -l) echo "Number of files: ${files1}" rc=0 diff --git a/tooling/reproducible/repro_process.sh b/tooling/reproducible/repro_process.sh index 7dbbe6ed4..d44f9ac8b 100755 --- a/tooling/reproducible/repro_process.sh +++ b/tooling/reproducible/repro_process.sh @@ -13,7 +13,7 @@ # ******************************************************************************** # shellcheck disable=SC1091 -source $(dirname "$0")/repro_common.sh +source "$(dirname "$0")"/repro_common.sh JDK_DIR="$1" OS="$2"