Support using OS other than Debian as base for custom images

Signed-off-by: Balasankar "Balu" C <balasankar@gitlab.com>
This commit is contained in:
Balasankar "Balu" C 2022-06-15 09:51:03 +05:30
parent 703c30315e
commit 0dea43ac3b
No known key found for this signature in database
GPG key ID: B77D2E2E23735427
14 changed files with 345 additions and 226 deletions

View file

@ -2,24 +2,33 @@
set -xeuo pipefail
export DEBIAN_FRONTEND=noninteractive
GCLOUD_VERSION=${1}
apt-get update
apt-get -y install \
apt-transport-https \
python3 \
gnupg
function build_debian() {
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get -y install \
apt-transport-https \
python3 \
gnupg
curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
echo "deb https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
echo "deb https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
apt-get update
apt-get update
PACKAGE_VERSION=$(apt-cache policy google-cloud-cli | awk -v dv=${GCLOUD_VERSION} '$1 ~ dv {print $1}')
PACKAGE_VERSION=$(apt-cache policy google-cloud-cli | awk -v dv=${GCLOUD_VERSION} '$1 ~ dv {print $1}')
apt-get install -y google-cloud-cli=${PACKAGE_VERSION}
apt-get -yq autoremove
apt-get clean -yqq
rm -rf /var/lib/apt/lists/*
apt-get install -y google-cloud-cli=${PACKAGE_VERSION}
apt-get -yq autoremove
apt-get clean -yqq
rm -rf /var/lib/apt/lists/*
}
BUILD_OS=${BUILD_OS:-debian}
if [[ $BUILD_OS =~ debian ]]; then
build_debian "$@"
elif [[ $BUILD_OS =~ ubi ]]; then
build_ubi "$@"
fi