From 64b05104aa7d4f899829b8ecf39e88fca8edc1e7 Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Tue, 25 Feb 2020 16:00:37 -0600 Subject: [PATCH] Address snap base regression after snap-tool removal With the removal of snap-tool failures are seen in image builds that do not have the 'core' snap included by the seed. This is the case for the minimized subproject of the ubuntu-cpc project where lxd/core is removed. In that subproject, any binary hook which adds a snap that is based on 'core' will not add 'core' and fail 'snap debug validate-seed'. snap-tool included the following logic in the 'snap-tool info' when determining snap bases: # Have "base" initialized to something meaningful. if self.is_core_snap(): snap_data["snap"]["base"] = "" elif snap_data["snap"].get("base") is None: snap_data["snap"]["base"] = "core" The snap store does not return a base if the base is core which makes this necessary. This patch looks for the base in 'snap info' output and if none is found (and the snap is not snapd or core) it assumes the base is 'core' and installs it. This restores the behavior lost in the migration from snap-tool to snap cli. --- debian/changelog | 6 ++++++ live-build/functions | 15 +++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/debian/changelog b/debian/changelog index 9642da69..aa3d06b1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +livecd-rootfs (2.620.2) eoan; urgency=medium + + * Address snap base regression after snap-tool removal + + -- Robert C Jennings Tue, 25 Feb 2020 16:15:48 -0600 + livecd-rootfs (2.620.1) eoan; urgency=medium * Use snap cli rather than custom snap-tool (LP: #1864252) diff --git a/live-build/functions b/live-build/functions index 82afa7b0..1113de03 100644 --- a/live-build/functions +++ b/live-build/functions @@ -477,12 +477,16 @@ _snap_preseed() { return fi + # Pre-seed snap's base case $SNAP_NAME in snapd) # snapd is self-contained, ignore base ;; + core|core[0-9][0-9]) + # core and core## are self-contained, ignore base + ;; *) - # Determine if and what core snap is needed + # Determine which core snap is needed local snap_info snap_info=$(snap info --verbose "${SNAP_NAME}") @@ -494,11 +498,10 @@ _snap_preseed() { local core_snap=$(echo "$snap_info" | grep '^base:' | awk '{print $2}') - # If $core_snap is not the empty string then SNAP itself is not a core - # snap and we must additionally seed the core snap. - if [ -n "$core_snap" ]; then - _snap_preseed $CHROOT_ROOT $core_snap stable - fi + # If snap info does not list a base use 'core' + core_snap=${core_snap:-core} + + _snap_preseed $CHROOT_ROOT $core_snap stable ;; esac