diff --git a/live-build/functions b/live-build/functions index d1ce2a61..17f2b075 100644 --- a/live-build/functions +++ b/live-build/functions @@ -760,6 +760,17 @@ snap_preseed() { snap_validate_seed() { local CHROOT_ROOT=$1 + if [ -e ${CHROOT_ROOT}/boot/vmlinuz ]; then + local kern_major_min=$(readlink --canonicalize --no-newline ${CHROOT_ROOT}/boot/vmlinuz | grep --extended-regexp --only-matching --max-count 1 '[0-9]+\.[0-9]+') + if [ -d /usr/share/livecd-rootfs/live-build/apparmor/${kern_major_min} ]; then + # if an Ubuntu version has different kernel apparmor features between LTS and HWE kernels + # a snap pre-seeding issue can occur, where the incorrect apparmor features are reported + # basic copy of a directory structure overriding the "generic" feature set + # which is tied to the LTS kernel + cp -R --verbose /usr/share/livecd-rootfs/live-build/apparmor/${kern_major_min}/* /usr/share/livecd-rootfs/live-build/apparmor/generic/ + fi + fi + if [ -e "${CHROOT_ROOT}/var/lib/snapd/seed/seed.yaml" ]; then snap debug validate-seed "${CHROOT_ROOT}/var/lib/snapd/seed/seed.yaml" /usr/lib/snapd/snap-preseed --reset $(realpath "${CHROOT_ROOT}")