Save chrome and chromium deb files in package registry

This commit is contained in:
Andrejs Cunskis 2022-08-21 21:32:51 +03:00
parent fad37f305c
commit 941883094a
No known key found for this signature in database
GPG key ID: 87CB75083F227241
5 changed files with 122 additions and 74 deletions

View file

@ -4,47 +4,26 @@ set -xeuo pipefail
IFS=$'\n\t'
function build_debian() {
ARCH="${TARGETARCH:-amd64}"
CHROME_VERSION=${1:-103.0.5060.134-1}
ARCH=${TARGETARCH:-amd64}
if [[ "${ARCH}" == "arm64" ]]; then
echo "The arm64 does not have prebuilt chrome. Using chromium instead."
apt-get update -q -y
apt-get install -y chromium chromium-driver
apt-get autoremove -yq
apt-get clean -yqq
rm -rf /var/lib/apt/lists/*
exit 0
if [ "${ARCH}" == "amd64" ]; then
PKG=google-chrome-stable
else
PKG=chromium
fi
CHROME_VERSION=${1:-99.0.4844.74-1}
# We hard code the URL rather than using $CI_API_V4_URL $CI_PROJECT_ID,
# because we would need to forward those variables
CHROME_DOWNLOAD_URL_BASE="https://gitlab.com/api/v4/projects/1075790/packages/generic/google-chrome-stable"
export DEBIAN_FRONTEND=noninteractive
CHROME_DOWNLOAD_URL_BASE="https://gitlab.com/api/v4/projects/1075790/packages/generic/${PKG}"
CHROME_DEB="${PKG}_${CHROME_VERSION}_${ARCH}.deb"
CHROME_URL="${CHROME_DOWNLOAD_URL_BASE}/${CHROME_VERSION}/${CHROME_DEB}"
curl -sS -L https://dl.google.com/linux/linux_signing_key.pub | apt-key add -
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >/etc/apt/sources.list.d/google.list
apt-get update -q -y
# Download from our package registry if we can't find the package in the apt repository
echo "Searching for $CHROME_VERSION in apt repository"
CHECK_VERSION=$(apt-cache show google-chrome-stable | grep Version | grep "$CHROME_VERSION") || true
apt-cache policy google-chrome-stable
if [[ -z $CHECK_VERSION ]]; then
CHROME_DEB="google-chrome-stable_${CHROME_VERSION}_${ARCH}.deb"
CHROME_URL="${CHROME_DOWNLOAD_URL_BASE}/${CHROME_VERSION}/${CHROME_DEB}"
echo "Downloading from our Package registry: $CHROME_URL"
curl --silent --show-error --fail -O $CHROME_URL
dpkg -i ./$CHROME_DEB || true
apt-get install -f -y
rm -f $CHROME_DEB
else
echo "Installing via apt-get"
apt-get install -y google-chrome-stable=$CHROME_VERSION
fi
echo "Downloading deb file from Package registry: $CHROME_URL"
curl --silent --show-error --fail -O $CHROME_URL
dpkg -i ./$CHROME_DEB || true
apt-get install -f -y
rm -f $CHROME_DEB
rm -rf /var/lib/apt/lists/*