Fix build environment detection

Signed-off-by: Balasankar "Balu" C <balasankar@gitlab.com>
This commit is contained in:
Balasankar "Balu" C 2022-07-05 12:01:56 +05:30
parent ca196275d2
commit 690bb34f74
No known key found for this signature in database
GPG key ID: B77D2E2E23735427
3 changed files with 32 additions and 11 deletions

View file

@ -82,9 +82,7 @@ function prepare_ubi_environment() {
}
if [[ $1 =~ debian ]]; then
export BUILD_OS=debian
prepare_debian_environment "$@"
elif [[ $1 =~ ubi ]]; then
export BUILD_OS=ubi
prepare_ubi_environment "$@"
fi

View file

@ -301,10 +301,32 @@ function parse_arguments() {
# armhf | armhf | armhf | arm32v7
# aarch64 | aarch64 | arm64 | arm64v8
# We make use of 4 variables related to the build environment.
# 1. `CUSTOM_DOCKER_IMAGE` - Defines the reference of image used as
# base for building images. Follows a
# valid docker image reference format
# - "arm64v8/debian:buster"
# - "registry.access.redhat.com/ubi8/ubi:8.6"
# 2. `CUSTOM_DOCKER_ARCH` - Defines the architecture of the docker
# image. Follows docker architecture
# format - `amd64`/`arm32v7`/`arm64v8`.
# 3. `BUILD_OS` - Used by installation scripts of various
# components to detect the OS being worked
# on. Follows regular docker image:tag
# format - "debian:buster" or "ubi:8.6".
# 4. `BUILD_ARCH` - Used by installation scripts of various
# components to detect the architecture
# being worked on. Follows general
# architecture names - `amd64`/`arm64`.
#
# The first two variables are used to pick the docker image used as
# base for builds. The last two variables are used to detect OS and
# architecture while building components.
# defaults
case $(arch) in
x86_64) CUSTOM_DOCKER_ARCH=amd64 ;;
aarch64) CUSTOM_DOCKER_ARCH=arm64v8 ;;
x86_64) CUSTOM_DOCKER_ARCH=amd64; BUILD_ARCH=amd64 ;;
aarch64) CUSTOM_DOCKER_ARCH=arm64v8; BUILD_ARCH=arm64 ;;
*) echo "unknown architecture $(arch)"; exit 1;;
esac
@ -340,7 +362,11 @@ function parse_arguments() {
CUSTOM_BASE_IMAGE="$CUSTOM_DOCKER_ARCH/debian:buster"
fi
BUILD_OS=${OS:-"debian:buster"}
printf -- "--build-arg CUSTOM_BASE_IMAGE=%s " "$CUSTOM_BASE_IMAGE"
printf -- "--build-arg BUILD_OS=%s " "$BUILD_OS"
printf -- "--build-arg BUILD_ARCH=%s " "$BUILD_ARCH"
}
function generate_command() {