From 0cf50e8fafb9123eafd4cb400b288cfb9695e34e Mon Sep 17 00:00:00 2001 From: wangyueliang Date: Wed, 10 Jul 2024 14:23:01 +0800 Subject: [PATCH] Add POC for building with osbuild, but we dont support it temporarily. Currently not supported for NestOS. Due to significant changes in the development of upstream toolchain software, support will be provided after these stable and introduction to the OpenEuler. [upstream] 5a1bd0450 add proof of concept for building with osbuild --- src/cmd-buildextend-metal | 19 +++++++++++++------ src/deps.txt | 6 ------ src/runvm-osbuild | 30 ++++++++++++++++++++++++++++++ src/vmdeps.txt | 4 ++++ 4 files changed, 47 insertions(+), 12 deletions(-) create mode 100755 src/runvm-osbuild diff --git a/src/cmd-buildextend-metal b/src/cmd-buildextend-metal index 4be486d8..990210bf 100755 --- a/src/cmd-buildextend-metal +++ b/src/cmd-buildextend-metal @@ -262,13 +262,20 @@ cat "${image_json}" image-dynamic.json | jq -s add > image-for-disk.json platforms_json="${workdir}/tmp/platforms.json" yaml2json "${configdir}/platforms.yaml" "${platforms_json}" +if [ "${image_type}" == "qemu" ] && [ "${COSA_USE_OSBUILD:-}" != "" ]; then + runvm -- /usr/lib/coreos-assembler/runvm-osbuild \ + "${ostree_repo}" "${ref}" \ + /usr/lib/coreos-assembler/coreos.osbuild.mpp.yaml \ + "${path}.tmp" +else runvm "${qemu_args[@]}" -- \ - /usr/lib/coreos-assembler/create_disk.sh \ - --config "$(pwd)"/image-for-disk.json \ - --kargs "${kargs}" \ - --platform "${ignition_platform_id}" \ - --platforms-json "${platforms_json}" \ - "${disk_args[@]}" + /usr/lib/coreos-assembler/create_disk.sh \ + --config "$(pwd)"/image-for-disk.json \ + --kargs "${kargs}" \ + --platform "${ignition_platform_id}" \ + --platforms-json "${platforms_json}" \ + "${disk_args[@]}" +fi if [[ $secure_execution -eq "1" && -z "${hostkey}" ]]; then /usr/lib/coreos-assembler/secex-genprotimgvm-scripts/runvm.sh \ diff --git a/src/deps.txt b/src/deps.txt index 5d38e443..da8dba87 100644 --- a/src/deps.txt +++ b/src/deps.txt @@ -16,12 +16,6 @@ dumb-init rpm-ostree createrepo_c openssh-clients python3-createrepo_c dnf-utils -# We don't actually use this right now but we intend to share -# code in the future. -# XXX: temporarily disabled until we fix -# https://github.com/osbuild/osbuild-composer/issues/1915 -# osbuild-composer - # For generating ISO images genisoimage diff --git a/src/runvm-osbuild b/src/runvm-osbuild new file mode 100755 index 00000000..92328a75 --- /dev/null +++ b/src/runvm-osbuild @@ -0,0 +1,30 @@ +#!/bin/bash +set -eux -o pipefail + +repo=$1 +ref=$2 +mppyaml=$3 +path=$4 + +# Since it doesn't exist create loop-control +mknod /dev/loop-control c 10 237 + +# get away from the virtiofs share because the xattrs that +# are written out by the ostree deploy will cause SELinux denials. +mkdir /root/osbuild && cd /root/osbuild + +# Run through the preprocessor +osbuild-mpp \ + -D ref=\""${ref}"\" \ + -D repourl=\""file://${repo}"\" \ + "${mppyaml}" \ + processed.json + +# Build the image +osbuild --store store/ \ + --output-directory out/ \ + --export qcow2 processed.json + + +# Copy it out to the specified location +cp out/qcow2/disk.qcow2 "${path}" diff --git a/src/vmdeps.txt b/src/vmdeps.txt index 2cc6098e..37fb0b3e 100644 --- a/src/vmdeps.txt +++ b/src/vmdeps.txt @@ -35,3 +35,7 @@ tar # needed for extensions container build podman + +# For running osbuild +# NestOS currently does not plan to introduce the osbuild build way +# osbuild osbuild-ostree osbuild-selinux osbuild-tools python3-pyrsistent -- Gitee