From 248ffcef030b0aab8f901e4c7f5beba144aa9ac4 Mon Sep 17 00:00:00 2001 From: Thilo Fromm Date: Wed, 23 Feb 2022 19:25:12 +0100 Subject: [PATCH 1/2] ci-automation/util/fetch_image.sh: fetch CI build stage image Signed-off-by: Thilo Fromm --- ci-automation/util/fetch_image.sh | 73 +++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100755 ci-automation/util/fetch_image.sh diff --git a/ci-automation/util/fetch_image.sh b/ci-automation/util/fetch_image.sh new file mode 100755 index 0000000000..1fec5c1a93 --- /dev/null +++ b/ci-automation/util/fetch_image.sh @@ -0,0 +1,73 @@ +#!/bin/bash +# +# Copyright (c) 2021 The Flatcar Maintainers. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Helper for fetching a CI stage container image. + +set -euo pipefail + +function fetch_image_usage() { + local version="$1" + echo "Usage: fetch_image [-a ] [-v ] ." + echo "Fetch and docker load a container image of a CI build stage." + echo " - CI build stsage to fetch:" + echo " sdk - fetch & install the plain SDK docker image. Note that this only works for the" + echo " 'main' branch since maintenance branches don't build an SDK." + echo " packages - fetch the packages (SDK + binary packages) container image." + echo " image - fetch the imagess (SDK + packages + image) container image." + echo " -v - Custom version to fetch instead of branch version '${version}'" + echo " -a - OS image target architecture - 'arm64' or 'amd64'. Defaults to 'amd64'." +} +# -- + +function fetch_image() { + local stage + local arch="amd64" + local version="${3:-}" + + local script_root="$(dirname "${BASH_SOURCE[0]}")/../.." + source "${script_root}/ci-automation/ci_automation_common.sh" + + local vernum="$(source "${script_root}/sdk_container/.repo/manifests/version.txt"; + echo "${FLATCAR_VERSION}")" + local docker_vernum="$(vernum_to_docker_image_version "${vernum}")" + + while [ 0 -lt $# ] ; do + case "$1" in + -h) usage; exit 0;; + -v) docker_vernum="$2"; shift; shift;; + -a) arch="$2"; shift; shift;; + *) if [ -n "${stage:-}" ] ; then + echo "ERROR: Spurious positional argument(s): '$@'" + fetch_image_usage "${vernum}" + exit 1 + fi + stage="$1" + shift;; + esac + done + + local image + case "${stage}" in + sdk) image="flatcar-sdk-${arch}";; + packages) image="flatcar-packages-${arch}";; + image) image="flatcar-images-${arch}";; + *) echo "ERROR: unknown build stage '$1'" + fetch_image_usage "${docker_vernum}" + exit 1;; + esac + + echo "Fetching '${image}:${docker_vernum}'. Depending on your connection this may take a while." + docker_image_from_buildcache "${image}" "${docker_vernum}" + + echo "Done! Use" + echo " ./run_sdk_container -t -C ${image}:${docker_vernum}" + echo "to start." +} +# -- + +if [ "$(basename "$0")" = "fetch_image.sh" ] ; then + fetch_image $@ +fi From 637e5d52ec28f40078c8005b0342ad21b1b8fb3e Mon Sep 17 00:00:00 2001 From: Thilo Fromm Date: Wed, 2 Mar 2022 10:09:59 +0100 Subject: [PATCH 2/2] Apply suggestions of my favourite proofreader MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Krzesimir continues to save me from embarrassing spelling mistakes 💙 Co-authored-by: Krzesimir Nowak --- ci-automation/util/fetch_image.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci-automation/util/fetch_image.sh b/ci-automation/util/fetch_image.sh index 1fec5c1a93..51c4ef3a42 100755 --- a/ci-automation/util/fetch_image.sh +++ b/ci-automation/util/fetch_image.sh @@ -12,11 +12,11 @@ function fetch_image_usage() { local version="$1" echo "Usage: fetch_image [-a ] [-v ] ." echo "Fetch and docker load a container image of a CI build stage." - echo " - CI build stsage to fetch:" + echo " - CI build stage to fetch:" echo " sdk - fetch & install the plain SDK docker image. Note that this only works for the" echo " 'main' branch since maintenance branches don't build an SDK." echo " packages - fetch the packages (SDK + binary packages) container image." - echo " image - fetch the imagess (SDK + packages + image) container image." + echo " image - fetch the images (SDK + packages + image) container image." echo " -v - Custom version to fetch instead of branch version '${version}'" echo " -a - OS image target architecture - 'arm64' or 'amd64'. Defaults to 'amd64'." }