From 80ccea8d63d6283b8ae0aed6d52101c27dfef3c1 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Lallement Date: Mon, 14 Mar 2022 11:29:19 +0100 Subject: [PATCH] Separate WSL from CPC Create a separate WSL image than CPC so it can be managed independently. Co-authored-by: Didier Roche --- live-build/auto/build | 2 +- live-build/auto/config | 20 ++++-- live-build/ubuntu-cpc/hooks.d/base/wsl.binary | 64 ------------------- live-build/ubuntu-wsl/hooks/99-tar.binary | 24 +++++++ 4 files changed, 41 insertions(+), 69 deletions(-) delete mode 100755 live-build/ubuntu-cpc/hooks.d/base/wsl.binary create mode 100755 live-build/ubuntu-wsl/hooks/99-tar.binary diff --git a/live-build/auto/build b/live-build/auto/build index 8fdd359f..7621de65 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -155,7 +155,7 @@ Expire-Date: 0 lb bootstrap "$@" case $PROJECT:${SUBPROJECT:-} in - ubuntu-server:*|ubuntu-cpc:*|ubuntu:desktop-preinstalled) + ubuntu-server:*|ubuntu-cpc:*|ubuntu:desktop-preinstalled|ubuntu-wsl:*) # Set locale to C.UTF-8 by default. We should # probably do this for all images early in the # 18.10 cycle but for now just do it for diff --git a/live-build/auto/config b/live-build/auto/config index 477ae96e..bf3e6947 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -331,7 +331,7 @@ _get_live_passes () if [ -z "${IMAGEFORMAT:-}" ]; then case $PROJECT:${SUBPROJECT:-} in - ubuntu-cpc:*|ubuntu:desktop-preinstalled) + ubuntu-cpc:*|ubuntu:desktop-preinstalled|ubuntu-wsl:*) case $SUBARCH in raspi|intel-iot) IMAGEFORMAT=ubuntu-image @@ -548,6 +548,8 @@ case $IMAGEFORMAT in case $PROJECT in ubuntu-server) ;; + ubuntu-wsl) + ;; ubuntu) if [ "$SUBPROJECT" != "canary" ]; then add_package live casper @@ -584,7 +586,7 @@ if [ "$PREINSTALLED" = "true" ]; then ubuntu-server) add_package live oem-config-debconf ubiquity-frontend-debconf ;; - ubuntu-base|ubuntu-oci|ubuntu-cpc) + ubuntu-base|ubuntu-oci|ubuntu-cpc|ubuntu-wsl) ;; ubuntu) add_package live oem-config-gtk ubiquity-frontend-gtk @@ -892,6 +894,13 @@ case $PROJECT in OPTS="${OPTS:+$OPTS }--bootstrap-flavour=minimal" ;; + ubuntu-wsl) + add_task install minimal standard ubuntu-wsl + OPTS="${OPTS:+$OPTS }--linux-packages=none --initramfs=none" + KERNEL_FLAVOURS=none + BINARY_REMOVE_LINUX=false + ;; + ubuntu-cpc) KERNEL_FLAVOURS=virtual @@ -989,6 +998,9 @@ case $PROJECT:${SUBPROJECT:-} in ubuntu:*|kubuntu*:*|lubuntu*:*|xubuntu*:*|ubuntu-mate*:*|ubuntustudio*:*|ubuntukylin*:*|ubuntu-budgie*:*) BASE_SEED='desktop' ;; + ubuntu-wsl:*) + BASE_SEED='wsl' + ;; ubuntu-cpc:*) BASE_SEED='server' ;; @@ -1151,7 +1163,7 @@ if [ "${IMAGE_HAS_HARDCODED_PASSWORD:-}" = "1" ]; then fi case $PROJECT in - ubuntu-cpc|ubuntu-core|ubuntu-base|ubuntu-oci) + ubuntu-cpc|ubuntu-core|ubuntu-base|ubuntu-oci|ubuntu-wsl) # ubuntu-cpc gets this added in 025-create-groups.chroot, and we do # not want this group in projects that are effectively just chroots ;; @@ -1310,7 +1322,7 @@ EOF fi ;; - ubuntu-cpc:*|ubuntu-server:live|ubuntu:desktop-preinstalled) + ubuntu-cpc:*|ubuntu-server:live|ubuntu:desktop-preinstalled|ubuntu-wsl:*) # Ensure that most things e.g. includes.chroot are copied as is for entry in /usr/share/livecd-rootfs/live-build/${PROJECT}/*; do case $entry in diff --git a/live-build/ubuntu-cpc/hooks.d/base/wsl.binary b/live-build/ubuntu-cpc/hooks.d/base/wsl.binary deleted file mode 100755 index 3c2c589a..00000000 --- a/live-build/ubuntu-cpc/hooks.d/base/wsl.binary +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -eux -# vi: ts=4 expandtab -# -# Generate the compressed root directory for WSL - -case ${SUBPROJECT:-} in - minimized) - echo "Skipping minimized $0 build as WSL systems are designed to be interactive" - exit 0 - ;; - *) - ;; -esac - -case $ARCH in - amd64|arm64) - ;; - *) - echo "WSL root tarballs are not generated for $ARCH." - exit 0;; -esac - -if [ -n "${SUBARCH:-}" ]; then - echo "Skipping rootfs build for subarch flavor build" - exit 0 -fi - -. config/functions - -rootfs_dir=wslroot.dir - -# This is the directory created by create-root-dir.binary -cp -a rootfs.dir $rootfs_dir - -setup_mountpoint $rootfs_dir - -env DEBIAN_FRONTEND=noninteractive chroot $rootfs_dir apt-get -y -qq install ubuntu-wsl -env DEBIAN_FRONTEND=noninteractive chroot $rootfs_dir apt-get autoremove --purge --assume-yes - -# Install snap manually for now as config on cpc always assume the same base seed for every flavors -env UBUNTU_STORE_ARCH=${ARCH:-} SNAPPY_STORE_NO_CDN=1 chroot $rootfs_dir snap download --target-directory=/var/lib/snapd/snaps core20 -env UBUNTU_STORE_ARCH=${ARCH:-} SNAPPY_STORE_NO_CDN=1 chroot $rootfs_dir snap download --target-directory=/var/lib/snapd/snaps gtk-common-themes -env UBUNTU_STORE_ARCH=${ARCH:-} SNAPPY_STORE_NO_CDN=1 chroot $rootfs_dir snap download --target-directory=/var/lib/snapd/snaps --channel=latest/edge ubuntu-desktop-installer - - - -create_manifest $rootfs_dir livecd.ubuntu-cpc.wsl.rootfs.manifest -teardown_mountpoint $rootfs_dir - -# remove attributes not supported by WSL's tar -if [ -d $rootfs_dir/var/log/journal ]; then - setfattr -x system.posix_acl_access $rootfs_dir/var/log/journal - setfattr -x system.posix_acl_default $rootfs_dir/var/log/journal -fi - -# The reason not using just tar .. -C $rootfs_dir . is that using '.' was found -# not working once and checking if using the simpler command is safe needs -# verification of the app installation on all Windows 10 builds we support -# with WSL. -cd $rootfs_dir -tar --xattrs --sort=name -czf ../livecd.ubuntu-cpc.wsl.rootfs.tar.gz * -cd .. - -rm -rf $rootfs_dir diff --git a/live-build/ubuntu-wsl/hooks/99-tar.binary b/live-build/ubuntu-wsl/hooks/99-tar.binary new file mode 100755 index 00000000..c6a5e562 --- /dev/null +++ b/live-build/ubuntu-wsl/hooks/99-tar.binary @@ -0,0 +1,24 @@ +#!/bin/bash -eux +# vi: ts=4 expandtab +# +# Generate the compressed root directory for WSL manually. +# Type "plain" unfortunately does not execute lb_binary_* helpers. + +case $ARCH in + amd64|arm64) + ;; + *) + echo "WSL root tarballs are not generated for $ARCH." + exit 0;; +esac + +# The reason not using just tar .. -C chroot . is that using '.' was found +# not working once and checking if using the simpler command is safe needs +# verification of the app installation on all Windows 10 builds we support +# with WSL. +cd chroot +tar --xattrs --sort=name -czf ../livecd.ubuntu-wsl.rootfs.tar.gz * +cd .. + +# Remove initial ext4-formatted fs +rm -f binary/boot/filesystem.ext4