Skip to content

Commit ad581ef

Browse files
committed
osbuild: use bootc install to deploy the container
Instead of deploying the container to the tree then copy all the contents to the disk image, use bootc to directly manage the installation to the target filesystems. Right now this requires to use the image as the buildroot so this requires python (for osbuild). This is tracked in [1]. As we have python in rawhide now I duplicated the manifest and added a switch in the osbuild wrapper script. We can keep the manifest duplicated until we are confident to roll this to all streams. [1] bootc-dev/bootc#1410 Requires: bootc-dev/bootc#1460 bootc-dev/bootc#1451 osbuild/osbuild#2149 osbuild/osbuild#2152 All of which have landed in osbuild-159 and bootc 1.6
1 parent 6ce8e88 commit ad581ef

File tree

3 files changed

+600
-13
lines changed

3 files changed

+600
-13
lines changed

src/cmd-osbuild

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,14 +409,22 @@ main() {
409409
cmd="runvm_with_cache"
410410
fi
411411

412+
# Use the bootc install to-filesystem manifest if applicable
413+
bootc_suffix=""
414+
if should_use_bootc_install; then
415+
bootc_suffix=".bootc"
416+
fi
417+
418+
manifest_path="/usr/lib/coreos-assembler/osbuild-manifests/coreos.osbuild.${basearch}${bootc_suffix}.mpp.yaml"
419+
412420
# To get a shell in the osbuild supermin VM uncomment this.
413421
# osbuild can then be started with `bash tmp/build.<artifact>/cmd.sh`
414422
# See comment about checkpoints in runvm-osbuild
415423
# RUNVM_SHELL=1 \
416-
$cmd -- /usr/lib/coreos-assembler/runvm-osbuild \
417-
--config "${runvm_osbuild_config_json}" \
418-
--mpp "/usr/lib/coreos-assembler/osbuild-manifests/coreos.osbuild.${basearch}.mpp.yaml" \
419-
--outdir "${outdir}" \
424+
$cmd -- /usr/lib/coreos-assembler/runvm-osbuild \
425+
--config "${runvm_osbuild_config_json}" \
426+
--mpp "${manifest_path}" \
427+
--outdir "${outdir}" \
420428
--platforms "$(IFS=,; echo "${platforms[*]}")"
421429

422430
for platform in "${platforms[@]}"; do

src/cmdlib.sh

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,28 +148,47 @@ yaml2json() {
148148
python3 -c 'import sys, json, yaml; json.dump(yaml.safe_load(sys.stdin), sys.stdout, sort_keys=True)' < "$1" > "$2"
149149
}
150150

151-
should_build_with_buildah() {
152-
local variant manifest
153-
if [ -n "${COSA_BUILD_WITH_BUILDAH:-}" ]; then
154-
if [ "${COSA_BUILD_WITH_BUILDAH:-}" = 1 ]; then
151+
# Common helper to check for features that can be enabled via an env var or
152+
# in the manifest metadata.
153+
_should_enable_feature() {
154+
local env_var_name=$1
155+
local metadata_key=$2
156+
local env_var_value
157+
# Indirect expansion
158+
env_var_value=${!env_var_name:-}
159+
160+
if [ -n "${env_var_value}" ]; then
161+
if [ "${env_var_value}" = 1 ]; then
155162
return 0
156163
else
157164
return 1
158165
fi
159166
fi
167+
168+
pushd "${configdir}"
160169
# this slightly duplicates some logic in `prepare_build`, but meh...
161-
if [[ -f "src/config.json" ]]; then
162-
variant="$(jq --raw-output '."coreos-assembler.config-variant"' src/config.json)"
163-
manifest="src/config/manifest-${variant}.yaml"
170+
if [[ -f "../config.json" ]]; then
171+
variant="$(jq --raw-output '."coreos-assembler.config-variant"' ../config.json)"
172+
manifest="manifest-${variant}.yaml"
164173
else
165-
manifest="src/config/manifest.yaml"
174+
manifest="manifest.yaml"
166175
fi
167-
if [ "$(yq .metadata.build_with_buildah "${manifest}")" = true ]; then
176+
if [ "$(yq ".metadata.${metadata_key}" "${manifest}")" = true ]; then
177+
popd
168178
return 0
169179
fi
180+
popd
170181
return 1
171182
}
172183

184+
should_use_bootc_install() {
185+
_should_enable_feature "COSA_OSBUILD_USE_BOOTC_INSTALL" "use_bootc_install"
186+
}
187+
188+
should_build_with_buildah() {
189+
_should_enable_feature "COSA_BUILD_WITH_BUILDAH" "build_with_buildah"
190+
}
191+
173192
prepare_build() {
174193
preflight
175194
preflight_kvm

0 commit comments

Comments
 (0)