[Merge] ~itrue/livecd-rootfs:add-kiwi-support into livecd-rootfs:ubuntu/master
Loïc Minier
mp+439825 at code.launchpad.net
Wed Mar 29 16:22:20 UTC 2023
(Damn, my first review comments were lost because I didn't properly submit this, sorry)
I think the high-level should be PROJECT=nemos, and SUBPROJECT=someimagetype; the livecd-rootfs part should use $SUITE to map to the relevant filename here, rather than expecting the Launchpad livefs build to pass a specific filename each time.
Diff comments:
> diff --git a/live-build/auto/build b/live-build/auto/build
> index ddbb733..81eba6e 100755
> --- a/live-build/auto/build
> +++ b/live-build/auto/build
> @@ -117,6 +117,114 @@ if [ "${IMAGEFORMAT:-}" = "ubuntu-image" ]; then
> fi
>
> exit 0
> +elif [ "${IMAGEFORMAT:-}" = "kiwi" ]; then
> + # Kiwi refers to target build configurations as "descriptions". These
> + # descriptions are XML files (generally called either "appliance.kiwi"
> + # or "config.xml" and reside in a folder alongside any additional
> + # scripts and files that are needed by the target system. This can
> + # include any arbitrary script that will be executed inside a chroot
> + # environment. The user must specify the folder the description resides
> + # in, rather than the file itself, due to the way Kiwi works.
> + # Here, the user can directly specify the desired path to the
> + # description by setting the KIWI_DESCRIPTION variable, or use the
> + # default path, which is then determined through the use of the
> + # PROJECT variable, i.e. /usr/share/kiwi/$SUBPROJECT/$KIWI_ARCH
I think SUBPROJECT should be a high-level reference to the type of image ("preinstalled", "generic", something else or plain empty) that gets translated into a path in the list of image definitions by livecd-rootfs
> + if [ -z "${KIWI_DESCRIPTION:-}" ]; then
> + if [ -z "${SUBPROJECT:-}" ]; then
> + echo "Kiwi error: SUBPROJECT must be specified when " \
> + "KIWI_DESCRIPTION is not set"
> + exit 1
> + fi
> + if [ -z "${KIWI_ROOT:-}" ]; then
> + KIWI_ROOT="/usr/share/kiwi"
> + fi
> + # Kiwi uses a lot of RPM-style terminology, including referring
> + # to arm64 as aarch64. Account for this here.
> + case $ARCH in
> + arm64|aarch64)
> + KIWI_ARCH="aarch64"
> + ;;
> + x86|amd64)
> + KIWI_ARCH="x86"
> + ;;
> + *)
> + KIWI_ARCH="${ARCH}"
> + esac
> + KIWI_DESCRIPTION="${KIWI_ROOT}/${SUBPROJECT}/${KIWI_ARCH}"
> + fi
> +
> + if [ ! -e "${KIWI_DESCRIPTION}/appliance.kiwi" ] &&
> + [ ! -e "${KIWI_DESCRIPTION}/config.xml" ]; then
> + echo "Kiwi error: appliance description not found in path " \
> + "\"${KIWI_DESCRIPTION}\""
> + exit 1
> + fi
> +
> + # Kiwi provides a variety of configuration options for the build
> + # system that are not a part of the image configuration itself, and
> + # instead need to be managed using a YAML file. If the user has
> + # provided a file using the KIWI_CONFIG variable, use that. Otherwise,
> + # use a configuration file with some sensible defaults.
> + if [ -n "${KIWI_CONFIG:-}" ]; then
> + if [ -e "${KIWI_CONFIG}" ]; then
> + KIWI_CONFIG="--config ${KIWI_CONFIG}"
> + else
> + echo "Kiwi error: configuration file does not exist:" \
> + " \"${KIWI_CONFIG}\""
> + exit 1
> + fi
> + else
> + DEFAULT_KIWI_CONFIG="$(mktemp)"
> + cat << EOF > ${DEFAULT_KIWI_CONFIG}
> +---
> +runtime_checks:
> + - disable:
> + # This check needs to be disabled in Ubuntu because the Kiwi package
> + # "dracut-kiwi-overlay" does not exist in Ubuntu/Debian, and we cannot
> + # add it to the image.
> + - "check_dracut_module_for_disk_overlay_in_package_list"
> +
> +mapper:
> + # Tell Kiwi to use kpartx for setting up the partitions, as its device
> + # mappings are more flexible and work better with complex disk configurations.
> + - part_mapper: "kpartx"
> +
> +credentials:
> + # Used for signing dm-verity block data
> + - verification_metadata_signing_key_file: "/etc/ssl/private/ssl-cert-snakeoil.key"
> +EOF
> + KIWI_CONFIG="--config ${DEFAULT_KIWI_CONFIG}"
> + fi
> +
> + # Kiwi allows the use of different profiles inside the description
> + # file. This allows different configuration blocks to be disabled or
> + # enabled at build-time. We allow the user to specify this here with
> + # the KIWI_PROFILE variable.
> + if [ -n "${KIWI_PROFILE:-}" ]; then
> + KIWI_PROFILE="--profile ${KIWI_PROFILE}"
> + else
> + KIWI_PROFILE=""
> + fi
> +
> + # Run the Kiwi build. Not that the output directory must not exist
> + # before this runs, otherwise Kiwi will complain and exit
> + kiwi-ng --debug ${KIWI_CONFIG} ${KIWI_PROFILE} \
> + system build --description "${KIWI_DESCRIPTION}" \
> + --target-dir output
> +
> + # Clean up if we created the config file
> + if [ -n "${DEFAULT_KIWI_CONFIG:-}" ]; then
> + rm "${DEFAULT_KIWI_CONFIG}"
> + fi
> +
> + # Move the files around so that we have the same output as ubuntu-image
> + mv output/*.raw "${PREFIX}".img
> + xz -0 -T4 "${PREFIX}".img
> +
> + # Also link the output image to a filename that cdimage expects
> + ln "${PREFIX}".img.xz "livecd.${PROJECT}.disk1.img.xz"
> +
> + exit 0
> fi
>
> # Setup cleanup function
> diff --git a/live-build/auto/config b/live-build/auto/config
> index 1f81218..eab2665 100755
> --- a/live-build/auto/config
> +++ b/live-build/auto/config
> @@ -345,6 +345,9 @@ if [ -z "${IMAGEFORMAT:-}" ]; then
> ubuntu-server:live|ubuntu-mini-iso:)
> IMAGEFORMAT=plain
> ;;
> + kiwi:*)
I think this should be nemos
> + IMAGEFORMAT=kiwi
> + ;;
> esac
> fi
>
> @@ -1045,6 +1052,9 @@ case $PROJECT in
> OPTS="${OPTS:+$OPTS }--ext-fudge-factor=15"
> ;;
>
> + kiwi)
Probably nemos as well
> + ;;
> +
> *)
> echo "unknown project $PROJECT" >&2
> exit 2
--
https://code.launchpad.net/~itrue/livecd-rootfs/+git/livecd-rootfs/+merge/439825
Your team Ubuntu Core Development Team is requested to review the proposed merge of ~itrue/livecd-rootfs:add-kiwi-support into livecd-rootfs:ubuntu/master.
More information about the Ubuntu-reviews
mailing list