mirror of
https://ops.gitlab.net/gitlab-org/gitlab-build-images.git
synced 2025-12-09 18:12:55 +01:00
58 lines
1.8 KiB
Bash
Executable file
58 lines
1.8 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
set -xeuo pipefail
|
|
IFS=$'\n\t'
|
|
|
|
function build_debian() {
|
|
CHROME_VERSION=${1:-103.0.5060.134-1}
|
|
ARCH=${TARGETARCH:-amd64}
|
|
|
|
if [ "${ARCH}" == "amd64" ]; then
|
|
PKG=google-chrome-stable
|
|
else
|
|
PKG=chromium
|
|
fi
|
|
|
|
# We hard code the URL rather than using $CI_API_V4_URL $CI_PROJECT_ID,
|
|
# because we would need to forward those variables
|
|
DOWNLOAD_URL_BASE="https://gitlab.com/api/v4/projects/1075790/packages/generic/${PKG}"
|
|
BROWSER_DEB="${PKG}_${CHROME_VERSION}_${ARCH}.deb"
|
|
BROWSER_URL="${DOWNLOAD_URL_BASE}/${CHROME_VERSION}/${BROWSER_DEB}"
|
|
|
|
echo "Installing browser"
|
|
curl --silent --show-error --fail -O "$BROWSER_URL"
|
|
dpkg -i "./${BROWSER_DEB}" || true
|
|
apt-get install -f -y
|
|
rm -f "$BROWSER_DEB"
|
|
|
|
echo "Installing webdriver"
|
|
if [ "${ARCH}" == "amd64" ]; then
|
|
CHROME_VERSION_BASE=$(echo $CHROME_VERSION | awk -F "." '{print $1 "." $2 "." $3}')
|
|
CHROME_DRIVER_VERSION=$(curl -q https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_VERSION_BASE)
|
|
|
|
wget -q https://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip
|
|
unzip chromedriver_linux64.zip -d /usr/local/bin
|
|
rm -f chromedriver_linux64.zip
|
|
else
|
|
DRIVER_DEB="${PKG}-driver_${CHROME_VERSION}_${ARCH}.deb"
|
|
DRIVER_URL="${DOWNLOAD_URL_BASE}/${CHROME_VERSION}/${DRIVER_DEB}"
|
|
|
|
curl --silent --show-error --fail -O "$DRIVER_URL"
|
|
dpkg -i "./${DRIVER_DEB}" || true
|
|
apt-get install -f -y
|
|
rm -f "$DRIVER_DEB"
|
|
fi
|
|
|
|
apt-get autoremove -yq
|
|
apt-get clean -yqq
|
|
rm -rf /var/lib/apt/lists/*
|
|
rm -rf /etc/apt/sources.list.d/google*.list
|
|
}
|
|
|
|
BUILD_OS=${BUILD_OS:-debian}
|
|
|
|
if [[ $BUILD_OS =~ debian ]]; then
|
|
build_debian "$@"
|
|
elif [[ $BUILD_OS =~ ubi ]]; then
|
|
build_ubi "$@"
|
|
fi
|