ubuntu: add --comp for each optional component from the model

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
Olivier Gayot 2025-12-02 16:26:01 +01:00
parent a19f30b9d6
commit 5cbea9f677

View File

@ -42,6 +42,25 @@ get_snaps_args()
| jq --raw-output '.snaps[] | "--snap=" + .name + "=" + .["default-channel"]'
}
get_all_components()
{
# Get list of all components in every snaps
local model=$1
local jq_filter='
# Find all snaps that have components
.snaps[] | select(.components)
# Then save the name of each snap in a variable
| .name as $snap
# Then for each entry that has "optional"
| .components | to_entries | map(select(.value.presence == "optional"))
# Output its name with the snap name prepended
| "\($snap)" + "+" + .[].key'
sed '/^$/,$d' -- "$model" \
| yaml_to_json \
| jq --raw-output "$jq_filter"
}
# Generation of the model:
# * At https://github.com/canonical/models one can find a repo of raw,
# unsigned, input .json files, and their signed .model equivalents.
@ -91,6 +110,10 @@ else
| grep -v -F -e pc-kernel -e snapd -e firmware-updater -e desktop-security-center)
fi
for comp in $(get_all_components "$model"); do
prepare_args+=(--comp "$comp")
done
channel=""
if [ -n "${CHANNEL:-}" ]; then
channel="--channel $CHANNEL"