Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions builder/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ clean:
features_platforms="$$(./parse_features $(PARSE_FEATURES_ARGS) --feature-dir features --cname '$*' platforms)"
features_elements="$$(./parse_features $(PARSE_FEATURES_ARGS) --feature-dir features --cname '$*' elements)"
features_flags="$$(./parse_features $(PARSE_FEATURES_ARGS) --feature-dir features --cname '$*' flags)"
cname_base="$$(./parse_features $(PARSE_FEATURES_ARGS) --feature-dir features --cname '$*' cname_base)"
BUILDER_CNAME='$*'
BUILDER_CNAME_BASE="$$cname_base"
BUILDER_VERSION='$(call cname_version,$*)'
BUILDER_ARCH='$(call cname_arch,$*)'
BUILDER_TIMESTAMP='$(TIMESTAMP)'
Expand All @@ -66,7 +68,7 @@ clean:
BUILDER_FEATURES_PLATFORMS="$$features_platforms"
BUILDER_FEATURES_ELEMENTS="$$features_elements"
BUILDER_FEATURES_FLAGS="$$features_flags"
export BUILDER_CNAME BUILDER_VERSION BUILDER_ARCH BUILDER_TIMESTAMP BUILDER_COMMIT BUILDER_FEATURES BUILDER_FEATURES_PLATFORMS BUILDER_FEATURES_ELEMENTS BUILDER_FEATURES_FLAGS
export BUILDER_CNAME BUILDER_CNAME_BASE BUILDER_VERSION BUILDER_ARCH BUILDER_TIMESTAMP BUILDER_COMMIT BUILDER_FEATURES BUILDER_FEATURES_PLATFORMS BUILDER_FEATURES_ELEMENTS BUILDER_FEATURES_FLAGS
./configure '$(word 1,$^)' '$@'

define artifact_template =
Expand All @@ -79,7 +81,9 @@ define artifact_template =
features_platforms="$$$$(./parse_features $(PARSE_FEATURES_ARGS) --feature-dir features --cname '$$*' platforms)"
features_elements="$$$$(./parse_features $(PARSE_FEATURES_ARGS) --feature-dir features --cname '$$*' elements)"
features_flags="$$$$(./parse_features $(PARSE_FEATURES_ARGS) --feature-dir features --cname '$$*' flags)"
cname_base="$$$$(./parse_features $(PARSE_FEATURES_ARGS) --feature-dir features --cname '$$*' cname_base)"
BUILDER_CNAME='$$*'
BUILDER_CNAME_BASE="$$$$cname_base"
BUILDER_VERSION='$$(call cname_version,$$*)'
BUILDER_ARCH='$$(call cname_arch,$$*)'
BUILDER_TIMESTAMP='$$(TIMESTAMP)'
Expand All @@ -88,7 +92,7 @@ define artifact_template =
BUILDER_FEATURES_PLATFORMS="$$$$features_platforms"
BUILDER_FEATURES_ELEMENTS="$$$$features_elements"
BUILDER_FEATURES_FLAGS="$$$$features_flags"
export BUILDER_CNAME BUILDER_VERSION BUILDER_ARCH BUILDER_TIMESTAMP BUILDER_COMMIT BUILDER_FEATURES BUILDER_FEATURES_PLATFORMS BUILDER_FEATURES_ELEMENTS BUILDER_FEATURES_FLAGS
export BUILDER_CNAME BUILDER_CNAME_BASE BUILDER_VERSION BUILDER_ARCH BUILDER_TIMESTAMP BUILDER_COMMIT BUILDER_FEATURES BUILDER_FEATURES_PLATFORMS BUILDER_FEATURES_ELEMENTS BUILDER_FEATURES_FLAGS
"./$$$$script" "$$$$input" '$$@'
endef

Expand Down
33 changes: 18 additions & 15 deletions builder/image.requirements
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,31 @@ set -euo pipefail

features_dir="${FEATURES_DIR:-/builder/features}"

# Built-in keys. requirements.mod scripts may extend this array via:
# requirements_keys+=(mykey)
# mykey=true
requirements_keys=(arch)
export arch="$BUILDER_ARCH"
# Requirements keys, registered as "name=default" entries. A feature's
# requirements.mod appends its key with the default to emit when the feature is
# not selected, and sets the active value, e.g.:
# requirements_keys+=(uefi=false) # boolean, default false
# uefi=true
# requirements_keys+=(publishing_group=) # string, default empty
# publishing_group="value"
requirements_keys=("arch=$BUILDER_ARCH")

# Pass 1: source every requirements.mod to discover all keys any feature
# may contribute, then reset discovered keys to "false" as defaults.
# This ensures output keys are stable regardless of which features are selected.
# Pass 1: source every requirements.mod to discover all keys any feature may
# contribute, so the output keys are stable regardless of which features are
# selected.
for req_mod in "$features_dir"/*/requirements.mod; do
[ -e "$req_mod" ] || continue
# shellcheck source=/dev/null
source "$req_mod"
done

# Reset all discovered (non-arch) keys to false as defaults for pass 2.
for key in "${requirements_keys[@]}"; do
[ "$key" = arch ] && continue
declare "$key=false"
# Reset every discovered key to its registered default before pass 2.
for entry in "${requirements_keys[@]}"; do
declare "${entry%%=*}=${entry#*=}"
done

# Pass 2: source only the selected features' requirements.mod files,
# allowing them to override the defaults set above.
# Pass 2: source only the selected features' requirements.mod files, letting
# them override the defaults set above.
IFS=',' read -r -a features <<< "$BUILDER_FEATURES"
for feature in "${features[@]}"; do
[ -z "$feature" ] && continue
Expand All @@ -36,6 +38,7 @@ for feature in "${features[@]}"; do
done

# Emit each key alphabetically (duplicates silently dropped by sort -u).
for key in "${requirements_keys[@]}"; do
for entry in "${requirements_keys[@]}"; do
key="${entry%%=*}"
printf '%s=%s\n' "$key" "${!key}"
done | sort -u -t= -k1,1 > "$2"
Loading