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.6 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
. config/common
FILESYSTEM_ROOT=binary/boot/squashfs.dir
INSTALLER_ROOT=binary/boot/installer.squashfs.dir
OVERLAY_ROOT=binary/overlay
mkdir -p "$INSTALLER_ROOT" "$OVERLAY_ROOT"
# Create an installer squashfs layer
mount_overlay "$FILESYSTEM_ROOT/" "$OVERLAY_ROOT/" "$INSTALLER_ROOT/"
setup_mountpoint binary/boot/squashfs.dir
# Override JobRunningTimeoutSec to 0s on the .device unit that
# subiquity_config.mount depends on to avoid a 5s delay on switching
# to a new VT when there is no device there (LP: #1750117).
# It would be better to have this in ../includes.binary/overlay but
# you can't have backslashes in filenames in bzr branches!
DEVICE_UNIT_NAME='dev-disk-by\x2duuid-00c629d6\x2d06ab\x2d4dfd\x2db21e\x2dc3186f34105d.device'
mkdir -p "$INSTALLER_ROOT/etc/systemd/system/$DEVICE_UNIT_NAME.d"
cat > "$INSTALLER_ROOT/etc/systemd/system/$DEVICE_UNIT_NAME.d/override.conf" <<EOF
[Unit]
JobRunningTimeoutSec=0s
Wants=subiquity_config.mount
EOF
# Prepare installer layer.
# Install casper for live session magic.
chroot $INSTALLER_ROOT apt-get -y install lupin-casper
chroot $INSTALLER_ROOT apt-get clean
# For bug #1743643 "Install to dirty disk with swap fails" remove the
# "helpful" casper script that mounts any swap partitions it finds.
rm -f $INSTALLER_ROOT/usr/share/initramfs-tools/scripts/casper-bottom/*swap
# Don't let cloud-init run in the live session.
touch $INSTALLER_ROOT/etc/cloud/cloud-init.disabled
# Do the snap seeding dance.
chroot $INSTALLER_ROOT mkdir -p /var/lib/snapd/seed/snaps /var/lib/snapd/seed/assertions
chroot $INSTALLER_ROOT sh -c '
set -x;
mkdir -p /var/lib/snapd/seed/snaps/
cd /var/lib/snapd/seed/snaps/;
if [ ! -e core_*.snap ]; then
SNAPPY_STORE_NO_CDN=1 snap download core
fi
SNAPPY_STORE_NO_CDN=1 snap download subiquity;
CORE_SNAP=$(ls -1 core_*.snap);
SUBIQUITY_SNAP=$(ls -1 subiquity*.snap);
mv *.assert /var/lib/snapd/seed/assertions/;
cat <<EOF > /var/lib/snapd/seed/seed.yaml
snaps:
- name: core
channel: stable
file: ${CORE_SNAP}
- name: subiquity
channel: stable
classic: true
file: ${SUBIQUITY_SNAP}
EOF
'
teardown_mountpoint "$INSTALLER_ROOT"
squashfs_f="${PWD}/livecd.${PROJECT}.installer.squashfs"
(cd "$OVERLAY_ROOT/" &&
mksquashfs . ${squashfs_f} \
-no-progress -xattrs -comp xz )