You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
livecd-rootfs/live-build/ubuntu-server/hooks/032-installer-squashfs.binary

99 lines
2.4 KiB

#!/bin/bash -ex
# vi: ts=4 noexpandtab
#
# Generate a squashfs root and manifest
set -x
echo "032-installer-squashfs.binary"
case $IMAGE_TARGETS in
""|*squashfs*)
;;
*)
echo "Skipping squashfs build"
exit 0
;;
esac
if [ -n "$SUBARCH" ]; then
echo "Skipping rootfs build for subarch flavor build"
exit 0
fi
. config/functions
SQUASH_ROOT=binary/boot/squashfs.dir
OVERLAY_ROOT=binary/overlay
mkdir -p "$OVERLAY_ROOT"
# Create an installer squashfs layer
mount_overlay "$SQUASH_ROOT/" "$OVERLAY_ROOT/" "$SQUASH_ROOT/"
setup_mountpoint binary/boot/squashfs.dir
# Prepare installer layer.
# Install any requirements for the installer, for things we don't want
# to see on the installed system
chroot $SQUASH_ROOT apt-get update
chroot $SQUASH_ROOT apt-get -y install user-setup
chroot $SQUASH_ROOT apt-get -y install curtin
# Don't let cloud-init run in the live session.
touch $SQUASH_ROOT/etc/cloud/cloud-init.disabled
# Do the snap seeding dance.
chroot $SQUASH_ROOT mkdir -p /var/lib/snapd/seed/snaps /var/lib/snapd/seed/assertions
chroot $SQUASH_ROOT sh -c '
set -x;
cd /var/lib/snapd/seed;
sudo SNAPPY_STORE_NO_CDN=1 snap download core;
sudo SNAPPY_STORE_NO_CDN=1 snap download --channel=edge subiquity;
CORE_SNAP=$(ls -1 core*.snap);
SUBIQUITY_SNAP=$(ls -1 subiquity*.snap);
mv *.assert /var/lib/snapd/seed/assertions/;
mv *.snap /var/lib/snapd/seed/snaps/;
cat <<EOF > /var/lib/snapd/seed/seed.yaml
snaps:
- name: core
channel: stable
file: ${CORE_SNAP}
- name: subiquity
channel: edge
classic: true
file: ${SUBIQUITY_SNAP}
EOF
'
assertions_dir="$SQUASH_ROOT/var/lib/snapd/seed/assertions"
model_assertion="$assertions_dir/generic-classic.model"
account_key_assertion="$assertions_dir/generic.account-key"
account_assertion="$assertions_dir/generic.account"
snap known --remote model series=16 model=generic-classic brand-id=generic \
> "$model_assertion"
account_key=$(sed -n -e's/sign-key-sha3-384: //p' "$model_assertion")
snap known --remote account-key public-key-sha3-384="$account_key" \
> "$account_key_assertion"
account=$(sed -n -e's/account-id: //p' "$account_key_assertion")
snap known --remote account account-id=generic \
> "$account_assertion"
teardown_mountpoint "$SQUASH_ROOT"
# Then unmount the overlay
umount "$SQUASH_ROOT"
squashfs_f="${PWD}/livecd.${PROJECT}.installer.squashfs"
(cd "$OVERLAY_ROOT/" &&
mksquashfs . ${squashfs_f} \
-no-progress -xattrs -comp xz )