Skip to content

Commit

Permalink
overlay, ci-automation: Factor out OEMID info to a separate file
Browse files Browse the repository at this point in the history
Image changes job needs a list of OEMIDs that are built for a specific
architecture. Similar information already existed in the
coreos-base/common-oem-files ebuild, so factor it out to a separate
file, so the image changes job does not need to source the entire
ebuild (or process it in other way), but rather source the smaller
file.
  • Loading branch information
krnowak committed Oct 26, 2023
1 parent 22f47b5 commit 8426698
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 64 deletions.
61 changes: 12 additions & 49 deletions ci-automation/image_changes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -206,59 +206,22 @@ function git_tag_for_nightly() {
# 2 - arch
# 3 - name of an array variable to store the result in
function get_oem_id_list() {
local scripts_repo arch
local scripts_repo arch list_var_name
scripts_repo=${1}; shift
arch=${1}; shift
local -n list_var_ref=${1}; shift
list_var_name=${1}; shift

local -a ebuilds
ebuilds=( "${scripts_repo}/sdk_container/src/third_party/coreos-overlay/coreos-base/common-oem-files/common-oem-files-"*'.ebuild' )
# 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

list_var_ref=()
if [[ ${#ebuilds[@]} -eq 0 ]]; then
return 0
fi
local mode
# 0 = no OEMIDS line found yet
# 1 = OEMIDS line found
mode=0
local -a fields
local first arch_field arch_found
while read -r -a fields; do
if [[ ${#fields[@]} -eq 0 ]]; then
continue
fi
first=${fields[0]}
case ${mode} in
0)
if [[ ${first} = 'OEMIDS=(' ]]; then
mode=1
fi
;;
1)
if [[ ${first} = ')' ]]; then
break
fi
if [[ ${#fields[@]} -gt 1 ]]; then
if [[ ${fields[1]} != '#' ]]; then
echo "expect a line inside OEMIDS to be like '<OEMID> # <ARCH1> <ARCH2>…' or just '<OEMID>', got '${fields[*]}'" >&2
exit 1
fi
arch_found=
for arch_field in "${fields[@]:2}"; do
if [[ ${arch} = "${arch_field}" ]]; then
arch_found=x
break
fi
done
if [[ -z ${arch_found} ]]; then
continue
fi
fi
list_var_ref+=( "${first}" )
;;
esac
done <"${ebuilds[0]}"
local -n arch_oemids_ref="${arch^^}_ONLY_OEMIDS"
local all_oemids=(
"${COMMON_OEMIDS[@]}"
"${arch_oemids_ref[@]}"
)

mapfile -t "${list_var_name}" < <(printf '%s\n' "${all_oemids[@]}" | sort)
}

function get_base_sysext_list() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,8 @@

EAPI=8

# One OEM ID per line, a comment at the end of the line to denote
# which arch this OEM is for (not necessary if OEM is built for all of
# them). The arches should be space separated.
#
# This is used by the ci-automation/image_changes.sh script to figure
# out the per-arch OEM IDs.
OEMIDS=(
ami
azure
digitalocean # amd64
openstack
packet
qemu
vmware # amd64
)
# This defines the OEMIDS variable.
source "${FILESDIR}/oemids.sh" only-oemids

DESCRIPTION='Common OEM files'
HOMEPAGE='https://www.flatcar.org/'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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

0 comments on commit 8426698

Please sign in to comment.