mirror of
https://ops.gitlab.net/gitlab-org/gitlab-build-images.git
synced 2025-12-09 10:02:56 +01:00
Save chrome and chromium deb files in package registry
This commit is contained in:
parent
fad37f305c
commit
941883094a
5 changed files with 122 additions and 74 deletions
|
|
@ -1,47 +1,94 @@
|
|||
#!/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 gnupg2
|
||||
|
||||
curl -sS -L https://dl.google.com/linux/linux_signing_key.pub | apt-key add -
|
||||
echo "deb [arch=$(dpkg --print-architecture)] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list
|
||||
function cache-chrome() {
|
||||
PKG=google-chrome-stable
|
||||
|
||||
echo "Updating apt to get Google Chrome packages..."
|
||||
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 -y -q update
|
||||
echo "Updating apt to get Google Chrome packages..."
|
||||
|
||||
echo "Checking for latest Chrome version in apt repository..."
|
||||
apt-get -y -qq update
|
||||
|
||||
LATEST_VERSION=$(apt-cache show $PKG | grep Version | sort | tail -1 | sed -e "s/Version: //")
|
||||
CHROME_DEB="google-chrome-stable_${LATEST_VERSION}_$(dpkg --print-architecture).deb"
|
||||
CHROME_URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${PKG}/${LATEST_VERSION}/${CHROME_DEB}"
|
||||
echo "Checking for latest Chrome version in apt repository..."
|
||||
|
||||
echo "Checking if cache has $CHROME_DEB"
|
||||
FILE_CHECK=$(curl --silent --location --head --output /dev/null --write "%{http_code}\\n" "$CHROME_URL")
|
||||
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}"
|
||||
|
||||
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
|
||||
echo "Checking if cache has $CHROME_DEB"
|
||||
FILE_CHECK=$(curl --silent --location --head --output /dev/null --write "%{http_code}\\n" "$CHROME_URL")
|
||||
|
||||
if ! [ -f "$CHROME_DEB" ]; then
|
||||
echo "Downloaded file didn't have expected name: $CHROME_DEB"
|
||||
ls
|
||||
exit 1
|
||||
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 --fail --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
|
||||
--upload-file "./{$CHROME_DEB}" \
|
||||
"$CHROME_URL"
|
||||
fi
|
||||
}
|
||||
|
||||
echo "Transferring $CHROME_DEB to GitLab packages"
|
||||
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
|
||||
--upload-file "./{$CHROME_DEB}" \
|
||||
"$CHROME_URL"
|
||||
function cache-chromium() {
|
||||
PKG=chromium
|
||||
|
||||
echo "Checking for latest Chromium version in apt repository..."
|
||||
|
||||
LATEST_VERSION=$(apt-cache show $PKG | grep Version | sort | tail -1 | sed -e "s/Version: //")
|
||||
VERSION_NUMBER=$(echo $LATEST_VERSION | sed -e "s/~deb.*//") # remove debian version part to have chrome and chromium compatible version numbers
|
||||
CHROMIUM_DEB="chromium_${VERSION_NUMBER}_arm64.deb"
|
||||
CHROMIUM_URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${PKG}/${VERSION_NUMBER}/${CHROMIUM_DEB}"
|
||||
|
||||
echo "Checking if cache has ${CHROMIUM_DEB}"
|
||||
FILE_CHECK=$(curl --silent --location --head --output /dev/null --write "%{http_code}\\n" "$CHROMIUM_URL")
|
||||
|
||||
if [ "$FILE_CHECK" -eq "200" ]; then
|
||||
echo "Latest version ${LATEST_VERSION} is already cached!"
|
||||
else
|
||||
echo "Downloading latest Chromium version (${LATEST_VERSION}) from apt repository..."
|
||||
cd /tmp
|
||||
apt-get download "$PKG"
|
||||
|
||||
DEB_FILE="chromium_${LATEST_VERSION}_arm64.deb"
|
||||
|
||||
if ! [ -f "$DEB_FILE" ]; then
|
||||
echo "Downloaded file didn't have expected name: ${DEB_FILE}"
|
||||
ls
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mv "$DEB_FILE" "$CHROMIUM_DEB"
|
||||
|
||||
echo "Transferring ${CHROMIUM_DEB} to GitLab packages"
|
||||
curl --fail --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
|
||||
--upload-file "./{$CHROMIUM_DEB}" \
|
||||
"$CHROMIUM_URL"
|
||||
fi
|
||||
}
|
||||
|
||||
apt-get -y -qq update
|
||||
apt-get -y install apt-utils curl bash gnupg2 > /dev/null
|
||||
|
||||
if [ "$TARGETARCH" == "amd64" ]; then
|
||||
cache-chrome
|
||||
else
|
||||
cache-chromium
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue