Simplify snap model assertion customization

ubuntu/cosmic
Robert C Jennings 6 years ago
parent 97b0bbeed3
commit 8d603cc87f

@ -432,17 +432,10 @@ snap_prepare_assertions() {
if [ -e "$model_assertion" ] ; then if [ -e "$model_assertion" ] ; then
existing_model=$(sed -n 's/^model: \(.*\)$/\1/p' $model_assertion) existing_model=$(sed -n 's/^model: \(.*\)$/\1/p' $model_assertion)
existing_brand=$(sed -n 's/^brand-id: \(.*\)$/\1/p' $model_assertion) existing_brand=$(sed -n 's/^brand-id: \(.*\)$/\1/p' $model_assertion)
if [ "$existing_model" == "generic-classic" ] && echo "snap_prepare_assertions: replacing $existing_brand:$existing_model with $brand:$model"
[ "$existing_brand" == "generic" ] && rm "$model_assertion"
( [ "$existing_model" != "$model" ] || rm "$account_key_assertion"
[ "$existing_brand" != "$brand" ] ); then rm "$account_assertion"
echo "snap_prepare_assertions: clearing $existing_brand:$existing_model for $brand:$model"
rm "$model_assertion"
rm "$account_key_assertion"
rm "$account_assertion"
else
echo "snap_prepare_assertions: not replacing $existing_brand:$existing_model with $brand:$model"
fi
fi fi
if ! [ -e "$model_assertion" ] ; then if ! [ -e "$model_assertion" ] ; then
@ -486,13 +479,12 @@ snap_prepare() {
} }
snap_preseed() { snap_preseed() {
# Preseed a snap in the image # Preseed a snap in the image (snap_prepare must be called once prior)
local CHROOT_ROOT=$1 local CHROOT_ROOT=$1
local SNAP=$2 local SNAP=$2
# Per Ubuntu policy, all seeded snaps (with the exception of the core # Per Ubuntu policy, all seeded snaps (with the exception of the core
# snap) must pull from stable/ubuntu-$(release_ver) as their channel. # snap) must pull from stable/ubuntu-$(release_ver) as their channel.
local CHANNEL=${3:-"stable/ubuntu-$(release_ver)"} local CHANNEL=${3:-"stable/ubuntu-$(release_ver)"}
snap_prepare $CHROOT_ROOT
_snap_preseed $CHROOT_ROOT $SNAP $CHANNEL _snap_preseed $CHROOT_ROOT $SNAP $CHANNEL
} }

Loading…
Cancel
Save