snap preseeding: capture Ubuntu snap seeding policy in code

When no channel is given for a pre-seeded snap, the channel
should be stable/ubuntu-XX.YY to match Ubuntu policy.

This patch adds the LB_DISTRIBUTION var to config/{binary,chroot}
to have a common way of determining the Ubuntu XX.YY version
number between hooks and auto/build.
ubuntu/cosmic
Robert C Jennings 7 years ago
parent cbcb5d3ed8
commit 73dba1f31a

@ -39,10 +39,8 @@ preinstall_snaps() {
lb chroot_resolv install lb chroot_resolv install
snap_prepare chroot snap_prepare chroot
snap_channel="stable/ubuntu-$(distro-info --series="$LB_DISTRIBUTION" \
-r | awk '{ print $1 }')"
for snap in "$@"; do for snap in "$@"; do
snap_preseed chroot "${snap}" "$snap_channel" snap_preseed chroot "${snap}"
done done
lb chroot_resolv remove lb chroot_resolv remove
} }

@ -825,9 +825,11 @@ lb config noauto \
echo "LB_CHROOT_HOOKS=\"$CHROOT_HOOKS\"" >> config/chroot echo "LB_CHROOT_HOOKS=\"$CHROOT_HOOKS\"" >> config/chroot
echo "SUBPROJECT=\"${SUBPROJECT:-}\"" >> config/chroot echo "SUBPROJECT=\"${SUBPROJECT:-}\"" >> config/chroot
echo "LB_DISTRIBUTION=\"$SUITE\"" >> config/chroot
echo "LB_BINARY_HOOKS=\"$BINARY_HOOKS\"" >> config/binary echo "LB_BINARY_HOOKS=\"$BINARY_HOOKS\"" >> config/binary
echo "BUILDSTAMP=\"$NOW\"" >> config/binary echo "BUILDSTAMP=\"$NOW\"" >> config/binary
echo "SUBPROJECT=\"${SUBPROJECT:-}\"" >> config/binary echo "SUBPROJECT=\"${SUBPROJECT:-}\"" >> config/binary
echo "LB_DISTRIBUTION=\"$SUITE\"" >> config/binary
case $ARCH+$SUBARCH in case $ARCH+$SUBARCH in
armhf+raspi2) armhf+raspi2)

@ -362,6 +362,11 @@ recreate_initramfs() {
mv "$CHROOT"/boot/initrd.img-* $DESTDIR mv "$CHROOT"/boot/initrd.img-* $DESTDIR
} }
release_ver() {
# Return the release version number
distro-info --series="$LB_DISTRIBUTION" -r | awk '{ print $1 }'
}
_snap_preseed() { _snap_preseed() {
# Download the snap/assertion and add to the preseed # Download the snap/assertion and add to the preseed
local CHROOT_ROOT=$1 local CHROOT_ROOT=$1
@ -442,7 +447,9 @@ snap_preseed() {
# Preseeed a snap in the image # Preseeed a snap in the image
local CHROOT_ROOT=$1 local CHROOT_ROOT=$1
local SNAP=$2 local SNAP=$2
local CHANNEL=${3:-stable} # Per Ubuntu policy, all seeded snaps (with the exception of the core
# snap) must pull from stable/ubuntu-$(release_ver) as their channel.
local CHANNEL=${3:-"stable/ubuntu-$(release_ver)"}
snap_prepare $CHROOT_ROOT snap_prepare $CHROOT_ROOT
_snap_preseed $CHROOT_ROOT $SNAP $CHANNEL _snap_preseed $CHROOT_ROOT $SNAP $CHANNEL

Loading…
Cancel
Save