diff --git a/README.md b/README.md index f9ced9753..11f38584a 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ as we can generate valid dockerfile for it): ```bash ./makejdk-any-platform.sh --docker --clean-docker-build jdk8u -./makejdk-any-platform.sh --docker --clean-docker-build --build-variant openj9 jdk11u +./makejdk-any-platform.sh --podman --clean-docker-build --build-variant openj9 jdk11u ``` We test these dockerfiles on a regular basis in the @@ -144,8 +144,8 @@ specify the location for the built binary, e.g. /path/. This is typically used in conjunction with -T to create a custom path / file name for the resulting binary. --D, --docker -build OpenJDK in a docker container. +-D, --docker, --podman +build OpenJDK in a docker/podman container. -D will autodetect, using podman if found, docker otherwise. --cross-compile use this if you are cross compiling - it will skip the java -version checks at the end @@ -253,7 +253,7 @@ specify the JVM variant (server or client), defaults to server. Example usage: -./makejdk-any-platform --docker jdk8u +./makejdk-any-platform -D jdk8u ./makejdk-any-platform -T MyOpenJDK10.tar.gz jdk10 ``` diff --git a/configureBuild.sh b/configureBuild.sh index 924863833..8606be3ec 100755 --- a/configureBuild.sh +++ b/configureBuild.sh @@ -86,7 +86,7 @@ doAnyBuildVariantOverrides() { # Set the working directory for this build setWorkingDirectory() { if [ -z "${BUILD_CONFIG[WORKSPACE_DIR]}" ]; then - if [[ "${BUILD_CONFIG[USE_DOCKER]}" == "true" ]]; then + if [[ "${BUILD_CONFIG[CONTAINER_COMMAND]}" == "true" ]]; then BUILD_CONFIG[WORKSPACE_DIR]="/openjdk/" else BUILD_CONFIG[WORKSPACE_DIR]="$PWD/workspace" @@ -410,5 +410,7 @@ configure_build() { setWorkingDirectory configureMacFreeFont setMakeArgs - setBootJdk + if [ "${BUILD_CONFIG[CONTAINER_COMMAND]}" == false ] ; then + setBootJdk + fi } diff --git a/cyclonedx-lib/build.xml b/cyclonedx-lib/build.xml index eeba51bb1..6e3e58f07 100644 --- a/cyclonedx-lib/build.xml +++ b/cyclonedx-lib/build.xml @@ -354,7 +354,7 @@ - + diff --git a/docker-build.sh b/docker-build.sh index a6bbb80e0..b7211f464 100755 --- a/docker-build.sh +++ b/docker-build.sh @@ -20,6 +20,12 @@ # ################################################################################ +# the ${BUILD_CONFIG[CONTAINER_AS_ROOT]} can not be quoted. It is sudo (or simialrly) or nothing. "" is not an option. +# simialrly the ${cpuset} and ${userns} +# shellcheck disable=SC2206 +# shellcheck disable=SC2046 +# shellcheck disable=SC2086 + set -eu # Create a data volume called ${BUILD_CONFIG[DOCKER_SOURCE_VOLUME_NAME]}, @@ -30,7 +36,7 @@ set -eu createPersistentDockerDataVolume() { set +e - ${BUILD_CONFIG[DOCKER]} volume inspect "${BUILD_CONFIG[DOCKER_SOURCE_VOLUME_NAME]}" > /dev/null 2>&1 + ${BUILD_CONFIG[CONTAINER_AS_ROOT]} "${BUILD_CONFIG[CONTAINER_COMMAND]}" volume inspect "${BUILD_CONFIG[DOCKER_SOURCE_VOLUME_NAME]}" > /dev/null 2>&1 local data_volume_exists=$? set -e @@ -38,13 +44,16 @@ createPersistentDockerDataVolume() # shellcheck disable=SC2154 echo "Removing old volumes and containers" - # shellcheck disable=SC2046 - ${BUILD_CONFIG[DOCKER]} rm -f $(${BUILD_CONFIG[DOCKER]} ps -a --no-trunc -q -f volume="${BUILD_CONFIG[DOCKER_SOURCE_VOLUME_NAME]}") || true - ${BUILD_CONFIG[DOCKER]} volume rm -f "${BUILD_CONFIG[DOCKER_SOURCE_VOLUME_NAME]}" || true + ${BUILD_CONFIG[CONTAINER_AS_ROOT]} "${BUILD_CONFIG[CONTAINER_COMMAND]}" rm -f $(${BUILD_CONFIG[CONTAINER_AS_ROOT]} "${BUILD_CONFIG[CONTAINER_COMMAND]}" ps -a --no-trunc -q -f volume="${BUILD_CONFIG[DOCKER_SOURCE_VOLUME_NAME]}") || true + ${BUILD_CONFIG[CONTAINER_AS_ROOT]} "${BUILD_CONFIG[CONTAINER_COMMAND]}" volume rm -f "${BUILD_CONFIG[DOCKER_SOURCE_VOLUME_NAME]}" || true # shellcheck disable=SC2154 echo "Creating tmp container" - ${BUILD_CONFIG[DOCKER]} volume create --name "${BUILD_CONFIG[DOCKER_SOURCE_VOLUME_NAME]}" + if echo "${BUILD_CONFIG[CONTAINER_COMMAND]}" | grep docker ; then + ${BUILD_CONFIG[CONTAINER_AS_ROOT]} "${BUILD_CONFIG[CONTAINER_COMMAND]}" volume create --name "${BUILD_CONFIG[DOCKER_SOURCE_VOLUME_NAME]}" + else + ${BUILD_CONFIG[CONTAINER_AS_ROOT]} "${BUILD_CONFIG[CONTAINER_COMMAND]}" volume create "${BUILD_CONFIG[DOCKER_SOURCE_VOLUME_NAME]}" + fi fi } @@ -64,12 +73,25 @@ buildDockerContainer() writeConfigToFile - ${BUILD_CONFIG[DOCKER]} build -t "${BUILD_CONFIG[CONTAINER_NAME]}" -f "${dockerFile}" . --build-arg "OPENJDK_CORE_VERSION=${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" --build-arg "HostUID=${UID}" + ${BUILD_CONFIG[CONTAINER_AS_ROOT]} "${BUILD_CONFIG[CONTAINER_COMMAND]}" build -t "${BUILD_CONFIG[CONTAINER_NAME]}" -f "${dockerFile}" . --build-arg "OPENJDK_CORE_VERSION=${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" --build-arg "HostUID=${UID}" } # Execute the (Adoptium) OpenJDK build inside the Docker Container buildOpenJDKViaDocker() { + local hostDir + hostDir="$(pwd)" + local pipelinesdir="${hostDir}"/workspace/pipelines + local workspacedir="${hostDir}"/workspace # we must ensure build user have correct permissions here + local targetdir="${hostDir}"/workspace/target + local targetbuilddir="${hostDir}"/workspace/build + local configdir="${hostDir}"/workspace/config + local localsourcesdir= + + if [ "${BUILD_CONFIG[OPENJDK_LOCAL_SOURCE_ARCHIVE]}" = "true" ] ; then + # OPENJDK_LOCAL_SOURCE_ARCHIVE_ABSPATH can be file, you can nto mount file + localsourcesdir=$(dirname "${BUILD_CONFIG[OPENJDK_LOCAL_SOURCE_ARCHIVE_ABSPATH]}") + fi # TODO This could be extracted overridden by the user if we support more # architectures going forwards @@ -80,7 +102,8 @@ buildOpenJDKViaDocker() if [ "${BUILD_CONFIG[BUILD_VARIANT]}" == "openj9" ]; then build_variant_flag="--openj9" fi - docker/dockerfile-generator.sh --version "${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]}" --path "${BUILD_CONFIG[DOCKER_FILE_PATH]}" "$build_variant_flag" + docker/dockerfile-generator.sh --version "${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]}" --path "${BUILD_CONFIG[DOCKER_FILE_PATH]}" "$build_variant_flag" \ + --dirs "${workspacedir} ${targetdir} ${targetbuilddir} ${configdir} ${localsourcesdir}" --command "${BUILD_CONFIG[CONTAINER_AS_ROOT]} ${BUILD_CONFIG[CONTAINER_COMMAND]}" # shellcheck disable=SC1090,SC1091 source "${BUILD_CONFIG[DOCKER_FILE_PATH]}/dockerConfiguration.sh" @@ -129,7 +152,7 @@ buildOpenJDKViaDocker() BUILD_CONFIG[DEBUG_IMAGE_PATH]=$openjdk_debug_image_path BUILD_CONFIG[STATIC_LIBS_IMAGE_PATH]=$static_libs_dir - if [ -z "$(command -v docker)" ]; then + if [ -z "$(command -v "${BUILD_CONFIG[CONTAINER_COMMAND]}")" ]; then # shellcheck disable=SC2154 echo "Error, please install docker and ensure that it is in your path and running!" exit @@ -144,7 +167,7 @@ buildOpenJDKViaDocker() if [[ "${BUILD_CONFIG[REUSE_CONTAINER]}" == "true" ]] ; then # shellcheck disable=SC2086 # If we can't find the previous Docker container then build a new one - if [ "$(${BUILD_CONFIG[DOCKER]} ps -a | grep -c \"${BUILD_CONFIG[CONTAINER_NAME]}\")" == 0 ]; then + if [ "$(${BUILD_CONFIG[CONTAINER_AS_ROOT]} ${BUILD_CONFIG[CONTAINER_COMMAND]} ps -a | grep -c \"${BUILD_CONFIG[CONTAINER_NAME]}\")" == 0 ]; then echo "No docker container for reuse was found, so creating '${BUILD_CONFIG[CONTAINER_NAME]}' " buildDockerContainer fi @@ -152,7 +175,7 @@ buildOpenJDKViaDocker() # shellcheck disable=SC2154 echo "Since you specified --ignore-container, we are removing the existing container (if it exists) and building you a new one{$good}" # Find the previous Docker container and remove it (if it exists) - ${BUILD_CONFIG[DOCKER]} ps -a | awk '{ print $1,$2 }' | grep "${BUILD_CONFIG[CONTAINER_NAME]}" | awk '{print $1 }' | xargs -I {} "${BUILD_CONFIG[DOCKER]}" rm -f {} + ${BUILD_CONFIG[CONTAINER_AS_ROOT]} "${BUILD_CONFIG[CONTAINER_COMMAND]}" ps -a | awk '{ print $1,$2 }' | grep "${BUILD_CONFIG[CONTAINER_NAME]}" | awk '{print $1 }' | xargs -I {} ${BUILD_CONFIG[CONTAINER_AS_ROOT]} "${BUILD_CONFIG[CONTAINER_COMMAND]}" rm -f {} # Build a new container buildDockerContainer @@ -161,9 +184,6 @@ buildOpenJDKViaDocker() # Show the user all of the config before we build displayParams - local hostDir - hostDir="$(pwd)" - echo "Target binary directory on host machine: ${hostDir}/target" mkdir -p "${hostDir}/workspace/target" @@ -183,11 +203,36 @@ buildOpenJDKViaDocker() fi # Command without gitSshAccess or dockerMode arrays + if [ -e "${hostDir}"/pipelines ] ; then + local pipelinesdir="${hostDir}"/pipelines + else + mkdir -p "${pipelinesdir}" + fi + if echo "${BUILD_CONFIG[CONTAINER_COMMAND]}" | grep docker ; then + local cpuset="--cpuset-cpus=${cpuSet}" + else + local cpuset="" + fi + if echo "${BUILD_CONFIG[CONTAINER_COMMAND]}" | grep podman ; then + local userns="--userns=keep-id" + else + local userns="" + fi + local mountflag=Z #rw? maybe this should be bound to root/rootles content of BUILD_CONFIG[CONTAINER_AS_ROOT] rather then just podman/docker in USE_DOCKER? + mkdir -p "${hostDir}"/workspace/build # shouldnt be already there? + local localsourcesdirmount= + if [ -n "${localsourcesdir}" ] ; then + localsourcesdirmount="-v ${localsourcesdir}:${localsourcesdir}:${mountflag}" #read only? Is copied anwya + fi + echo "If you get permissions denied on ${targetdir} or ${pipelinesdir} try to turn off selinux" local commandString=( - "--cpuset-cpus=${cpuSet}" + ${cpuset} + ${userns} + ${localsourcesdirmount} -v "${BUILD_CONFIG[DOCKER_SOURCE_VOLUME_NAME]}:/openjdk/build" - -v "${hostDir}"/workspace/target:/"${BUILD_CONFIG[WORKSPACE_DIR]}"/"${BUILD_CONFIG[TARGET_DIR]}":Z - -v "${hostDir}"/pipelines:/openjdk/pipelines:Z + -v "${targetdir}":/"${BUILD_CONFIG[WORKSPACE_DIR]}"/"${BUILD_CONFIG[TARGET_DIR]}":"${mountflag}" + -v "${pipelinesdir}":/openjdk/pipelines:"${mountflag}" + -v "${configdir}":/"${BUILD_CONFIG[WORKSPACE_DIR]}"/"config":"${mountflag}" -e "DEBUG_DOCKER_FLAG=${BUILD_CONFIG[DEBUG_DOCKER]}" -e "BUILD_VARIANT=${BUILD_CONFIG[BUILD_VARIANT]}" "${dockerEntrypoint[@]:+${dockerEntrypoint[@]}}") @@ -204,14 +249,14 @@ buildOpenJDKViaDocker() fi # Run the command string in Docker - ${BUILD_CONFIG[DOCKER]} run --name "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}-${BUILD_CONFIG[BUILD_VARIANT]}" "${commandString[@]}" + ${BUILD_CONFIG[CONTAINER_AS_ROOT]} "${BUILD_CONFIG[CONTAINER_COMMAND]}" run --name "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}-${BUILD_CONFIG[BUILD_VARIANT]}" "${commandString[@]}" # Tell user where the resulting binary can be found on the host system - echo "The finished image can be found in ${hostDir}/workspace/target on the host system" + echo "The finished image can be found in ${targetdir} on the host system" # If we didn't specify to keep the container then remove it if [[ "${BUILD_CONFIG[KEEP_CONTAINER]}" == "false" ]] ; then echo "Removing container ${BUILD_CONFIG[OPENJDK_CORE_VERSION]}-${BUILD_CONFIG[BUILD_VARIANT]}" - ${BUILD_CONFIG[DOCKER]} ps -a | awk '{ print $1,$(NF) }' | grep "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}-${BUILD_CONFIG[BUILD_VARIANT]}" | awk '{print $1 }' | xargs -I {} "${BUILD_CONFIG[DOCKER]}" rm {} + ${BUILD_CONFIG[CONTAINER_AS_ROOT]} "${BUILD_CONFIG[CONTAINER_COMMAND]}" ps -a | awk '{ print $1,$(NF) }' | grep "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}-${BUILD_CONFIG[BUILD_VARIANT]}" | awk '{print $1 }' | xargs -I {} ${BUILD_CONFIG[CONTAINER_AS_ROOT]} ${BUILD_CONFIG[CONTAINER_COMMAND]} rm {} fi } diff --git a/docker/dockerfile-generator.sh b/docker/dockerfile-generator.sh index 4865df20a..932224e05 100755 --- a/docker/dockerfile-generator.sh +++ b/docker/dockerfile-generator.sh @@ -18,6 +18,7 @@ set -eu OPENJ9=false BUILD=false COMMENTS=false +DIRS= PRINT=false DOCKERFILE_DIR= DOCKERFILE_PATH= @@ -87,6 +88,11 @@ processArgs() { COMMENTS=true shift ;; + --dirs) + DIRS="${2}" + shift + shift + ;; --path) DOCKERFILE_DIR=$2 shift @@ -107,6 +113,11 @@ processArgs() { shift shift ;; + --command) + CMD="${2}" + shift + shift + ;; *) echo "Unrecognised Argument: $1" exit 1 @@ -126,15 +137,24 @@ processArgs() { if [ ${OPENJ9} == true ]; then DOCKERFILE_PATH="$DOCKERFILE_PATH-openj9" fi + + if [ -z "$CMD" ]; then + if which podman > /dev/null; then + CMD=podman + else + CMD=docker + fi + fi } usage() { - echo" Usage: ./dockerfile_generator.sh [OPTIONS] + echo " Usage: ./dockerfile_generator.sh [OPTIONS] Options: --help | -h Print this message and exit --build Build the docker image after generation and create interactive container --clean Remove all dockerfiles (Dockerfile*) from '--path' --comments Prints comments into the dockerfile + --dirs space separated list of dirs to be created, with proper permissions --path Specify where to save the dockerfile (Default: $PWD) --print Print the Dockerfile to screen after generation --openj9 Make the Dockerfile able to build w/OpenJ9 JIT @@ -264,6 +284,14 @@ printgcc() { ENV CC=gcc-7 CXX=g++-7" >> "$DOCKERFILE_PATH" } +printCustomDirs() { + for dir in ${DIRS} ; do + echo "RUN mkdir -p $dir" >> "$DOCKERFILE_PATH" + echo "RUN chmod 755 $dir" >> "$DOCKERFILE_PATH" + echo "RUN chown -R build $dir" >> "$DOCKERFILE_PATH" + done +} + printDockerJDKs() { # JDK8 uses zulu-7 to as it's bootjdk if [ "${JDK_VERSION}" != 8 ] && [ "${JDK_VERSION}" != "${JDK_MAX}" ]; then @@ -325,6 +353,7 @@ printCopyFolders(){ echo " COPY sbin /openjdk/sbin COPY security /openjdk/security +COPY test /openjdk/test COPY workspace/config /openjdk/config" >> "$DOCKERFILE_PATH" } @@ -339,7 +368,9 @@ ARG HostUID ENV HostUID=\$HostUID RUN useradd -u \$HostUID -ms /bin/bash build WORKDIR /openjdk/build -RUN chown -R build /openjdk/ +RUN chown -R build /openjdk/" >> "$DOCKERFILE_PATH" + printCustomDirs + echo " USER build" >> "$DOCKERFILE_PATH" } @@ -416,7 +447,8 @@ if [ "${BUILD}" == true ]; then commandString="${commandString} --build-variant openj9" fi - docker build -t "jdk${JDK_VERSION}_build_image" -f "$DOCKERFILE_PATH" . --build-arg "OPENJDK_CORE_VERSION=${JDK_VERSION}" --build-arg "HostUID=${UID}" + # although this works for both docekr and podman with docker alias, it shodl honour the setup of BUILD_CONFIG[CONTAINER_COMMAND] (also maybe with BUILD_CONFIG[CONTAINER_AS_ROOT] which set sudo/no sudo) + ${CMD} build -t "jdk${JDK_VERSION}_build_image" -f "$DOCKERFILE_PATH" . --build-arg "OPENJDK_CORE_VERSION=${JDK_VERSION}" --build-arg "HostUID=${UID}" echo "To start a build run ${commandString}" - docker run -it "jdk${JDK_VERSION}_build_image" bash + ${CMD} run -it "jdk${JDK_VERSION}_build_image" bash fi diff --git a/makejdk-any-platform.1 b/makejdk-any-platform.1 index c095de133..80cb4158c 100755 --- a/makejdk-any-platform.1 +++ b/makejdk-any-platform.1 @@ -22,7 +22,7 @@ that you are building for further details. \fBExample:\fR The simplest use case to run is: -"./makejdk-any-platform.sh --docker jdk8u" +"./makejdk-any-platform.sh -D jdk8u" This will start a Docker container and build you the latest Java 8 Temurin binary from the source at https://github.com/adoptium/openjdk-jdk8u @@ -97,8 +97,10 @@ specify the location for the built binary, e.g. /path/. This is typically used in conjunction with \fB<-T>\fR to create a custom path / file name for the resulting binary. .TP -.BR \-D ", " \-\-docker -build OpenJDK in a docker container. +.BR \-D ", " \-\-docker ", " \-\-podman +build OpenJDK in a docker/podman container. -D will autodetect, using podman if found, docker otherwise. +When podman is used, there is bug requiring \fI--custom-cacerts\fR to be used under some circumstances. +It is known issue: https://github.com/adoptium/temurin-build/issues/3862 .TP .BR \-\-debug-docker debug OpenJDK build script in a docker container. Only valid if \fB-D\fR is selected. @@ -220,6 +222,6 @@ specify the JVM variant (server or client), defaults to server. Some common example usages: -"./makejdk-any-platform --docker jdk8u" +"./makejdk-any-platform --sudo --docker jdk8u" "./makejdk-any-platform -s /home/openjdk10/src -d /home/openjdk/target -T MyOpenJDK10.tar.gz jdk10" diff --git a/makejdk-any-platform.sh b/makejdk-any-platform.sh index 2dc01423f..ba1527608 100755 --- a/makejdk-any-platform.sh +++ b/makejdk-any-platform.sh @@ -64,7 +64,7 @@ done echo "${makeJdkArgs}" > ./workspace/config/makejdk-any-platform.args # Let's build and test the (Adoptium) OpenJDK binary in Docker or natively -if [ "${BUILD_CONFIG[USE_DOCKER]}" == "true" ] ; then +if [ ! "${BUILD_CONFIG[CONTAINER_COMMAND]}" == "false" ] ; then buildOpenJDKViaDocker else buildOpenJDKInNativeEnvironment diff --git a/sbin/build.sh b/sbin/build.sh index 5f7fbfad2..11b5ff835 100755 --- a/sbin/build.sh +++ b/sbin/build.sh @@ -955,7 +955,7 @@ generateSBoM() { # Add Build Docker image SHA1 local buildimagesha=$(cat ${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[TARGET_DIR]}/metadata/docker.txt) - # ${BUILD_CONFIG[USE_DOCKER]^} always set to false cannot rely on it. + # ${BUILD_CONFIG[CONTAINER_COMMAND]^} always set to false cannot rely on it. if [ -n "${buildimagesha}" ] && [ "${buildimagesha}" != "N.A" ]; then addSBOMMetadataProperty "${javaHome}" "${classpath}" "${sbomJson}" "Use Docker for build" "true" addSBOMMetadataTools "${javaHome}" "${classpath}" "${sbomJson}" "Docker image SHA1" "${buildimagesha}" @@ -2100,7 +2100,7 @@ createTargetDir() { fixJavaHomeUnderDocker() { # If we are inside docker we cannot trust the JDK_BOOT_DIR that was detected on the host system - if [[ "${BUILD_CONFIG[USE_DOCKER]}" == "true" ]]; then + if [[ ! "${BUILD_CONFIG[CONTAINER_COMMAND]}" == "false" ]]; then # clear BUILD_CONFIG[JDK_BOOT_DIR] and re set it BUILD_CONFIG[JDK_BOOT_DIR]="" setBootJdk diff --git a/sbin/common/common.sh b/sbin/common/common.sh index 6f544a848..6cb632802 100755 --- a/sbin/common/common.sh +++ b/sbin/common/common.sh @@ -233,7 +233,7 @@ createOpenJDKArchive() function setBootJdk() { # Stops setting the bootJDK on the host machine when running docker-build - if [ "${BUILD_CONFIG[DOCKER]}" != "docker" ] || { [ "${BUILD_CONFIG[DOCKER]}" == "docker" ] && [ "${BUILD_CONFIG[DOCKER_FILE_PATH]}" != "" ]; } ; then + if [ "${BUILD_CONFIG[CONTAINER_AS_ROOT]}" == "false" ] || { [ "${BUILD_CONFIG[CONTAINER_AS_ROOT]}" != "false" ] && [ "${BUILD_CONFIG[DOCKER_FILE_PATH]}" != "" ]; } ; then if [ -z "${BUILD_CONFIG[JDK_BOOT_DIR]}" ] ; then echo "Searching for JDK_BOOT_DIR" diff --git a/sbin/common/config_init.sh b/sbin/common/config_init.sh index cd3e82878..97ea90d12 100755 --- a/sbin/common/config_init.sh +++ b/sbin/common/config_init.sh @@ -41,9 +41,11 @@ BUILD_REPRODUCIBLE_DATE BUILD_TIMESTAMP BUILD_VARIANT CERTIFICATE +CONTAINER_AS_ROOT CLEAN_DOCKER_BUILD CLEAN_GIT_REPO CLEAN_LIBS +CONTAINER_COMMAND CONTAINER_NAME COPY_MACOSX_FREE_FONT_LIB_FOR_JDK_FLAG COPY_MACOSX_FREE_FONT_LIB_FOR_JRE_FLAG @@ -57,7 +59,6 @@ CROSSCOMPILE DEBUG_DOCKER DEBUG_IMAGE_PATH DISABLE_ADOPT_BRANCH_SAFETY -DOCKER DOCKER_FILE_PATH DOCKER_SOURCE_VOLUME_NAME ENABLE_SBOM_STRACE @@ -101,7 +102,6 @@ TARGET_FILE_NAME TMP_CONTAINER_NAME TMP_SPACE_BUILD USE_ADOPTIUM_DEVKIT -USE_DOCKER USE_JEP319_CERTS USE_SSH USER_SUPPLIED_CONFIGURE_ARGS @@ -273,8 +273,14 @@ function parseConfigurationArguments() { "--destination" | "-d" ) BUILD_CONFIG[TARGET_DIR]="$1"; shift;; - "--docker" | "-D" ) - BUILD_CONFIG[USE_DOCKER]="true";; + "-D" ) + if which podman > /dev/null ; then BUILD_CONFIG[CONTAINER_COMMAND]="podman" ; else BUILD_CONFIG[CONTAINER_COMMAND]="docker" ; fi;; + + "--docker" ) + BUILD_CONFIG[CONTAINER_COMMAND]="docker";; + + "--podman" ) + BUILD_CONFIG[CONTAINER_COMMAND]="podman";; "--debug-docker" ) BUILD_CONFIG[DEBUG_DOCKER]="true";; @@ -348,7 +354,7 @@ function parseConfigurationArguments() { BUILD_CONFIG[SIGN]=true; BUILD_CONFIG[CERTIFICATE]="$1"; shift;; "--sudo" ) - BUILD_CONFIG[DOCKER]="sudo docker";; + BUILD_CONFIG[CONTAINER_AS_ROOT]="sudo";; "--tag" | "-t" ) BUILD_CONFIG[TAG]="$1"; BUILD_CONFIG[SHALLOW_CLONE_OPTION]=""; shift;; @@ -543,7 +549,7 @@ function configDefaults() { BUILD_CONFIG[CLEAN_DOCKER_BUILD]=${BUILD_CONFIG[CLEAN_DOCKER_BUILD]:-false} # Use Docker to build (defaults to false) - BUILD_CONFIG[USE_DOCKER]=${BUILD_CONFIG[USE_DOCKER]:-false} + BUILD_CONFIG[CONTAINER_COMMAND]=${BUILD_CONFIG[CONTAINER_COMMAND]:-false} # Alow to debug docker build.sh script (dafult to false) BUILD_CONFIG[DEBUG_DOCKER]=${BUILD_CONFIG[DEBUG_DOCKER]:-false} @@ -600,7 +606,7 @@ function configDefaults() { # Whether to use Temurin's cacerts file (true) or use the file provided by OpenJDK (false) BUILD_CONFIG[CUSTOM_CACERTS]=${BUILD_CONFIG[CUSTOM_CACERTS]:-"true"} - BUILD_CONFIG[DOCKER]=${BUILD_CONFIG[DOCKER]:-"docker"} + BUILD_CONFIG[CONTAINER_AS_ROOT]=${BUILD_CONFIG[CONTAINER_AS_ROOT]:-""} BUILD_CONFIG[TMP_SPACE_BUILD]=${BUILD_CONFIG[TMP_SPACE_BUILD]:-false} diff --git a/signalhandler.sh b/signalhandler.sh index ba5beaff0..d7a2c7c02 100755 --- a/signalhandler.sh +++ b/signalhandler.sh @@ -13,8 +13,8 @@ # ******************************************************************************** exit_script() { - if [[ -z ${KEEP_CONTAINER} ]] ; then - docker ps -a | awk '{ print $1,$2 }' | grep "$CONTAINER_NAME" | awk '{print $1 }' | xargs -I {} docker rm -f {} + if [[ -z "${BUILD_CONFIG[KEEP_CONTAINER]}" ]] ; then + "${BUILD_CONFIG[CONTAINER_COMMAND]}" ps -a | awk '{ print $1,$2 }' | grep "${BUILD_CONFIG[CONTAINER_NAME]}" | awk '{print $1 }' | xargs -I {} "${BUILD_CONFIG[CONTAINER_COMMAND]}" rm -f {} fi echo "Process exited" trap - SIGINT SIGTERM # clear the trap