Skip to content

Commit 09f7d26

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 09f7d26

File tree

3 files changed

+592
-9
lines changed

3 files changed

+592
-9
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: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,17 @@ 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
@@ -164,12 +171,20 @@ should_build_with_buildah() {
164171
else
165172
manifest="src/config/manifest.yaml"
166173
fi
167-
if [ "$(yq .metadata.build_with_buildah "${manifest}")" = true ]; then
174+
if [ "$(yq ".metadata.${metadata_key}" "${manifest}")" = true ]; then
168175
return 0
169176
fi
170177
return 1
171178
}
172179

180+
should_use_bootc_install() {
181+
_should_enable_feature "COSA_OSBUILD_USE_BOOTC_INSTALL" "use_bootc_install"
182+
}
183+
184+
should_build_with_buildah() {
185+
_should_enable_feature "COSA_BUILD_WITH_BUILDAH" "build_with_buildah"
186+
}
187+
173188
prepare_build() {
174189
preflight
175190
preflight_kvm

0 commit comments

Comments
 (0)