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
21 changes: 17 additions & 4 deletions src/cmd-osbuild
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,23 @@ main() {
else
cmd="runvm_with_cache"
fi
$cmd -- /usr/lib/coreos-assembler/runvm-osbuild \
--config "${runvm_osbuild_config_json}" \
--mpp "/usr/lib/coreos-assembler/osbuild-manifests/coreos.osbuild.${basearch}.mpp.yaml" \
--outdir "${outdir}" \

# Use the bootc install to-filesystem manifest if applicable
bootc_suffix=""
if should_use_bootc_install; then
bootc_suffix=".bootc"
fi

manifest_path="/usr/lib/coreos-assembler/osbuild-manifests/coreos.osbuild.${basearch}${bootc_suffix}.mpp.yaml"

# To get a shell in the osbuild supermin VM uncomment this.
# osbuild can then be started with `bash tmp/build.<artifact>/cmd.sh`
# See comment about checkpoints in runvm-osbuild
# RUNVM_SHELL=1 \
$cmd -- /usr/lib/coreos-assembler/runvm-osbuild \
--config "${runvm_osbuild_config_json}" \
--mpp "${manifest_path}" \
--outdir "${outdir}" \
--platforms "$(IFS=,; echo "${platforms[*]}")"

for platform in "${platforms[@]}"; do
Expand Down
54 changes: 40 additions & 14 deletions src/cmdlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,28 +148,53 @@ yaml2json() {
python3 -c 'import sys, json, yaml; json.dump(yaml.safe_load(sys.stdin), sys.stdout, sort_keys=True)' < "$1" > "$2"
}

should_build_with_buildah() {
local variant manifest
if [ -n "${COSA_BUILD_WITH_BUILDAH:-}" ]; then
if [ "${COSA_BUILD_WITH_BUILDAH:-}" = 1 ]; then
# Common helper to check for features that can be enabled via an env var or
# in the manifest metadata.
_should_enable_feature() {
local env_var_name=$1
local metadata_key=$2
local env_var_value
# Indirect expansion
env_var_value=${!env_var_name:-}

if [ -n "${env_var_value}" ]; then
if [ "${env_var_value}" = 1 ]; then
return 0
else
return 1
fi
fi

# Make sure we are in the config directory (e.g. cmd-osbuild set a different working directory).
# When called very early (e.g. cmd-fetch), configdir isn't initialized yet so we assume we are in the top
# cosa initialized dir and use `src/config`.
# We redirect the output to /dev/null to avoid the noisy `dirs` output.
set +u
pushd "${configdir:-src/config}" > /dev/null
set -u
# this slightly duplicates some logic in `prepare_build`, but meh...
if [[ -f "src/config.json" ]]; then
variant="$(jq --raw-output '."coreos-assembler.config-variant"' src/config.json)"
manifest="src/config/manifest-${variant}.yaml"
if [[ -f "../config.json" ]]; then
variant="$(jq --raw-output '."coreos-assembler.config-variant"' ../config.json)"
manifest="manifest-${variant}.yaml"
else
manifest="src/config/manifest.yaml"
manifest="manifest.yaml"
fi
if [ "$(yq .metadata.build_with_buildah "${manifest}")" = true ]; then
if [ "$(yq ".metadata.${metadata_key}" "${manifest}")" = true ]; then
popd > /dev/null
return 0
fi
popd > /dev/null
return 1
}

should_use_bootc_install() {
_should_enable_feature "COSA_OSBUILD_USE_BOOTC_INSTALL" "use_bootc_install"
}

should_build_with_buildah() {
_should_enable_feature "COSA_BUILD_WITH_BUILDAH" "build_with_buildah"
}

prepare_build() {
preflight
preflight_kvm
Expand Down Expand Up @@ -758,10 +783,11 @@ runvm() {

# include COSA in the image
find /usr/lib/coreos-assembler/ -type f > "${vmpreparedir}/hostfiles"
cat <<EOF >> "${vmpreparedir}/hostfiles"
/usr/lib/osbuild/stages/org.osbuild.coreos.live-artifacts.mono
/usr/lib/osbuild/stages/org.osbuild.coreos.live-artifacts.mono.meta.json
EOF
# Include arbitrary files from the host
# cat <<EOF >> "${vmpreparedir}/hostfiles"
# /usr/lib/osbuild/stages/org.osbuild.ln
# /usr/lib/osbuild/stages/org.osbuild.ln.meta.json
# EOF

# and include all GPG keys
echo '/etc/pki/rpm-gpg/*' >> "${vmpreparedir}/hostfiles"
Expand All @@ -787,7 +813,7 @@ rc=0
if [ -z "${RUNVM_SHELL:-}" ]; then
(cd ${workdir}; bash ${tmp_builddir}/cmd.sh |& tee /dev/virtio-ports/cosa-cmdout) || rc=\$?
else
(cd ${workdir}; bash)
(cd ${workdir}; RUNVM_SHELL=${RUNVM_SHELL:-} bash)
fi
echo \$rc > ${rc_file}
if [ -n "\${cachedev}" ]; then
Expand Down
Loading
Loading