From 10376add5bad6bbddfe11463c79861da03a30687 Mon Sep 17 00:00:00 2001 From: sophia-guo Date: Sat, 7 Dec 2024 19:22:43 -0500 Subject: [PATCH] Enhance SBOM and JDK file check (#4078) * update params check * check if default sbom and jdk available Signed-off-by: Sophia Guo * check if default sbom and jdk available * Format Signed-off-by: Sophia Guo * update ERROR to info to avoid exit the test early Signed-off-by: Sophia Guo * update usage message --------- Signed-off-by: Sophia Guo --- .../reproducibleCompare/reproducible.mk | 25 +++++++++++++------ .../reproducible/macos_repro_build_compare.sh | 2 +- .../windows_repro_build_compare.sh | 6 +++-- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/test/system/reproducibleCompare/reproducible.mk b/test/system/reproducibleCompare/reproducible.mk index e6fbfb2a1..4870bed9a 100644 --- a/test/system/reproducibleCompare/reproducible.mk +++ b/test/system/reproducibleCompare/reproducible.mk @@ -12,18 +12,29 @@ # ******************************************************************************** ifndef SBOM_FILE - SBOM_FILE := $(shell ls $(TEST_ROOT)/../jdkbinary/ | grep "sbom" | grep -v "metadata") - SBOM_FILE := $(TEST_ROOT)/../jdkbinary/$(SBOM_FILE) + SBOM_FILE := $(shell ls $(TEST_ROOT)/../jdkbinary/ | grep "sbom" | grep -v "metadata") + ifeq ($(strip $(SBOM_FILE)),) + $(info ERROR! NO SBOM_FILE AVAILABLE) + SBOM_FILE := + else + SBOM_FILE := $(TEST_ROOT)/../jdkbinary/$(SBOM_FILE) + endif 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 + 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 + ifeq ($(strip $(JDK_FILE)),) + $(info ERROR! NO JDK_FILE AVAILABLE) + endif endif ifneq (,$(findstring linux,$(SPEC))) - SBOM_FILE := $(subst $(TEST_ROOT)/../jdkbinary,/home/jenkins/test,$(SBOM_FILE)) + ifneq ($(strip $(SBOM_FILE)),) + 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) \ No newline at end of file diff --git a/tooling/reproducible/macos_repro_build_compare.sh b/tooling/reproducible/macos_repro_build_compare.sh index 4831c76c5..18c976916 100755 --- a/tooling/reproducible/macos_repro_build_compare.sh +++ b/tooling/reproducible/macos_repro_build_compare.sh @@ -23,7 +23,7 @@ set -e # Check All 3 Params Are Supplied if [ "$#" -lt 3 ]; then - echo "Usage: $0 SBOM_URL/SBOM_PATH JDKZIP_URL/JDKZIP_PATH" + echo "Usage: $0 SBOM_URL/SBOM_PATH JDKZIP_URL/JDKZIP_PATH REPORT_DIR" echo "" echo "1. SBOM_URL/SBOM_PATH - should be the FULL path OR a URL to a Temurin JDK SBOM JSON file in CycloneDX Format" echo " eg. https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.3%2B9/OpenJDK21U-sbom_x64_mac_hotspot_21.0.3_9.json" diff --git a/tooling/reproducible/windows_repro_build_compare.sh b/tooling/reproducible/windows_repro_build_compare.sh index e8b5b2400..186f44f89 100755 --- a/tooling/reproducible/windows_repro_build_compare.sh +++ b/tooling/reproducible/windows_repro_build_compare.sh @@ -19,8 +19,8 @@ set -e # Check All 3 Params Are Supplied -if [ "$#" -lt 2 ]; then - echo "Usage: $0 SBOM_URL/SBOM_PATH JDKZIP_URL/JDKZIP_PATH" +if [ "$#" -lt 3 ]; then + echo "Usage: $0 SBOM_URL/SBOM_PATH JDKZIP_URL/JDKZIP_PATH REPORT_DIR" echo "" echo "1. SBOM_URL/SBOM_PATH - should be the FULL path OR a URL to a Temurin JDK SBOM JSON file in CycloneDX Format" echo " eg. https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.2%2B13/OpenJDK21U-sbom_x64_windows_hotspot_21.0.2_13.json" @@ -28,6 +28,8 @@ if [ "$#" -lt 2 ]; then echo "2. JDKZIP_URL/JDKZIP_PATH - should be the FULL path OR a URL to a Temurin Windows JDK Zip file" echo " eg. https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.2%2B13/OpenJDK21U-jdk_x64_windows_hotspot_21.0.2_13.zip" echo "" + echo "3. REPORT_DIR - should be the FULL path OR a URL to the output directory for the comparison report" + echo "" exit 1 fi