~vorlon/livecd-rootfs/initramfsless-everywhere

« back to all changes in this revision

Viewing changes to live-build/functions

MergeĀ lp:~rcj/livecd-rootfs/trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
427
427
    local brand="$(echo $CUSTOM_BRAND_MODEL | cut -d: -f 1)"
428
428
    local model="$(echo $CUSTOM_BRAND_MODEL | cut -d: -f 2)"
429
429
 
 
430
    # Clear the assertions if they already exist
 
431
    if [ -e "$model_assertion" ] ; then
 
432
        existing_model=$(awk '/^model: / {print $2}' $model_assertion)
 
433
        existing_brand=$(awk '/^brand-id: / {print $2}' $model_assertion)
 
434
        echo "snap_prepare_assertions: replacing $existing_brand:$existing_model with $brand:$model"
 
435
        rm "$model_assertion"
 
436
        rm "$account_key_assertion"
 
437
        rm "$account_assertion"
 
438
    fi
 
439
 
430
440
    if ! [ -e "$model_assertion" ] ; then
431
441
        snap known --remote model series=16 \
432
442
            model=$model brand-id=$brand \
441
451
            > "$account_key_assertion"
442
452
    fi
443
453
 
444
 
 
445
454
    if ! [ -e "$account_assertion" ] ; then
446
455
        local account=$(sed -n -e's/account-id: //p' < "$account_key_assertion")
447
456
        snap known --remote account account-id=$account \
468
477
}
469
478
 
470
479
snap_preseed() {
471
 
    # Preseed a snap in the image
 
480
    # Preseed a snap in the image (snap_prepare must be called once prior)
472
481
    local CHROOT_ROOT=$1
473
482
    local SNAP=$2
474
483
    # Per Ubuntu policy, all seeded snaps (with the exception of the core
475
484
    # snap) must pull from stable/ubuntu-$(release_ver) as their channel.
476
485
    local CHANNEL=${3:-"stable/ubuntu-$(release_ver)"}
477
486
 
478
 
    snap_prepare $CHROOT_ROOT
 
487
    if [ ! -e "$CHROOT_ROOT/var/lib/snapd/seed/assertions/model" ]; then
 
488
        echo "ERROR: Snap model assertion not present, snap_prepare must be called"
 
489
        exit 1
 
490
    fi
479
491
    _snap_preseed $CHROOT_ROOT $SNAP $CHANNEL
480
492
}