mirror of
https://ops.gitlab.net/gitlab-org/gitlab-build-images.git
synced 2025-12-11 02:52:56 +01:00
We currently cache Google Chrome deb files in AWS. Since GitLab 14.8 Generic Packages have become generally available. So in order to remove the dependency on AWS and to dogfood the feature, we are going to cache the Google Chrome deb files with GitLab https://docs.gitlab.com/ee/user/packages/generic_packages/
47 lines
1.6 KiB
Bash
Executable file
47 lines
1.6 KiB
Bash
Executable file
#!/bin/bash
|
|
# This script attempts to copy the latest version of the Google Chrome Debian
|
|
# package into our own package registry. Google yanks old versions regularly,
|
|
# making it hard to keep up with all the new versions.
|
|
|
|
set -e
|
|
|
|
PKG=google-chrome-stable
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
apt-get -y update
|
|
apt-get -y install apt-utils curl bash
|
|
|
|
curl -sS -L https://dl.google.com/linux/linux_signing_key.pub | apt-key add -
|
|
echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list
|
|
|
|
echo "Updating apt to get Google Chrome packages..."
|
|
|
|
apt-get -y -q update
|
|
|
|
echo "Checking for latest Chrome version in apt repository..."
|
|
|
|
LATEST_VERSION=$(apt-cache show $PKG | grep Version | sort | tail -1 | sed -e "s/Version: //")
|
|
CHROME_DEB="google-chrome-stable_${LATEST_VERSION}_amd64.deb"
|
|
CHROME_URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${PKG}/${LATEST_VERSION}/${CHROME_DEB}"
|
|
|
|
echo "Checking if cache has $CHROME_DEB"
|
|
FILE_CHECK=$(curl --silent --location --head --output /dev/null --write "%{http_code}\\n" "$CHROME_URL")
|
|
|
|
if [ "$FILE_CHECK" -eq "200" ]; then
|
|
echo "Latest version $LATEST_VERSION is already cached!"
|
|
else
|
|
echo "Downloading latest Chrome version ($LATEST_VERSION) in apt repository..."
|
|
cd /tmp
|
|
apt-get download $PKG
|
|
|
|
if ! [ -f "$CHROME_DEB" ]; then
|
|
echo "Downloaded file didn't have expected name: $CHROME_DEB"
|
|
ls
|
|
exit 1
|
|
fi
|
|
|
|
echo "Transferring $CHROME_DEB to GitLab packages"
|
|
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
|
|
--upload-file "./{$CHROME_DEB}" \
|
|
"$CHROME_URL"
|
|
fi
|