From beb2bf156526465d1a31633831f3287dea0c4ef0 Mon Sep 17 00:00:00 2001 From: Carlos Nihelton Date: Fri, 27 Jun 2025 16:46:45 -0300 Subject: [PATCH] Implement WSL hooks for Focal The same hooks used to build Jammy and later --- .../ubuntu-wsl/hooks/00-enable-systemd.chroot | 10 ++++++++ .../hooks/01-distribution-conf.chroot | 20 +++++++++++++++ .../ubuntu-wsl/hooks/10-create-groups.chroot | 10 ++++++++ live-build/ubuntu-wsl/hooks/99-tar.binary | 25 +++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100755 live-build/ubuntu-wsl/hooks/00-enable-systemd.chroot create mode 100755 live-build/ubuntu-wsl/hooks/01-distribution-conf.chroot create mode 100755 live-build/ubuntu-wsl/hooks/10-create-groups.chroot create mode 100755 live-build/ubuntu-wsl/hooks/99-tar.binary diff --git a/live-build/ubuntu-wsl/hooks/00-enable-systemd.chroot b/live-build/ubuntu-wsl/hooks/00-enable-systemd.chroot new file mode 100755 index 00000000..67f9d852 --- /dev/null +++ b/live-build/ubuntu-wsl/hooks/00-enable-systemd.chroot @@ -0,0 +1,10 @@ +#!/bin/bash -eu +# vi: ts=4 expandtab +# +# Enable systemd by default on our WSL image +# + +cat </etc/wsl.conf +[boot] +systemd=true +EOF diff --git a/live-build/ubuntu-wsl/hooks/01-distribution-conf.chroot b/live-build/ubuntu-wsl/hooks/01-distribution-conf.chroot new file mode 100755 index 00000000..764867f7 --- /dev/null +++ b/live-build/ubuntu-wsl/hooks/01-distribution-conf.chroot @@ -0,0 +1,20 @@ +#!/bin/bash -eu +# vi: ts=4 expandtab +# +# Create wsl-distribution.conf for WSL setup +# + +source /etc/os-release + +cat </etc/wsl-distribution.conf +[oobe] +command = /usr/lib/wsl/wsl-setup +defaultUid = 1000 +defaultName = ${NAME}-${VERSION_ID} + +[shortcut] +icon = /usr/share/wsl/ubuntu.ico + +[windowsterminal] +ProfileTemplate = /usr/share/wsl/terminal-profile.json +EOF diff --git a/live-build/ubuntu-wsl/hooks/10-create-groups.chroot b/live-build/ubuntu-wsl/hooks/10-create-groups.chroot new file mode 100755 index 00000000..d731044a --- /dev/null +++ b/live-build/ubuntu-wsl/hooks/10-create-groups.chroot @@ -0,0 +1,10 @@ +#!/bin/bash +# +# Create the necessary groups +# + +echo "Adding admin group..." +addgroup --system --quiet admin + +echo "Adding netdev group..." +addgroup --system --quiet netdev 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..58c50efc --- /dev/null +++ b/live-build/ubuntu-wsl/hooks/99-tar.binary @@ -0,0 +1,25 @@ +#!/bin/bash -eu +# 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 + +## remove attributes not supported by WSL's tar +setfattr -x system.posix_acl_access chroot/var/log/journal +setfattr -x system.posix_acl_default chroot/var/log/journal + +# Create the rootfs as a .wsl extension +cd chroot +tar --xattrs --sort=name -czf ../livecd.$PROJECT${SUBARCH:+-$SUBARCH}.wsl * +cd .. + +# Remove initial ext4-formatted fs +rm -f binary/boot/filesystem.ext4