From 8a75eba90628b3b53ca96872d50179b5fd92c367 Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Wed, 1 Nov 2023 18:28:06 +0100 Subject: [PATCH] overlay, ci-automation: Another attempt at providing OEMID info Please read the comment at the top of the coreos-base/common-oem-files ebuild for details. --- ci-automation/image_changes.sh | 8 ++- .../common-oem-files-0-r4.ebuild | 60 ++++++++++++++++++- .../common-oem-files/files/oemids.sh | 30 ---------- 3 files changed, 64 insertions(+), 34 deletions(-) delete mode 100644 sdk_container/src/third_party/coreos-overlay/coreos-base/common-oem-files/files/oemids.sh diff --git a/ci-automation/image_changes.sh b/ci-automation/image_changes.sh index 69c8c597b9..bc93b0d27a 100644 --- a/ci-automation/image_changes.sh +++ b/ci-automation/image_changes.sh @@ -210,9 +210,15 @@ function get_oem_id_list() { arch=${1}; shift list_var_name=${1}; shift + local -a ebuilds=("${scripts_repo}/sdk_container/src/third_party/coreos-overlay/coreos-base/common-oem-files/common-oem-files-"*'.ebuild') + if [[ ${#ebuilds[@]} -eq 0 ]] || [[ ! -e ${ebuilds[0]} ]]; then + echo "No coreos-base/common-oem-files ebuilds?!" >&2 + exit 1 + fi + # This defines COMMON_OEMIDS, AMD64_ONLY_OEMIDS, ARM64_ONLY_OEMIDS # and OEMIDS variable. We don't use the last one. - source "${scripts_repo}/sdk_container/src/third_party/coreos-overlay/coreos-base/common-oem-files/files/oemids.sh" local + source "${ebuilds[0]}" flatcar-local-variables local -n arch_oemids_ref="${arch^^}_ONLY_OEMIDS" local all_oemids=( diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/common-oem-files/common-oem-files-0-r4.ebuild b/sdk_container/src/third_party/coreos-overlay/coreos-base/common-oem-files/common-oem-files-0-r4.ebuild index 33c4b20a73..26c6c6ecb5 100644 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/common-oem-files/common-oem-files-0-r4.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/common-oem-files/common-oem-files-0-r4.ebuild @@ -1,10 +1,64 @@ # Copyright (c) 2023 The Flatcar Maintainers. # Distributed under the terms of the GNU General Public License v2 -EAPI=8 +# This is a terrible hack done in order to avoid excessive duplication +# of OEM IDs around the place. This ebuild basically serves as a +# Gentoo ebuild (duh…) and as a bash file to be sourced in order to +# get arch-specific information about possible OEM IDs. The latter +# role is assumed when the ebuild is sourced with first argument being +# 'flatcar-local-variables'. This role is used by our image-changes +# job. All this fluff needs to happen before we define or invoke any +# Gentoo-specific variables or functions like "EAPI" or "inherit" that +# may mess up sourcing. +# +# This can't be done with a separate shell file in FILESDIR (I tried), +# because portage moves the ebuild into some temporary directory where +# FILESDIR, although defined, does not even exist. Probably a security +# measure or something. So this needs to be done as +# all-in-terrible-one (as opposed to all-in-wonder-one). -# This defines the OEMIDS variable. -source "${FILESDIR}/oemids.sh" only-oemids +## +## BEGIN HACK +## + +if [[ ${1:-} = 'flatcar-local-variables' ]]; then + local -a COMMON_OEMIDS ARM64_ONLY_OEMIDS AMD64_ONLY_OEMIDS OEMIDS +fi + +COMMON_OEMIDS=( + ami + azure + openstack + packet + qemu +) + +ARM64_ONLY_OEMIDS=( +) + +AMD64_ONLY_OEMIDS=( + digitalocean + vmware +) + +OEMIDS=( + "${COMMON_OEMIDS[@]}" + "${ARM64_ONLY_OEMIDS[@]}" + "${AMD64_ONLY_OEMIDS[@]}" +) + +if [[ ${1:-} = 'flatcar-local-variables' ]]; then + # Leave the sourced script here. + return 0 +else + unset COMMON_OEMIDS ARM64_ONLY_OEMIDS AMD64_ONLY_OEMIDS +fi + +## +## END HACK +## + +EAPI=8 DESCRIPTION='Common OEM files' HOMEPAGE='https://www.flatcar.org/' diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/common-oem-files/files/oemids.sh b/sdk_container/src/third_party/coreos-overlay/coreos-base/common-oem-files/files/oemids.sh deleted file mode 100644 index ca6b294aa9..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/common-oem-files/files/oemids.sh +++ /dev/null @@ -1,30 +0,0 @@ -if [[ ${1:-} = 'local' ]]; then - local -a COMMON_OEMIDS ARM64_ONLY_OEMIDS AMD64_ONLY_OEMIDS OEMIDS - shift -fi - -COMMON_OEMIDS=( - ami - azure - openstack - packet - qemu -) - -ARM64_ONLY_OEMIDS=( -) - -AMD64_ONLY_OEMIDS=( - digitalocean - vmware -) - -OEMIDS=( - "${COMMON_OEMIDS[@]}" - "${ARM64_ONLY_OEMIDS[@]}" - "${AMD64_ONLY_OEMIDS[@]}" -) - -if [[ ${1:-} = 'only-oemids' ]]; then - unset COMMON_OEMIDS ARM64_ONLY_OEMIDS AMD64_ONLY_OEMIDS -fi