Check exit status of snap-tool info call while determining base snap

u-i-cloud-init
Tobias Koch 6 years ago
parent 7ec97a627a
commit 18468c4218

8
debian/changelog vendored

@ -1,3 +1,11 @@
livecd-rootfs (2.600) UNRELEASED; urgency=medium
[ Tobias Koch ]
* Do proper error checking when calling snap-tool info to determine
the base of a snap.
-- Tobias Koch <tobias.koch@canonical.com> Mon, 15 Jul 2019 07:44:38 +0200
livecd-rootfs (2.599) eoan; urgency=medium livecd-rootfs (2.599) eoan; urgency=medium
* Append the list of seeded snaps to manifests for all regular images. * Append the list of seeded snaps to manifests for all regular images.

@ -483,12 +483,20 @@ _snap_preseed() {
;; ;;
*) *)
# Determine if and what core snap is needed # Determine if and what core snap is needed
local core_snap=$(/usr/share/livecd-rootfs/snap-tool info \ local snap_info
snap_info=$(/usr/share/livecd-rootfs/snap-tool info \
--cohort-key="${COHORT_KEY:-}" \ --cohort-key="${COHORT_KEY:-}" \
--channel="$CHANNEL" "$SNAP_NAME" | \ --channel="$CHANNEL" "${SNAP_NAME}" \
grep '^base:' | awk '{print $2}'
) )
if [ $? -ne 0 ]; then
echo "Failed to retrieve base of $SNAP_NAME!"
exit 1
fi
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 # If $core_snap is not the empty string then SNAP itself is not a core
# snap and we must additionally seed the core snap. # snap and we must additionally seed the core snap.
if [ -n "$core_snap" ]; then if [ -n "$core_snap" ]; then

Loading…
Cancel
Save