From d5a6f5cbe3cbb27f136deb4bc3a5369e1ab53611 Mon Sep 17 00:00:00 2001 From: Mathieu Trudel-Lapierre Date: Mon, 20 Mar 2017 20:57:45 -0400 Subject: [PATCH 01/19] Add 'ubuntu-server-next' subiquity image. --- live-build/auto/config | 20 +- live-build/ubuntu-server-next/functions | 271 ++++++++++++++++++ .../hooks/01-setup_modules.chroot | 5 + .../hooks/030-root-squashfs.binary | 37 +++ .../hooks/032-installer-squashfs.binary | 164 +++++++++++ .../hooks/99-fix-resolvconf.chroot | 3 + .../includes.chroot/etc/hosts | 9 + .../multi-user.target.wants/subiquity.service | 31 ++ .../systemd/system/subiquity-debug@.service | 30 ++ .../lib/systemd/system/subiquity.service | 31 ++ 10 files changed, 598 insertions(+), 3 deletions(-) create mode 100644 live-build/ubuntu-server-next/functions create mode 100755 live-build/ubuntu-server-next/hooks/01-setup_modules.chroot create mode 100755 live-build/ubuntu-server-next/hooks/030-root-squashfs.binary create mode 100755 live-build/ubuntu-server-next/hooks/032-installer-squashfs.binary create mode 100644 live-build/ubuntu-server-next/hooks/99-fix-resolvconf.chroot create mode 100644 live-build/ubuntu-server-next/includes.chroot/etc/hosts create mode 100644 live-build/ubuntu-server-next/includes.chroot/lib/systemd/system/multi-user.target.wants/subiquity.service create mode 100644 live-build/ubuntu-server-next/includes.chroot/lib/systemd/system/subiquity-debug@.service create mode 100644 live-build/ubuntu-server-next/includes.chroot/lib/systemd/system/subiquity.service diff --git a/live-build/auto/config b/live-build/auto/config index 9782a75d..e81d9217 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -105,6 +105,9 @@ case $PROJECT in ubuntu-cpc) IMAGEFORMAT=ext4 ;; + ubuntu-server-next) + IMAGEFORMAT=plain + ;; esac case $IMAGEFORMAT in @@ -168,7 +171,7 @@ if [ "$PREINSTALLED" = "true" ] && [ "$SUBPROJECT" != "wubi" ]; then ubuntu-server) add_package live oem-config-debconf ubiquity-frontend-debconf ;; - ubuntu-core|ubuntu-base|base|ubuntu-touch|ubuntu-touch-custom|ubuntu-cpc|ubuntu-desktop-next) + ubuntu-core|ubuntu-base|base|ubuntu-touch|ubuntu-touch-custom|ubuntu-cpc|ubuntu-desktop-next|ubuntu-server-next) ;; *) add_package live oem-config-gtk ubiquity-frontend-gtk @@ -367,6 +370,17 @@ case $PROJECT in PREINSTALL_POOL_SEEDS='server-ship' ;; + ubuntu-server-next) + add_task install minimal + add_task install standard + add_task install server + COMPONENTS='main restricted universe' + add_package install snapd + add_package install nplan + add_package install curtin + add_package install hdparm + ;; + ubuntu-core) OPTS="${OPTS:+$OPTS }--apt-recommends false" @@ -569,7 +583,7 @@ case $ARCH in esac case $PROJECT in - ubuntu-server|ubuntu-base|ubuntu-touch|ubuntu-touch-custom) + ubuntu-server|ubuntu-base|ubuntu-touch|ubuntu-touch-custom|ubuntu-server-next) OPTS="${OPTS:+$OPTS }--linux-packages=none --initramfs=none" KERNEL_FLAVOURS=none BINARY_REMOVE_LINUX=false @@ -748,7 +762,7 @@ EOF fi ;; - ubuntu-touch:*|ubuntu-touch-custom:*|ubuntu-core:system-image|ubuntu-desktop-next:system-image|ubuntu-cpc:*) + ubuntu-touch:*|ubuntu-touch-custom:*|ubuntu-core:system-image|ubuntu-desktop-next:system-image|ubuntu-cpc:*|ubuntu-server-next:*) cp -af /usr/share/livecd-rootfs/live-build/${PROJECT}/* \ config/ ;; diff --git a/live-build/ubuntu-server-next/functions b/live-build/ubuntu-server-next/functions new file mode 100644 index 00000000..d58d9127 --- /dev/null +++ b/live-build/ubuntu-server-next/functions @@ -0,0 +1,271 @@ +# vi: ts=4 expandtab syntax=sh + +CLOUD_IMG_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process" +IMAGE_SIZE=$((2252*1024**2)) # 2.2G (the current size we ship) + +rootfs_dev_mapper= +loop_device= +loop_raw= +backing_img= + +apt-get -qqy install dosfstools gdisk + +clean_loops() { + + if [ -n "${backing_img}" ]; then + kpartx -v -d "${backing_img}" + unset backing_img + fi + + if [ -z "${rootfs_dev_mapper}" ]; then + return 0 + fi + + unset loop_device + unset loop_raw + unset rootfs_dev_mapper +} + +create_empty_disk_image() { + # Prepare an empty disk image + dd if=/dev/zero of="$1" bs=1 count=0 seek="${IMAGE_SIZE}" +} + +make_ext4_partition() { + device="$1" + + mkfs.ext4 -F -b 4096 -i 8192 -m 0 -L cloudimg-rootfs -E resize=536870912 "$device" +} + +mount_image() { + apt-get install -qqy kpartx + trap clean_loops EXIT + backing_img="$1" + local rootpart="$2" + kpartx_mapping="$(kpartx -s -v -a ${backing_img})" + + # Find the loop device + loop_p1="$(echo -e ${kpartx_mapping} | head -n1 | awk '{print$3}')" + loop_device="/dev/loop$(echo ${loop_p1} | cut -b5)" + if [ ! -b ${loop_device} ]; then + echo "unable to find loop device for ${backing_img}" + exit 1 + fi + + # Find the rootfs location + rootfs_dev_mapper="/dev/mapper/${loop_p1%%[0-9]}${rootpart}" + if [ ! -b "${rootfs_dev_mapper}" ]; then + echo "${rootfs_dev_mapper} is not a block device"; + exit 1 + fi + + # Add some information to the debug logs + echo "Mounted disk image ${backing_img} to ${rootfs_dev_mapper}" + blkid ${rootfs_dev_mapper} + + return 0 +} + +setup_mountpoint() { + local mountpoint="$1" + + mount --bind /dev "$mountpoint/dev" + mount devpts-live -t proc "$mountpoint/dev/pts" + mount proc-live -t proc "$mountpoint/proc" + mount sysfs-live -t sysfs "$mountpoint/sys" + mount -t tmpfs none "$mountpoint/tmp" + mv "$mountpoint/etc/resolv.conf" resolv.conf.tmp + cp /etc/resolv.conf "$mountpoint/etc/resolv.conf" + +} + +mount_partition() { + partition="$1" + mountpoint="$2" + + mount "$partition" "$mountpoint" + setup_mountpoint "$mountpoint" +} + + +mount_overlay() { + lower="$1" + upper="$2" + work="$2/../work" + path="$3" + + mkdir -p "$work" + mount -t overlay overlay \ + -olowerdir="$lower",upperdir="$upper",workdir="$work" \ + "$path" +} + +mount_disk_image() { + local disk_image=${1} + local mountpoint=${2} + mount_image ${disk_image} 1 + mount_partition "${rootfs_dev_mapper}" $mountpoint + + local uefi_dev="/dev/mapper${loop_device///dev/}p15" + if [ -b ${uefi_dev} -a -e $mountpoint/boot/efi ]; then + mount "${uefi_dev}" $mountpoint/boot/efi + fi + + # This is needed to allow for certain operations + # such as updating grub and installing software + cat > $mountpoint/usr/sbin/policy-rc.d << EOF +#!/bin/sh +# ${CLOUD_IMG_STR} +echo "All runlevel operations denied by policy" >&2 +exit 101 +EOF + chmod 0755 $mountpoint/usr/sbin/policy-rc.d + +} + +umount_settle() { + # Unmount device, and let it settle + umount $1 + udevadm settle +} + +umount_partition() { + local mountpoint=${1} + mv resolv.conf.tmp "$mountpoint/etc/resolv.conf" + for submnt in proc sys dev/pts dev tmp; + do + umount $mountpoint/$submnt + done + umount $mountpoint + udevadm settle + + if [ -n "${rootfs_dev_mapper}" -a -b "${rootfs_dev_mapper}" ]; then + # buildd's don't have /etc/mtab symlinked + # /etc/mtab is needed in order zerofree space for ext4 filesystems + [ -e /etc/mtab ] || ln -s /proc/mounts /etc/mtab + + # both of these are likely overkill, but it does result in slightly + # smaller ext4 filesystem + apt-get -qqy install zerofree + e2fsck -y -E discard ${rootfs_dev_mapper} + zerofree ${rootfs_dev_mapper} + fi +} + +umount_disk_image() { + mountpoint="$1" + + local uefi_dev="/dev/mapper${loop_device///dev/}p15" + if [ -e "$mountpoint/boot/efi" -a -b "$uefi_dev" ]; then + umount --detach-loop "$mountpoint/boot/efi" + fi + + if [ -e $mountpoint/usr/sbin/policy-rc.d ]; then + rm $mountpoint/usr/sbin/policy-rc.d + fi + umount_partition $mountpoint + clean_loops +} + +modify_vmdk_header() { + # Modify the VMDK headers so that both VirtualBox _and_ VMware can + # read the vmdk and import them. The vodoo here is _not_ documented + # anywhere....so this will have to do. This is undocumented vodoo + # that has been learned by the Cloud Image team. + + vmdk_name="${1}" + descriptor=$(mktemp) + newdescriptor=$(mktemp) + + # Extract the vmdk header for manipulation + dd if="${vmdk_name}" of="${descriptor}" bs=1 skip=512 count=1024 + + # The sed lines below is where the magic is. Specifically: + # ddb.toolsVersion: sets the open-vm-tools so that VMware shows + # the tooling as current + # ddb.virtualHWVersion: set the version to 7, which covers most + # current versions of VMware + # createType: make sure its set to stream Optimized + # remove the vmdk-stream-converter comment and replace with + # # Disk DescriptorFile. This is needed for Virtualbox + # remove the comments from vmdk-stream-converter which causes + # VirtualBox and others to fail VMDK validation + + sed -e 's|# Description file.*|# Disk DescriptorFile|' \ + -e '/# Believe this is random*/d' \ + -e '/# Indicates no parent/d' \ + -e '/# The Disk Data Base/d' \ + -e 's|ddb.comment.*|ddb.toolsVersion = "2147483647"|' \ + "${descriptor}" > "${newdescriptor}" + + # The header is cannot be bigger than 1024 + expr $(stat --format=%s ${newdescriptor}) \< 1024 > /dev/null 2>&1 || { + echo "descriptor is too large, VMDK will be invalid!"; exit 1; } + + # Overwrite the vmdk header with our new, modified one + dd conv=notrunc,nocreat \ + if="${newdescriptor}" of="${vmdk_name}" \ + bs=1 seek=512 count=1024 + + rm ${descriptor} ${newdescriptor} +} + +create_vmdk() { + # There is no real good way to create a _compressed_ VMDK using open source + # tooling that works across multiple VMDK-capable platforms. This functions + # uses vmdk-stream-converter and then calls modify_vmdk_header to produce a + # compatible VMDK. + + src="$1" + destination="$2" + size="${3:-10240}" + + apt-get install -qqy qemu-utils vmdk-stream-converter + streamconverter="/usr/share/pyshared/VMDKstream.py" + scratch_d=$(mktemp -d) + cp ${src} ${scratch_d}/resize.img + + truncate --size=${size}M ${scratch_d}/resize.img + python ${streamconverter} ${scratch_d}/resize.img ${destination} + modify_vmdk_header ${destination} + + qemu-img info ${destination} + rm -rf ${scratch_d} +} + +create_derivative() { + # arg1 is the disk type + # arg2 is the new name + unset derivative_img + case ${1} in + uefi) disk_image="binary/boot/disk-uefi.ext4"; + dname="${disk_image//-uefi/-$2-uefi}";; + *) disk_image="binary/boot/disk.ext4"; + dname="${disk_image//.ext4/-$2.ext4}";; + esac + + if [ ! -e ${disk_image} ]; then + echo "Did not find ${disk_image}!"; exit 1; + fi + + cp ${disk_image} ${dname} + export derivative_img=${dname} +} + +convert_to_qcow2() { + apt-get install -qqy qemu-utils + + src="$1" + destination="$2" + qemu-img convert -c -O qcow2 -o compat=0.10 "$src" "$destination" + qemu-img info "$destination" +} + +replace_grub_root_with_label() { + # When update-grub is run, it will detect the disks in the build system. + # Instead, we want grub to use the cloudimg-rootfs labelled disk + CHROOT_ROOT="$1" + + sed -i -e "s,root=[^ ]\+,root=LABEL=cloudimg-rootfs," \ + "$CHROOT_ROOT/boot/grub/grub.cfg" +} diff --git a/live-build/ubuntu-server-next/hooks/01-setup_modules.chroot b/live-build/ubuntu-server-next/hooks/01-setup_modules.chroot new file mode 100755 index 00000000..87af73c2 --- /dev/null +++ b/live-build/ubuntu-server-next/hooks/01-setup_modules.chroot @@ -0,0 +1,5 @@ +#!/bin/sh -x + +set -e + +mkdir -p /lib/modules diff --git a/live-build/ubuntu-server-next/hooks/030-root-squashfs.binary b/live-build/ubuntu-server-next/hooks/030-root-squashfs.binary new file mode 100755 index 00000000..0925710e --- /dev/null +++ b/live-build/ubuntu-server-next/hooks/030-root-squashfs.binary @@ -0,0 +1,37 @@ +#!/bin/bash -ex +# vi: ts=4 noexpandtab +# +# Generate a squashfs root and manifest + +set -x +echo "030-root-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 + +. /build/config/functions + +mkdir binary/boot/squashfs.dir +cp -a chroot/* binary/boot/squashfs.dir + +apt-get -qqy install squashfs-tools + +squashfs_f="${PWD}/livecd.ubuntu-server-next.squashfs" +squashfs_f_manifest="${squashfs_f}.manifest" + +dpkg-query --admindir=binary/boot/squashfs.dir/var/lib/dpkg -W > ${squashfs_f_manifest} + +(cd "binary/boot/squashfs.dir/" && + mksquashfs . ${squashfs_f} \ + -no-progress -xattrs -comp xz ) diff --git a/live-build/ubuntu-server-next/hooks/032-installer-squashfs.binary b/live-build/ubuntu-server-next/hooks/032-installer-squashfs.binary new file mode 100755 index 00000000..61bb42d0 --- /dev/null +++ b/live-build/ubuntu-server-next/hooks/032-installer-squashfs.binary @@ -0,0 +1,164 @@ +#!/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 + +. /build/config/functions + +SQUASH_ROOT=binary/boot/squashfs.dir +OVERLAY_ROOT=binary/boot/overlay.dir + +mkdir "$OVERLAY_ROOT" + +setup_mountpoint binary/boot/squashfs.dir + +# Create an installer squashfs layer +mount_overlay "$SQUASH_ROOT/" "$OVERLAY_ROOT/" "$SQUASH_ROOT/" + +# 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 + +# 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 < /var/lib/snapd/seed/seed.yaml +snaps: + - name: core + channel: stable + file: ${CORE_SNAP} + - name: subiquity + channel: edge + classic: true + file: ${SUBIQUITY_SNAP} +EOF +' + +cat < $SQUASH_ROOT/var/lib/snapd/seed/assertions/cyphermox.account +type: account +authority-id: canonical +account-id: H0szZPjHTU4x04XeYjLyv8tJqYXq7cYk +display-name: Mathieu Trudel +timestamp: 2016-09-12T20:11:03.478544Z +username: cyphermox +validation: unproven +sign-key-sha3-384: BWDEoaqyr25nF5SNCvEv2v7QnM9QsfCc0PBMYD_i2NGSQ32EF2d4D0hqUel3m8ul + +AcLBUgQAAQoABgUCV9cL1wAAbQIQAEa8X5Bf2achG/9gC2d9YHWE+Uk9/FXK58bZ4Ym5VDTPW2Es +BZOTMA6ROcCrii8/HM88+5bKGGoYLVNjfYUosYfR31kkFT1z1payhs4zfhANTBHXQpeNlGASm9ua +O1UkBNFJwYu+tRh9gsY5wuryjfxXndS2pzUm2fXlFB4I/FgQEZnKJP99C3H0cUkGHzEwadRc7vqu +/B+mmlwX/pgzlUwt3EXkCpx0hvN4ZgSzyKAtLn+ij2XSe4MxptT/uGCY2tnqsSa+H6J+O0RYENYD +Xa7MJLXSGS9iqOwBkTO5X1eHSNPUs0LqzAqz4zTL5Kd9c/ohFwPzZpO8ltLA2nhKEfHzofMsMjEi +qwhCDQ5LZD93dQ/VWzmmrCi9cmy+mci7K+hEYLtopzbkMl7cFBVVc2pQlTArspsFy9aMurCs4m8K +GfGJOmvYP4Rnn8YYVLtAIPbGADAzG4mxBDxc8r+NRCprDIJmVHed/aQo6gNNip6VHi7xORnAJYRI +0XQThASCRYzZxEBv3iND0GzAlRdlOLA+x+jRt2CDg0qLQ5DmuXGePEkEyJEMQb+OBsFHrPcvX1UI +eHoKL9ZyvcrhsuPmG92P2UYiGp7qeKYmPQFsWNNh/R18tgingyJbm75pAE8MrpyZ1TTyDEYhwzbm +F5zdm4dy0k1EGMhTTDz/hzlE0Ugw +EOF + +cat < $SQUASH_ROOT/var/lib/snapd/seed/assertions/cyphermox-sn-test.account-key +type: account-key +authority-id: canonical +public-key-sha3-384: vihTQiNMkgsi2g39sggy3k4EVGrkFyWMof_nIrCbhxSOO7U00PRD_TDeWrpqGNor +account-id: H0szZPjHTU4x04XeYjLyv8tJqYXq7cYk +name: cyphermox-sn-test +since: 2017-03-14T21:24:50Z +body-length: 717 +sign-key-sha3-384: BWDEoaqyr25nF5SNCvEv2v7QnM9QsfCc0PBMYD_i2NGSQ32EF2d4D0hqUel3m8ul + +AcbBTQRWhcGAARAAqJ9Xdy+csx9nQkipmldiKNsBKqwRh3HjwlnSrBm/YpI7Jbgs6zubD8Zj/hwr +bQiu4E2d6aobJcn3cgNdTlCEXES1M3sC6vSmkuz2fXdHRsYD6V3l5rlPjlyWPGNajcKvn1lEyOxC +j6efASJysX5lCDPfGy8Joe4OdeZxmPAwCJpuxpltlSMBlPjCHBgHMzv+C1zh9wkBuFh3wDIFP8ih +hnzGN/UevSHMfZCGh3y20TzDHeaeI35hiHkaibQuifqVNMTjnxReYKHV2eAP8/2XpEhfMAU6AD/Y +020ayr9REE/c6KTYq7Po7REzvUrWlG0KknBtHM7wCn9puo5HrM767K0H+ts6fsrvx5kRC5ZheVOf +Jh3EoXYQYCL1EGw0bzU03Lxx0RQ6teEc0WTDzky54vFr6UHjCAwethpzZ7MtZRdfwW4r/jUcxwXR +JXXKh03WK/ivhtr9KAROVkdUeMb/txp/8DvLW5zs7ohTaaC0qH5J+MMp0lm6ux0S8WyPmMOcb0SP +0IwOTvQc1ALDG3SiUgtJRP9Kt5jeuWIltH0cYE+QGPzey+fJ+iJx0QmeVnF2+O2JH2RihR5uJIBE +HzQlNMVZB/iyjgdCLamMUeqa6DAOpzR2haIRgaXKtK0G9Ho1ArEsXZsRiFYorhtxzrwGmkq7kGCw +tsY2pTeILZO1QPMAEQEAAQ== + +AcLBUgQAAQoABgUCWMhfrAAAXn4QALo795LKWhSNlzI7KIz3hq6rFK1YVDbj3KXW8xoF1FEwyE51 +4s1hZXc5N5h7DO49pj7JcXtE+Vi2gV+X294BqRevglBZgMwUtXdHX29IgPAx0jR9ARybS9A0QQYV +OaoKmnq+44p76D2gZz0blax18uROJCKfL6GCRw29/C/GJWpRnEEJlXC2DVD45vJeptSqLDcBL6z+ +AypoV9NhJlmGm2jxPg5Jm+BdkyCZSbfNMw2sBcjJbs63KHgE9XsaP6Frb9gBexwXCx8/U6Y2jFTL +wmyHpXXjBY0et8ze2bcqcEsDeW30eFALki/+FfPzjTtxY/Xo/r2j78YMHVFOkWJYj3MZJ+LJ0UWC +eM4xzJm2ROwxFhFpIqlIRtR6WUPIxAx3Fb1j3uDTSBXDYv/hjxhSLZpw3/AN7Rj7pLWnwfD3076i +3R900ad3/tRQp8hlrn4H9zRxBwaCKhZ9h1kfmyHcVpf0Nk03Fe5tHTai0pdHpC6bPi798Iw6qt0r +D7VoKv29fa55zlGRTAG9mW0cbgkKUq1SBtLnBSy+peluVGjJWgZ3j1K9waTEoQPiNn6/JJvg2GjK +awZPm8R1ngBYQs/vGPhcfz8DGF3uwFzbSh/bLAKky22qrRypTtczDXw4H1LWPlUvB4cQfTY6Ad+w +KaHPaPmuIpn1DVEfPhNeByz57PDu +EOF + +cat < $SQUASH_ROOT/var/lib/snapd/seed/assertions/cyphermox-classic.model +type: model +authority-id: H0szZPjHTU4x04XeYjLyv8tJqYXq7cYk +series: 16 +brand-id: H0szZPjHTU4x04XeYjLyv8tJqYXq7cYk +model: cyphermox-test-classic +classic: true +timestamp: 2017-03-15T14:32:45+00:00 +sign-key-sha3-384: vihTQiNMkgsi2g39sggy3k4EVGrkFyWMof_nIrCbhxSOO7U00PRD_TDeWrpqGNor + +AcLBXAQAAQoABgUCWMm5vAAKCRBdai1JSycAlUiAD/41bWorQOI343Ub/JVGFXN8aHXwZWh2iVzY +m42QbHZSuyyLBLiEqauiQLvuFa3Dtb3i6GC6hdtOlf/sPwZISriWrNuO5qPXik5SqP5zZop/qy4y +msWpG1S6M/aNqGVfUPIx0v7l9iTb4ZG9hyyxPwdE5lFj4nIqWlu6rIGPCGC+dfAS62PPkUGdXqzV +VOA6/D2FgthhxywaZZwSLwzP/Ee+JAgeO17iX605Lb0dzy/5HmopM7G8wUgzidPUY9AIZ63gr+GP +KyBrvwHzE6PbH9QjQy1Z7DhkThKeViocx67ewnBocBr75F09LfcVR+cAxMujSs7NBbYl444aQeth +HUuLwvuH189KsnQdqF2Tfta5lkCn9Uqeshq2c2jGyYXBTpvxyQny4X+yQZF1uEalH3PRR+AxIT9Y +2siMLMuRyS/iMhIkLToutzuhZS+7ujuGs7H4l9C0hUon9c+62XEIkNH4rjutR7lCuFbE3CMqVl9H +lgGQ6HXl0uoJHEzK4T1+ipstSiujn9KD+8LCtkz0YWFmdWQ97VHB2Wmjp4c2bze+BojbqJyfJ2bo +AAHP0AEiHQ7zN0yLl7+fkYIMy64xQJqamH1Z2BFN0GWMPwTjpXpszOC+ev7Bpbg0xoldQ1tBHHxH +J4Weia71DnXOnt8cj1VhebVMlyv7B/TGAbGwgprgmQ== +EOF + +mv resolv.conf.tmp "binary/boot/squashfs.dir/etc/resolv.conf" + +# Unmount the overlay first, where it is mounted: +umount "$SQUASH_ROOT" + +# Then we can start unmounting the "real" root: +umount "binary/boot/squashfs.dir/proc" +umount "binary/boot/squashfs.dir/sys" +umount "binary/boot/squashfs.dir/dev/pts" +umount "binary/boot/squashfs.dir/dev" +umount "binary/boot/squashfs.dir/tmp" + +apt-get -qqy install squashfs-tools + +squashfs_f="${PWD}/livecd.ubuntu-server-next.installer.squashfs" + +(cd "$OVERLAY_ROOT/" && + mksquashfs . ${squashfs_f} \ + -no-progress -xattrs -comp xz ) diff --git a/live-build/ubuntu-server-next/hooks/99-fix-resolvconf.chroot b/live-build/ubuntu-server-next/hooks/99-fix-resolvconf.chroot new file mode 100644 index 00000000..9ed0a499 --- /dev/null +++ b/live-build/ubuntu-server-next/hooks/99-fix-resolvconf.chroot @@ -0,0 +1,3 @@ +#!/bin/sh + +ln -snf ../run/resolvconf/resolv.conf /etc/resolv.conf diff --git a/live-build/ubuntu-server-next/includes.chroot/etc/hosts b/live-build/ubuntu-server-next/includes.chroot/etc/hosts new file mode 100644 index 00000000..81684340 --- /dev/null +++ b/live-build/ubuntu-server-next/includes.chroot/etc/hosts @@ -0,0 +1,9 @@ +127.0.0.1 localhost.localdomain localhost +::1 localhost6.localdomain6 localhost6 + +# The following lines are desirable for IPv6 capable hosts +::1 localhost ip6-localhost ip6-loopback +fe00::0 ip6-localnet +ff02::1 ip6-allnodes +ff02::2 ip6-allrouters +ff02::3 ip6-allhosts diff --git a/live-build/ubuntu-server-next/includes.chroot/lib/systemd/system/multi-user.target.wants/subiquity.service b/live-build/ubuntu-server-next/includes.chroot/lib/systemd/system/multi-user.target.wants/subiquity.service new file mode 100644 index 00000000..2b40f7c0 --- /dev/null +++ b/live-build/ubuntu-server-next/includes.chroot/lib/systemd/system/multi-user.target.wants/subiquity.service @@ -0,0 +1,31 @@ +[Unit] +Description=Subiquity, the installer for Ubuntu Server +After=systemd-user-sessions.service plymouth-quit-wait.service +After=rc-local.service +Requires=snapd.service +IgnoreOnIsolate=yes +ConditionPathExists=/dev/tty0 +ConditionPathExists=!/run/subiquity/complete + +[Service] +Environment=PYTHONPATH=/usr/share/subiquity +ExecStartPre=/bin/systemctl stop getty@tty1 +ExecStart=/sbin/agetty -n --noclear -l /snap/bin/subiquity tty1 $TERM +ExecStopPost=/bin/systemctl start getty@tty1 +Type=idle +Restart=always +RestartSec=0 +UtmpIdentifier=tty1 +TTYPath=/dev/tty1 +TTYReset=yes +TTYVHangup=yes +TTYVTDisallocate=yes +KillMode=process +IgnoreSIGPIPE=no +SendSIGHUP=yes + +#KillMode=process +#Restart=always +#StandardInput=tty-force +#StandardOutput=tty +#StandardError=tty diff --git a/live-build/ubuntu-server-next/includes.chroot/lib/systemd/system/subiquity-debug@.service b/live-build/ubuntu-server-next/includes.chroot/lib/systemd/system/subiquity-debug@.service new file mode 100644 index 00000000..826e234d --- /dev/null +++ b/live-build/ubuntu-server-next/includes.chroot/lib/systemd/system/subiquity-debug@.service @@ -0,0 +1,30 @@ +[Unit] +Description=Subiquity debug shell %I +After=systemd-user-sessions.service plymouth-quit-wait.service +After=rc-local.service +IgnoreOnIsolate=yes +ConditionPathExists=/dev/tty0 +ConditionPathExists=!/run/subiquity/complete + +[Service] +Environment=PYTHONPATH=/usr/share/subiquity +ExecStartPre=/bin/systemctl stop getty@%I +ExecStart=/sbin/agetty -n --noclear -l /usr/share/subiquity/subiquity-debug %I $TERM +ExecStopPost=/bin/systemctl start getty@%I +Type=idle +Restart=always +RestartSec=0 +UtmpIdentifier=%I +TTYPath=/dev/%I +TTYReset=yes +TTYVHangup=yes +TTYVTDisallocate=yes +KillMode=process +IgnoreSIGPIPE=no +SendSIGHUP=yes + +#KillMode=process +#Restart=always +#StandardInput=tty-force +#StandardOutput=tty +#StandardError=tty diff --git a/live-build/ubuntu-server-next/includes.chroot/lib/systemd/system/subiquity.service b/live-build/ubuntu-server-next/includes.chroot/lib/systemd/system/subiquity.service new file mode 100644 index 00000000..2b40f7c0 --- /dev/null +++ b/live-build/ubuntu-server-next/includes.chroot/lib/systemd/system/subiquity.service @@ -0,0 +1,31 @@ +[Unit] +Description=Subiquity, the installer for Ubuntu Server +After=systemd-user-sessions.service plymouth-quit-wait.service +After=rc-local.service +Requires=snapd.service +IgnoreOnIsolate=yes +ConditionPathExists=/dev/tty0 +ConditionPathExists=!/run/subiquity/complete + +[Service] +Environment=PYTHONPATH=/usr/share/subiquity +ExecStartPre=/bin/systemctl stop getty@tty1 +ExecStart=/sbin/agetty -n --noclear -l /snap/bin/subiquity tty1 $TERM +ExecStopPost=/bin/systemctl start getty@tty1 +Type=idle +Restart=always +RestartSec=0 +UtmpIdentifier=tty1 +TTYPath=/dev/tty1 +TTYReset=yes +TTYVHangup=yes +TTYVTDisallocate=yes +KillMode=process +IgnoreSIGPIPE=no +SendSIGHUP=yes + +#KillMode=process +#Restart=always +#StandardInput=tty-force +#StandardOutput=tty +#StandardError=tty From 86b64ef78e98fda8ae241b8a46da78256edfac2c Mon Sep 17 00:00:00 2001 From: Mathieu Trudel-Lapierre Date: Tue, 21 Mar 2017 18:22:58 -0400 Subject: [PATCH 02/19] Move curtin to installer squash. --- live-build/auto/config | 4 ---- .../ubuntu-server-next/hooks/032-installer-squashfs.binary | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/live-build/auto/config b/live-build/auto/config index e81d9217..67fcb896 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -375,10 +375,6 @@ case $PROJECT in add_task install standard add_task install server COMPONENTS='main restricted universe' - add_package install snapd - add_package install nplan - add_package install curtin - add_package install hdparm ;; ubuntu-core) diff --git a/live-build/ubuntu-server-next/hooks/032-installer-squashfs.binary b/live-build/ubuntu-server-next/hooks/032-installer-squashfs.binary index 61bb42d0..9dbc97a4 100755 --- a/live-build/ubuntu-server-next/hooks/032-installer-squashfs.binary +++ b/live-build/ubuntu-server-next/hooks/032-installer-squashfs.binary @@ -39,6 +39,7 @@ mount_overlay "$SQUASH_ROOT/" "$OVERLAY_ROOT/" "$SQUASH_ROOT/" # 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 # Do the snap seeding dance. chroot $SQUASH_ROOT mkdir -p /var/lib/snapd/seed/snaps /var/lib/snapd/seed/assertions From 303c7a29ec047eca05fe7e078e1fb0e076759fa2 Mon Sep 17 00:00:00 2001 From: Mathieu Trudel-Lapierre Date: Tue, 21 Mar 2017 18:32:55 -0400 Subject: [PATCH 03/19] Move subiquity systemd service to includes.binary; so that it's copied only on the installer overlay. --- .../multi-user.target.wants/subiquity.service | 1 + .../systemd/system/subiquity-debug@.service | 0 .../lib/systemd/system}/subiquity.service | 0 .../lib/systemd/system/subiquity.service | 31 ------------------- 4 files changed, 1 insertion(+), 31 deletions(-) create mode 120000 live-build/ubuntu-server-next/includes.binary/boot/overlay.dir/lib/systemd/system/multi-user.target.wants/subiquity.service rename live-build/ubuntu-server-next/{includes.chroot => includes.binary/boot/overlay.dir}/lib/systemd/system/subiquity-debug@.service (100%) rename live-build/ubuntu-server-next/{includes.chroot/lib/systemd/system/multi-user.target.wants => includes.binary/boot/overlay.dir/lib/systemd/system}/subiquity.service (100%) delete mode 100644 live-build/ubuntu-server-next/includes.chroot/lib/systemd/system/subiquity.service diff --git a/live-build/ubuntu-server-next/includes.binary/boot/overlay.dir/lib/systemd/system/multi-user.target.wants/subiquity.service b/live-build/ubuntu-server-next/includes.binary/boot/overlay.dir/lib/systemd/system/multi-user.target.wants/subiquity.service new file mode 120000 index 00000000..4d9ea45c --- /dev/null +++ b/live-build/ubuntu-server-next/includes.binary/boot/overlay.dir/lib/systemd/system/multi-user.target.wants/subiquity.service @@ -0,0 +1 @@ +../subiquity.service \ No newline at end of file diff --git a/live-build/ubuntu-server-next/includes.chroot/lib/systemd/system/subiquity-debug@.service b/live-build/ubuntu-server-next/includes.binary/boot/overlay.dir/lib/systemd/system/subiquity-debug@.service similarity index 100% rename from live-build/ubuntu-server-next/includes.chroot/lib/systemd/system/subiquity-debug@.service rename to live-build/ubuntu-server-next/includes.binary/boot/overlay.dir/lib/systemd/system/subiquity-debug@.service diff --git a/live-build/ubuntu-server-next/includes.chroot/lib/systemd/system/multi-user.target.wants/subiquity.service b/live-build/ubuntu-server-next/includes.binary/boot/overlay.dir/lib/systemd/system/subiquity.service similarity index 100% rename from live-build/ubuntu-server-next/includes.chroot/lib/systemd/system/multi-user.target.wants/subiquity.service rename to live-build/ubuntu-server-next/includes.binary/boot/overlay.dir/lib/systemd/system/subiquity.service diff --git a/live-build/ubuntu-server-next/includes.chroot/lib/systemd/system/subiquity.service b/live-build/ubuntu-server-next/includes.chroot/lib/systemd/system/subiquity.service deleted file mode 100644 index 2b40f7c0..00000000 --- a/live-build/ubuntu-server-next/includes.chroot/lib/systemd/system/subiquity.service +++ /dev/null @@ -1,31 +0,0 @@ -[Unit] -Description=Subiquity, the installer for Ubuntu Server -After=systemd-user-sessions.service plymouth-quit-wait.service -After=rc-local.service -Requires=snapd.service -IgnoreOnIsolate=yes -ConditionPathExists=/dev/tty0 -ConditionPathExists=!/run/subiquity/complete - -[Service] -Environment=PYTHONPATH=/usr/share/subiquity -ExecStartPre=/bin/systemctl stop getty@tty1 -ExecStart=/sbin/agetty -n --noclear -l /snap/bin/subiquity tty1 $TERM -ExecStopPost=/bin/systemctl start getty@tty1 -Type=idle -Restart=always -RestartSec=0 -UtmpIdentifier=tty1 -TTYPath=/dev/tty1 -TTYReset=yes -TTYVHangup=yes -TTYVTDisallocate=yes -KillMode=process -IgnoreSIGPIPE=no -SendSIGHUP=yes - -#KillMode=process -#Restart=always -#StandardInput=tty-force -#StandardOutput=tty -#StandardError=tty From 6978674cfec5246c9adadd91ef7af9b84d2fcd41 Mon Sep 17 00:00:00 2001 From: Mathieu Trudel-Lapierre Date: Thu, 23 Mar 2017 16:19:16 -0400 Subject: [PATCH 04/19] Add cloud-init for subiquity image. --- live-build/auto/config | 1 + 1 file changed, 1 insertion(+) diff --git a/live-build/auto/config b/live-build/auto/config index 67fcb896..ccb48866 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -375,6 +375,7 @@ case $PROJECT in add_task install standard add_task install server COMPONENTS='main restricted universe' + add_package install cloud-init ;; ubuntu-core) From 29f5dc57fd313b64989afd9bff65b363f94cc870 Mon Sep 17 00:00:00 2001 From: Mathieu Trudel-Lapierre Date: Mon, 27 Mar 2017 20:55:58 -0400 Subject: [PATCH 05/19] mkdir must not fail. --- debian/changelog | 6 ++++++ .../ubuntu-server-next/hooks/032-installer-squashfs.binary | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index ed333d87..50660829 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +livecd-rootfs (2.441~mtrudel2) zesty; urgency=medium + + * + + -- Mathieu Trudel-Lapierre Thu, 23 Mar 2017 16:20:16 -0400 + livecd-rootfs (2.440) zesty; urgency=medium [ Steve Langasek ] diff --git a/live-build/ubuntu-server-next/hooks/032-installer-squashfs.binary b/live-build/ubuntu-server-next/hooks/032-installer-squashfs.binary index 9dbc97a4..c0181d29 100755 --- a/live-build/ubuntu-server-next/hooks/032-installer-squashfs.binary +++ b/live-build/ubuntu-server-next/hooks/032-installer-squashfs.binary @@ -26,7 +26,7 @@ fi SQUASH_ROOT=binary/boot/squashfs.dir OVERLAY_ROOT=binary/boot/overlay.dir -mkdir "$OVERLAY_ROOT" +mkdir -p "$OVERLAY_ROOT" setup_mountpoint binary/boot/squashfs.dir From bf958b1472619662112a38e5ee366660519e6a71 Mon Sep 17 00:00:00 2001 From: Mathieu Trudel-Lapierre Date: Wed, 5 Apr 2017 13:35:38 -0400 Subject: [PATCH 06/19] Disable cloud-init for the live-session. user-setup will create our ubuntu user via casper. --- .../ubuntu-server-next/hooks/032-installer-squashfs.binary | 3 +++ 1 file changed, 3 insertions(+) diff --git a/live-build/ubuntu-server-next/hooks/032-installer-squashfs.binary b/live-build/ubuntu-server-next/hooks/032-installer-squashfs.binary index c0181d29..08885af6 100755 --- a/live-build/ubuntu-server-next/hooks/032-installer-squashfs.binary +++ b/live-build/ubuntu-server-next/hooks/032-installer-squashfs.binary @@ -41,6 +41,9 @@ 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 ' From e577ed767214d65ea799b8c1c1feb7025ec4a91b Mon Sep 17 00:00:00 2001 From: Mathieu Trudel-Lapierre Date: Thu, 6 Apr 2017 14:04:29 -0400 Subject: [PATCH 07/19] Rename to ubuntu-server-live; some build process fixes. --- live-build/auto/config | 14 +++++++------- .../functions | 0 .../hooks/01-setup_modules.chroot | 0 .../hooks/030-root-squashfs.binary | 2 +- .../hooks/032-installer-squashfs.binary | 2 +- .../hooks/99-fix-resolvconf.chroot | 0 .../multi-user.target.wants/subiquity.service | 0 .../lib/systemd/system/subiquity-debug@.service | 0 .../lib/systemd/system/subiquity.service | 0 .../includes.chroot/etc/hosts | 0 10 files changed, 9 insertions(+), 9 deletions(-) rename live-build/{ubuntu-server-next => ubuntu-server-live}/functions (100%) rename live-build/{ubuntu-server-next => ubuntu-server-live}/hooks/01-setup_modules.chroot (100%) rename live-build/{ubuntu-server-next => ubuntu-server-live}/hooks/030-root-squashfs.binary (92%) rename live-build/{ubuntu-server-next => ubuntu-server-live}/hooks/032-installer-squashfs.binary (98%) rename live-build/{ubuntu-server-next => ubuntu-server-live}/hooks/99-fix-resolvconf.chroot (100%) rename live-build/{ubuntu-server-next => ubuntu-server-live}/includes.binary/boot/overlay.dir/lib/systemd/system/multi-user.target.wants/subiquity.service (100%) rename live-build/{ubuntu-server-next => ubuntu-server-live}/includes.binary/boot/overlay.dir/lib/systemd/system/subiquity-debug@.service (100%) rename live-build/{ubuntu-server-next => ubuntu-server-live}/includes.binary/boot/overlay.dir/lib/systemd/system/subiquity.service (100%) rename live-build/{ubuntu-server-next => ubuntu-server-live}/includes.chroot/etc/hosts (100%) diff --git a/live-build/auto/config b/live-build/auto/config index ccb48866..b5d7d471 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -105,7 +105,7 @@ case $PROJECT in ubuntu-cpc) IMAGEFORMAT=ext4 ;; - ubuntu-server-next) + ubuntu-server-live) IMAGEFORMAT=plain ;; esac @@ -171,7 +171,7 @@ if [ "$PREINSTALLED" = "true" ] && [ "$SUBPROJECT" != "wubi" ]; then ubuntu-server) add_package live oem-config-debconf ubiquity-frontend-debconf ;; - ubuntu-core|ubuntu-base|base|ubuntu-touch|ubuntu-touch-custom|ubuntu-cpc|ubuntu-desktop-next|ubuntu-server-next) + ubuntu-core|ubuntu-base|base|ubuntu-touch|ubuntu-touch-custom|ubuntu-cpc|ubuntu-desktop-next|ubuntu-server-live) ;; *) add_package live oem-config-gtk ubiquity-frontend-gtk @@ -370,12 +370,12 @@ case $PROJECT in PREINSTALL_POOL_SEEDS='server-ship' ;; - ubuntu-server-next) + ubuntu-server-live) add_task install minimal add_task install standard add_task install server - COMPONENTS='main restricted universe' - add_package install cloud-init + add_task install cloud-image + COMPONENTS='main' ;; ubuntu-core) @@ -580,7 +580,7 @@ case $ARCH in esac case $PROJECT in - ubuntu-server|ubuntu-base|ubuntu-touch|ubuntu-touch-custom|ubuntu-server-next) + ubuntu-server|ubuntu-base|ubuntu-touch|ubuntu-touch-custom) OPTS="${OPTS:+$OPTS }--linux-packages=none --initramfs=none" KERNEL_FLAVOURS=none BINARY_REMOVE_LINUX=false @@ -759,7 +759,7 @@ EOF fi ;; - ubuntu-touch:*|ubuntu-touch-custom:*|ubuntu-core:system-image|ubuntu-desktop-next:system-image|ubuntu-cpc:*|ubuntu-server-next:*) + ubuntu-touch:*|ubuntu-touch-custom:*|ubuntu-core:system-image|ubuntu-desktop-next:system-image|ubuntu-cpc:*|ubuntu-server-live:*) cp -af /usr/share/livecd-rootfs/live-build/${PROJECT}/* \ config/ ;; diff --git a/live-build/ubuntu-server-next/functions b/live-build/ubuntu-server-live/functions similarity index 100% rename from live-build/ubuntu-server-next/functions rename to live-build/ubuntu-server-live/functions diff --git a/live-build/ubuntu-server-next/hooks/01-setup_modules.chroot b/live-build/ubuntu-server-live/hooks/01-setup_modules.chroot similarity index 100% rename from live-build/ubuntu-server-next/hooks/01-setup_modules.chroot rename to live-build/ubuntu-server-live/hooks/01-setup_modules.chroot diff --git a/live-build/ubuntu-server-next/hooks/030-root-squashfs.binary b/live-build/ubuntu-server-live/hooks/030-root-squashfs.binary similarity index 92% rename from live-build/ubuntu-server-next/hooks/030-root-squashfs.binary rename to live-build/ubuntu-server-live/hooks/030-root-squashfs.binary index 0925710e..48f60193 100755 --- a/live-build/ubuntu-server-next/hooks/030-root-squashfs.binary +++ b/live-build/ubuntu-server-live/hooks/030-root-squashfs.binary @@ -27,7 +27,7 @@ cp -a chroot/* binary/boot/squashfs.dir apt-get -qqy install squashfs-tools -squashfs_f="${PWD}/livecd.ubuntu-server-next.squashfs" +squashfs_f="${PWD}/livecd.${PROJECT}.squashfs" squashfs_f_manifest="${squashfs_f}.manifest" dpkg-query --admindir=binary/boot/squashfs.dir/var/lib/dpkg -W > ${squashfs_f_manifest} diff --git a/live-build/ubuntu-server-next/hooks/032-installer-squashfs.binary b/live-build/ubuntu-server-live/hooks/032-installer-squashfs.binary similarity index 98% rename from live-build/ubuntu-server-next/hooks/032-installer-squashfs.binary rename to live-build/ubuntu-server-live/hooks/032-installer-squashfs.binary index 08885af6..e50f80ab 100755 --- a/live-build/ubuntu-server-next/hooks/032-installer-squashfs.binary +++ b/live-build/ubuntu-server-live/hooks/032-installer-squashfs.binary @@ -161,7 +161,7 @@ umount "binary/boot/squashfs.dir/tmp" apt-get -qqy install squashfs-tools -squashfs_f="${PWD}/livecd.ubuntu-server-next.installer.squashfs" +squashfs_f="${PWD}/livecd.${PROJECT}.installer.squashfs" (cd "$OVERLAY_ROOT/" && mksquashfs . ${squashfs_f} \ diff --git a/live-build/ubuntu-server-next/hooks/99-fix-resolvconf.chroot b/live-build/ubuntu-server-live/hooks/99-fix-resolvconf.chroot similarity index 100% rename from live-build/ubuntu-server-next/hooks/99-fix-resolvconf.chroot rename to live-build/ubuntu-server-live/hooks/99-fix-resolvconf.chroot diff --git a/live-build/ubuntu-server-next/includes.binary/boot/overlay.dir/lib/systemd/system/multi-user.target.wants/subiquity.service b/live-build/ubuntu-server-live/includes.binary/boot/overlay.dir/lib/systemd/system/multi-user.target.wants/subiquity.service similarity index 100% rename from live-build/ubuntu-server-next/includes.binary/boot/overlay.dir/lib/systemd/system/multi-user.target.wants/subiquity.service rename to live-build/ubuntu-server-live/includes.binary/boot/overlay.dir/lib/systemd/system/multi-user.target.wants/subiquity.service diff --git a/live-build/ubuntu-server-next/includes.binary/boot/overlay.dir/lib/systemd/system/subiquity-debug@.service b/live-build/ubuntu-server-live/includes.binary/boot/overlay.dir/lib/systemd/system/subiquity-debug@.service similarity index 100% rename from live-build/ubuntu-server-next/includes.binary/boot/overlay.dir/lib/systemd/system/subiquity-debug@.service rename to live-build/ubuntu-server-live/includes.binary/boot/overlay.dir/lib/systemd/system/subiquity-debug@.service diff --git a/live-build/ubuntu-server-next/includes.binary/boot/overlay.dir/lib/systemd/system/subiquity.service b/live-build/ubuntu-server-live/includes.binary/boot/overlay.dir/lib/systemd/system/subiquity.service similarity index 100% rename from live-build/ubuntu-server-next/includes.binary/boot/overlay.dir/lib/systemd/system/subiquity.service rename to live-build/ubuntu-server-live/includes.binary/boot/overlay.dir/lib/systemd/system/subiquity.service diff --git a/live-build/ubuntu-server-next/includes.chroot/etc/hosts b/live-build/ubuntu-server-live/includes.chroot/etc/hosts similarity index 100% rename from live-build/ubuntu-server-next/includes.chroot/etc/hosts rename to live-build/ubuntu-server-live/includes.chroot/etc/hosts From 2cfa4a90881bff63fccb2ea93161106193ee8f50 Mon Sep 17 00:00:00 2001 From: Mathieu Trudel-Lapierre Date: Thu, 6 Apr 2017 15:11:05 -0400 Subject: [PATCH 08/19] Override gettys to wait for the user the press enter, and autologin to the ubuntu user. --- .../lib/systemd/system/getty@.service.d/autologin.conf | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 live-build/ubuntu-server-live/includes.binary/boot/overlay.dir/lib/systemd/system/getty@.service.d/autologin.conf diff --git a/live-build/ubuntu-server-live/includes.binary/boot/overlay.dir/lib/systemd/system/getty@.service.d/autologin.conf b/live-build/ubuntu-server-live/includes.binary/boot/overlay.dir/lib/systemd/system/getty@.service.d/autologin.conf new file mode 100644 index 00000000..2c08352a --- /dev/null +++ b/live-build/ubuntu-server-live/includes.binary/boot/overlay.dir/lib/systemd/system/getty@.service.d/autologin.conf @@ -0,0 +1,3 @@ +[Service] +ExecStart= +ExecStart=-/sbin/agetty --noclear --login-pause --autologin ubuntu %I $TERM From 715f13b887ef45cda3b32512c0660a4ab12478b6 Mon Sep 17 00:00:00 2001 From: Mathieu Trudel-Lapierre Date: Thu, 6 Apr 2017 15:39:44 -0400 Subject: [PATCH 09/19] Don't spam with unnecessary login messages; skip login altogether. --- .../lib/systemd/system/getty@.service.d/autologin.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/live-build/ubuntu-server-live/includes.binary/boot/overlay.dir/lib/systemd/system/getty@.service.d/autologin.conf b/live-build/ubuntu-server-live/includes.binary/boot/overlay.dir/lib/systemd/system/getty@.service.d/autologin.conf index 2c08352a..535e4f0c 100644 --- a/live-build/ubuntu-server-live/includes.binary/boot/overlay.dir/lib/systemd/system/getty@.service.d/autologin.conf +++ b/live-build/ubuntu-server-live/includes.binary/boot/overlay.dir/lib/systemd/system/getty@.service.d/autologin.conf @@ -1,3 +1,3 @@ [Service] ExecStart= -ExecStart=-/sbin/agetty --noclear --login-pause --autologin ubuntu %I $TERM +ExecStart=-/sbin/agetty --noclear -n --autologin ubuntu %I $TERM From 97303de4280d568f202fe7a9e4cbdd1435170db1 Mon Sep 17 00:00:00 2001 From: Mathieu Trudel-Lapierre Date: Thu, 6 Apr 2017 16:24:44 -0400 Subject: [PATCH 10/19] Add ubuntu-server-live for a subiquity-based server image. --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 50660829..e87c41a0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,6 @@ -livecd-rootfs (2.441~mtrudel2) zesty; urgency=medium +livecd-rootfs (2.441) UNRELEASED; urgency=medium - * + * Add ubuntu-server-live for a subiquity-based server image. -- Mathieu Trudel-Lapierre Thu, 23 Mar 2017 16:20:16 -0400 From 292c5f300c99a731c5d260da70a7acb6b418d7dc Mon Sep 17 00:00:00 2001 From: Mathieu Trudel-Lapierre Date: Thu, 6 Apr 2017 16:47:28 -0400 Subject: [PATCH 11/19] De-duplicate functions in ubuntu-server-live; use the file from ubuntu-cpc. --- live-build/ubuntu-server-live/functions | 272 +----------------------- 1 file changed, 1 insertion(+), 271 deletions(-) mode change 100644 => 120000 live-build/ubuntu-server-live/functions diff --git a/live-build/ubuntu-server-live/functions b/live-build/ubuntu-server-live/functions deleted file mode 100644 index d58d9127..00000000 --- a/live-build/ubuntu-server-live/functions +++ /dev/null @@ -1,271 +0,0 @@ -# vi: ts=4 expandtab syntax=sh - -CLOUD_IMG_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process" -IMAGE_SIZE=$((2252*1024**2)) # 2.2G (the current size we ship) - -rootfs_dev_mapper= -loop_device= -loop_raw= -backing_img= - -apt-get -qqy install dosfstools gdisk - -clean_loops() { - - if [ -n "${backing_img}" ]; then - kpartx -v -d "${backing_img}" - unset backing_img - fi - - if [ -z "${rootfs_dev_mapper}" ]; then - return 0 - fi - - unset loop_device - unset loop_raw - unset rootfs_dev_mapper -} - -create_empty_disk_image() { - # Prepare an empty disk image - dd if=/dev/zero of="$1" bs=1 count=0 seek="${IMAGE_SIZE}" -} - -make_ext4_partition() { - device="$1" - - mkfs.ext4 -F -b 4096 -i 8192 -m 0 -L cloudimg-rootfs -E resize=536870912 "$device" -} - -mount_image() { - apt-get install -qqy kpartx - trap clean_loops EXIT - backing_img="$1" - local rootpart="$2" - kpartx_mapping="$(kpartx -s -v -a ${backing_img})" - - # Find the loop device - loop_p1="$(echo -e ${kpartx_mapping} | head -n1 | awk '{print$3}')" - loop_device="/dev/loop$(echo ${loop_p1} | cut -b5)" - if [ ! -b ${loop_device} ]; then - echo "unable to find loop device for ${backing_img}" - exit 1 - fi - - # Find the rootfs location - rootfs_dev_mapper="/dev/mapper/${loop_p1%%[0-9]}${rootpart}" - if [ ! -b "${rootfs_dev_mapper}" ]; then - echo "${rootfs_dev_mapper} is not a block device"; - exit 1 - fi - - # Add some information to the debug logs - echo "Mounted disk image ${backing_img} to ${rootfs_dev_mapper}" - blkid ${rootfs_dev_mapper} - - return 0 -} - -setup_mountpoint() { - local mountpoint="$1" - - mount --bind /dev "$mountpoint/dev" - mount devpts-live -t proc "$mountpoint/dev/pts" - mount proc-live -t proc "$mountpoint/proc" - mount sysfs-live -t sysfs "$mountpoint/sys" - mount -t tmpfs none "$mountpoint/tmp" - mv "$mountpoint/etc/resolv.conf" resolv.conf.tmp - cp /etc/resolv.conf "$mountpoint/etc/resolv.conf" - -} - -mount_partition() { - partition="$1" - mountpoint="$2" - - mount "$partition" "$mountpoint" - setup_mountpoint "$mountpoint" -} - - -mount_overlay() { - lower="$1" - upper="$2" - work="$2/../work" - path="$3" - - mkdir -p "$work" - mount -t overlay overlay \ - -olowerdir="$lower",upperdir="$upper",workdir="$work" \ - "$path" -} - -mount_disk_image() { - local disk_image=${1} - local mountpoint=${2} - mount_image ${disk_image} 1 - mount_partition "${rootfs_dev_mapper}" $mountpoint - - local uefi_dev="/dev/mapper${loop_device///dev/}p15" - if [ -b ${uefi_dev} -a -e $mountpoint/boot/efi ]; then - mount "${uefi_dev}" $mountpoint/boot/efi - fi - - # This is needed to allow for certain operations - # such as updating grub and installing software - cat > $mountpoint/usr/sbin/policy-rc.d << EOF -#!/bin/sh -# ${CLOUD_IMG_STR} -echo "All runlevel operations denied by policy" >&2 -exit 101 -EOF - chmod 0755 $mountpoint/usr/sbin/policy-rc.d - -} - -umount_settle() { - # Unmount device, and let it settle - umount $1 - udevadm settle -} - -umount_partition() { - local mountpoint=${1} - mv resolv.conf.tmp "$mountpoint/etc/resolv.conf" - for submnt in proc sys dev/pts dev tmp; - do - umount $mountpoint/$submnt - done - umount $mountpoint - udevadm settle - - if [ -n "${rootfs_dev_mapper}" -a -b "${rootfs_dev_mapper}" ]; then - # buildd's don't have /etc/mtab symlinked - # /etc/mtab is needed in order zerofree space for ext4 filesystems - [ -e /etc/mtab ] || ln -s /proc/mounts /etc/mtab - - # both of these are likely overkill, but it does result in slightly - # smaller ext4 filesystem - apt-get -qqy install zerofree - e2fsck -y -E discard ${rootfs_dev_mapper} - zerofree ${rootfs_dev_mapper} - fi -} - -umount_disk_image() { - mountpoint="$1" - - local uefi_dev="/dev/mapper${loop_device///dev/}p15" - if [ -e "$mountpoint/boot/efi" -a -b "$uefi_dev" ]; then - umount --detach-loop "$mountpoint/boot/efi" - fi - - if [ -e $mountpoint/usr/sbin/policy-rc.d ]; then - rm $mountpoint/usr/sbin/policy-rc.d - fi - umount_partition $mountpoint - clean_loops -} - -modify_vmdk_header() { - # Modify the VMDK headers so that both VirtualBox _and_ VMware can - # read the vmdk and import them. The vodoo here is _not_ documented - # anywhere....so this will have to do. This is undocumented vodoo - # that has been learned by the Cloud Image team. - - vmdk_name="${1}" - descriptor=$(mktemp) - newdescriptor=$(mktemp) - - # Extract the vmdk header for manipulation - dd if="${vmdk_name}" of="${descriptor}" bs=1 skip=512 count=1024 - - # The sed lines below is where the magic is. Specifically: - # ddb.toolsVersion: sets the open-vm-tools so that VMware shows - # the tooling as current - # ddb.virtualHWVersion: set the version to 7, which covers most - # current versions of VMware - # createType: make sure its set to stream Optimized - # remove the vmdk-stream-converter comment and replace with - # # Disk DescriptorFile. This is needed for Virtualbox - # remove the comments from vmdk-stream-converter which causes - # VirtualBox and others to fail VMDK validation - - sed -e 's|# Description file.*|# Disk DescriptorFile|' \ - -e '/# Believe this is random*/d' \ - -e '/# Indicates no parent/d' \ - -e '/# The Disk Data Base/d' \ - -e 's|ddb.comment.*|ddb.toolsVersion = "2147483647"|' \ - "${descriptor}" > "${newdescriptor}" - - # The header is cannot be bigger than 1024 - expr $(stat --format=%s ${newdescriptor}) \< 1024 > /dev/null 2>&1 || { - echo "descriptor is too large, VMDK will be invalid!"; exit 1; } - - # Overwrite the vmdk header with our new, modified one - dd conv=notrunc,nocreat \ - if="${newdescriptor}" of="${vmdk_name}" \ - bs=1 seek=512 count=1024 - - rm ${descriptor} ${newdescriptor} -} - -create_vmdk() { - # There is no real good way to create a _compressed_ VMDK using open source - # tooling that works across multiple VMDK-capable platforms. This functions - # uses vmdk-stream-converter and then calls modify_vmdk_header to produce a - # compatible VMDK. - - src="$1" - destination="$2" - size="${3:-10240}" - - apt-get install -qqy qemu-utils vmdk-stream-converter - streamconverter="/usr/share/pyshared/VMDKstream.py" - scratch_d=$(mktemp -d) - cp ${src} ${scratch_d}/resize.img - - truncate --size=${size}M ${scratch_d}/resize.img - python ${streamconverter} ${scratch_d}/resize.img ${destination} - modify_vmdk_header ${destination} - - qemu-img info ${destination} - rm -rf ${scratch_d} -} - -create_derivative() { - # arg1 is the disk type - # arg2 is the new name - unset derivative_img - case ${1} in - uefi) disk_image="binary/boot/disk-uefi.ext4"; - dname="${disk_image//-uefi/-$2-uefi}";; - *) disk_image="binary/boot/disk.ext4"; - dname="${disk_image//.ext4/-$2.ext4}";; - esac - - if [ ! -e ${disk_image} ]; then - echo "Did not find ${disk_image}!"; exit 1; - fi - - cp ${disk_image} ${dname} - export derivative_img=${dname} -} - -convert_to_qcow2() { - apt-get install -qqy qemu-utils - - src="$1" - destination="$2" - qemu-img convert -c -O qcow2 -o compat=0.10 "$src" "$destination" - qemu-img info "$destination" -} - -replace_grub_root_with_label() { - # When update-grub is run, it will detect the disks in the build system. - # Instead, we want grub to use the cloudimg-rootfs labelled disk - CHROOT_ROOT="$1" - - sed -i -e "s,root=[^ ]\+,root=LABEL=cloudimg-rootfs," \ - "$CHROOT_ROOT/boot/grub/grub.cfg" -} diff --git a/live-build/ubuntu-server-live/functions b/live-build/ubuntu-server-live/functions new file mode 120000 index 00000000..bca29a2f --- /dev/null +++ b/live-build/ubuntu-server-live/functions @@ -0,0 +1 @@ +../ubuntu-cpc/functions \ No newline at end of file From 46fd6c58f5565e2b19ae43c4837919226677dd53 Mon Sep 17 00:00:00 2001 From: Mathieu Trudel-Lapierre Date: Fri, 7 Apr 2017 17:14:56 -0400 Subject: [PATCH 12/19] Refactor functions out of ubuntu-cpc and ubuntu-server hooks. --- debian/changelog | 1 + live-build/{ubuntu-cpc => auto}/functions | 16 ++++++++-------- .../ubuntu-cpc/hooks/032-disk-image.binary | 5 ++++- .../ubuntu-cpc/hooks/032-root-squashfs.binary | 2 +- .../ubuntu-cpc/hooks/033-disk-image-uefi.binary | 5 ++++- .../hooks/034-disk-image-ppc64el.binary | 5 ++++- .../ubuntu-cpc/hooks/040-qcow2-image.binary | 2 +- .../ubuntu-cpc/hooks/040-vmdk-image.binary | 2 +- live-build/ubuntu-cpc/hooks/042-vagrant.binary | 2 +- live-build/ubuntu-cpc/hooks/999-extras.binary | 2 +- live-build/ubuntu-server-live/functions | 1 - .../hooks/030-root-squashfs.binary | 2 +- .../hooks/032-installer-squashfs.binary | 2 +- 13 files changed, 28 insertions(+), 19 deletions(-) rename live-build/{ubuntu-cpc => auto}/functions (93%) delete mode 120000 live-build/ubuntu-server-live/functions diff --git a/debian/changelog b/debian/changelog index e87c41a0..482044a8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ livecd-rootfs (2.441) UNRELEASED; urgency=medium * Add ubuntu-server-live for a subiquity-based server image. + * Refactor functions out of ubuntu-cpc and ubuntu-server hooks. -- Mathieu Trudel-Lapierre Thu, 23 Mar 2017 16:20:16 -0400 diff --git a/live-build/ubuntu-cpc/functions b/live-build/auto/functions similarity index 93% rename from live-build/ubuntu-cpc/functions rename to live-build/auto/functions index c7ff023b..af555998 100644 --- a/live-build/ubuntu-cpc/functions +++ b/live-build/auto/functions @@ -1,7 +1,7 @@ # vi: ts=4 expandtab syntax=sh -CLOUD_IMG_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process" -IMAGE_SIZE=$((2252*1024**2)) # 2.2G (the current size we ship) +imagesize=${IMAGE_SIZE:-$((2252*1024**2))} # 2.2G (the current size we ship) +fs_label="${FS_LABEL:-rootfs}" rootfs_dev_mapper= loop_device= @@ -28,13 +28,13 @@ clean_loops() { create_empty_disk_image() { # Prepare an empty disk image - dd if=/dev/zero of="$1" bs=1 count=0 seek="${IMAGE_SIZE}" + dd if=/dev/zero of="$1" bs=1 count=0 seek="${imagesize}" } make_ext4_partition() { device="$1" - - mkfs.ext4 -F -b 4096 -i 8192 -m 0 -L cloudimg-rootfs -E resize=536870912 "$device" + label=${fs_label:+-L "${fs_label}"} + mkfs.ext4 -F -b 4096 -i 8192 -m 0 ${label} -E resize=536870912 "$device" } mount_image() { @@ -103,7 +103,7 @@ mount_disk_image() { # such as updating grub and installing software cat > $mountpoint/usr/sbin/policy-rc.d << EOF #!/bin/sh -# ${CLOUD_IMG_STR} +# ${IMAGE_STR} echo "All runlevel operations denied by policy" >&2 exit 101 EOF @@ -251,9 +251,9 @@ convert_to_qcow2() { replace_grub_root_with_label() { # When update-grub is run, it will detect the disks in the build system. - # Instead, we want grub to use the cloudimg-rootfs labelled disk + # Instead, we want grub to use the right labelled disk CHROOT_ROOT="$1" - sed -i -e "s,root=[^ ]\+,root=LABEL=cloudimg-rootfs," \ + sed -i -e "s,root=[^ ]\+,root=LABEL=${fs_label}," \ "$CHROOT_ROOT/boot/grub/grub.cfg" } diff --git a/live-build/ubuntu-cpc/hooks/032-disk-image.binary b/live-build/ubuntu-cpc/hooks/032-disk-image.binary index 0ed08b04..54df55a1 100755 --- a/live-build/ubuntu-cpc/hooks/032-disk-image.binary +++ b/live-build/ubuntu-cpc/hooks/032-disk-image.binary @@ -1,6 +1,9 @@ #!/bin/bash -ex -. /build/config/functions +IMAGE_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process" +FS_LABEL="cloudimg-rootfs" + +. auto/functions BOOTPART_START= BOOTPART_END= diff --git a/live-build/ubuntu-cpc/hooks/032-root-squashfs.binary b/live-build/ubuntu-cpc/hooks/032-root-squashfs.binary index 63a00894..f129384c 100755 --- a/live-build/ubuntu-cpc/hooks/032-root-squashfs.binary +++ b/live-build/ubuntu-cpc/hooks/032-root-squashfs.binary @@ -17,7 +17,7 @@ if [ -n "$SUBARCH" ]; then exit 0 fi -. /build/config/functions +. auto/functions mkdir binary/boot/squashfs.dir cp -a chroot/* binary/boot/squashfs.dir diff --git a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary index 04a3c7df..e1ea4f9b 100755 --- a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary +++ b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary @@ -9,7 +9,10 @@ case $ARCH in ;; esac -. /build/config/functions +IMAGE_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process" +FS_LABEL="cloudimg-rootfs" + +. auto/functions apt-get -qqy install dosfstools gdisk diff --git a/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary b/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary index 1f6b35a7..a0281ee2 100755 --- a/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary +++ b/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary @@ -7,7 +7,10 @@ case $ARCH in ;; esac -. /build/config/functions +IMAGE_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process" +FS_LABEL="cloudimg-rootfs" + +. auto/functions create_partitions() { disk_image="$1" diff --git a/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary b/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary index f9ab7e62..9b1c6c32 100755 --- a/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary +++ b/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary @@ -21,7 +21,7 @@ esac apt-get install -qqy qemu-utils -. /build/config/functions +. auto/functions if [ -f binary/boot/disk-uefi.ext4 ]; then convert_to_qcow2 binary/boot/disk-uefi.ext4 livecd.ubuntu-cpc.img diff --git a/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary b/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary index 9a71f7ff..6c7bbeb0 100755 --- a/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary +++ b/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary @@ -18,7 +18,7 @@ case ${IMAGE_TARGETS:-} in ;; esac -. /build/config/functions +. auto/functions if [ -e binary/boot/disk-uefi.ext4 ]; then create_vmdk binary/boot/disk-uefi.ext4 livecd.ubuntu-cpc.vmdk diff --git a/live-build/ubuntu-cpc/hooks/042-vagrant.binary b/live-build/ubuntu-cpc/hooks/042-vagrant.binary index 3f962bd8..4be0b7f8 100755 --- a/live-build/ubuntu-cpc/hooks/042-vagrant.binary +++ b/live-build/ubuntu-cpc/hooks/042-vagrant.binary @@ -44,7 +44,7 @@ case $ARCH in exit 0;; esac -. /build/config/functions +. auto/functions # Virtualbox is needed for making a small VMDK apt-get -qqy install genisoimage qemu-utils diff --git a/live-build/ubuntu-cpc/hooks/999-extras.binary b/live-build/ubuntu-cpc/hooks/999-extras.binary index ffc7c691..f5790201 100755 --- a/live-build/ubuntu-cpc/hooks/999-extras.binary +++ b/live-build/ubuntu-cpc/hooks/999-extras.binary @@ -9,7 +9,7 @@ if [ ! -d ${my_dir}/extra ]; then fi # Export the common functions to the extras -. /build/config/functions +. auto/functions # Cleaner execution /bin/run-parts --regex ".*\.binary" "${extra_d}" diff --git a/live-build/ubuntu-server-live/functions b/live-build/ubuntu-server-live/functions deleted file mode 120000 index bca29a2f..00000000 --- a/live-build/ubuntu-server-live/functions +++ /dev/null @@ -1 +0,0 @@ -../ubuntu-cpc/functions \ No newline at end of file diff --git a/live-build/ubuntu-server-live/hooks/030-root-squashfs.binary b/live-build/ubuntu-server-live/hooks/030-root-squashfs.binary index 48f60193..eb03d7fc 100755 --- a/live-build/ubuntu-server-live/hooks/030-root-squashfs.binary +++ b/live-build/ubuntu-server-live/hooks/030-root-squashfs.binary @@ -20,7 +20,7 @@ if [ -n "$SUBARCH" ]; then exit 0 fi -. /build/config/functions +. auto/functions mkdir binary/boot/squashfs.dir cp -a chroot/* binary/boot/squashfs.dir diff --git a/live-build/ubuntu-server-live/hooks/032-installer-squashfs.binary b/live-build/ubuntu-server-live/hooks/032-installer-squashfs.binary index e50f80ab..f71d9674 100755 --- a/live-build/ubuntu-server-live/hooks/032-installer-squashfs.binary +++ b/live-build/ubuntu-server-live/hooks/032-installer-squashfs.binary @@ -21,7 +21,7 @@ if [ -n "$SUBARCH" ]; then exit 0 fi -. /build/config/functions +. auto/functions SQUASH_ROOT=binary/boot/squashfs.dir OVERLAY_ROOT=binary/boot/overlay.dir From ab949fac1802ff7ce193be7fa324791baa9c4fb9 Mon Sep 17 00:00:00 2001 From: Mathieu Trudel-Lapierre Date: Fri, 7 Apr 2017 17:15:54 -0400 Subject: [PATCH 13/19] Rename ubuntu-server-live -> ubuntu-server --- live-build/auto/config | 35 +++++++++++-------- .../hooks/01-setup_modules.chroot | 0 .../hooks/030-root-squashfs.binary | 0 .../hooks/032-installer-squashfs.binary | 0 .../hooks/99-fix-resolvconf.chroot | 0 .../system/getty@.service.d/autologin.conf | 0 .../multi-user.target.wants/subiquity.service | 0 .../systemd/system/subiquity-debug@.service | 0 .../lib/systemd/system/subiquity.service | 0 .../includes.chroot/etc/hosts | 0 10 files changed, 20 insertions(+), 15 deletions(-) rename live-build/{ubuntu-server-live => ubuntu-server}/hooks/01-setup_modules.chroot (100%) rename live-build/{ubuntu-server-live => ubuntu-server}/hooks/030-root-squashfs.binary (100%) rename live-build/{ubuntu-server-live => ubuntu-server}/hooks/032-installer-squashfs.binary (100%) rename live-build/{ubuntu-server-live => ubuntu-server}/hooks/99-fix-resolvconf.chroot (100%) rename live-build/{ubuntu-server-live => ubuntu-server}/includes.binary/boot/overlay.dir/lib/systemd/system/getty@.service.d/autologin.conf (100%) rename live-build/{ubuntu-server-live => ubuntu-server}/includes.binary/boot/overlay.dir/lib/systemd/system/multi-user.target.wants/subiquity.service (100%) rename live-build/{ubuntu-server-live => ubuntu-server}/includes.binary/boot/overlay.dir/lib/systemd/system/subiquity-debug@.service (100%) rename live-build/{ubuntu-server-live => ubuntu-server}/includes.binary/boot/overlay.dir/lib/systemd/system/subiquity.service (100%) rename live-build/{ubuntu-server-live => ubuntu-server}/includes.chroot/etc/hosts (100%) diff --git a/live-build/auto/config b/live-build/auto/config index b5d7d471..1521dbe7 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -101,11 +101,11 @@ add_binary_hook () BINARY_HOOKS="${BINARY_HOOKS:+$BINARY_HOOKS }$1" } -case $PROJECT in - ubuntu-cpc) +case $PROJECT:$SUBPROJECT in + ubuntu-cpc:*) IMAGEFORMAT=ext4 ;; - ubuntu-server-live) + ubuntu-server:live) IMAGEFORMAT=plain ;; esac @@ -133,7 +133,13 @@ case $IMAGEFORMAT in plain) OPTS="${OPTS:+$OPTS }--initramfs none --chroot-filesystem $IMAGEFORMAT" - PREINSTALLED=true + case $PROJECT:$SUBPROJECT in + ubuntu-server:live) + ;; + *) + PREINSTALLED=true + ;; + esac ;; *) @@ -147,7 +153,7 @@ case $IMAGEFORMAT in ;; esac -if [ "$PREINSTALLED" = "true" ] && [ "$SUBPROJECT" != "wubi" ]; then +if [ "$PREINSTALLED" = "true" ]; then # This is an oem-config preinstalled image, touch a random file that # we can refer back to during build, cause that's wildly hackish touch config/oem-config-preinstalled @@ -171,7 +177,7 @@ if [ "$PREINSTALLED" = "true" ] && [ "$SUBPROJECT" != "wubi" ]; then ubuntu-server) add_package live oem-config-debconf ubiquity-frontend-debconf ;; - ubuntu-core|ubuntu-base|base|ubuntu-touch|ubuntu-touch-custom|ubuntu-cpc|ubuntu-desktop-next|ubuntu-server-live) + ubuntu-core|ubuntu-base|base|ubuntu-touch|ubuntu-touch-custom|ubuntu-cpc|ubuntu-desktop-next) ;; *) add_package live oem-config-gtk ubiquity-frontend-gtk @@ -366,18 +372,17 @@ case $PROJECT in ubuntu-server) add_task install minimal + case $SUBPROJECT in + live) + add_task install standard + add_task install server + LIVE_TASK='cloud-image' + ;; + esac COMPONENTS='main' PREINSTALL_POOL_SEEDS='server-ship' ;; - ubuntu-server-live) - add_task install minimal - add_task install standard - add_task install server - add_task install cloud-image - COMPONENTS='main' - ;; - ubuntu-core) OPTS="${OPTS:+$OPTS }--apt-recommends false" @@ -759,7 +764,7 @@ EOF fi ;; - ubuntu-touch:*|ubuntu-touch-custom:*|ubuntu-core:system-image|ubuntu-desktop-next:system-image|ubuntu-cpc:*|ubuntu-server-live:*) + ubuntu-touch:*|ubuntu-touch-custom:*|ubuntu-core:system-image|ubuntu-desktop-next:system-image|ubuntu-cpc:*|ubuntu-server:live) cp -af /usr/share/livecd-rootfs/live-build/${PROJECT}/* \ config/ ;; diff --git a/live-build/ubuntu-server-live/hooks/01-setup_modules.chroot b/live-build/ubuntu-server/hooks/01-setup_modules.chroot similarity index 100% rename from live-build/ubuntu-server-live/hooks/01-setup_modules.chroot rename to live-build/ubuntu-server/hooks/01-setup_modules.chroot diff --git a/live-build/ubuntu-server-live/hooks/030-root-squashfs.binary b/live-build/ubuntu-server/hooks/030-root-squashfs.binary similarity index 100% rename from live-build/ubuntu-server-live/hooks/030-root-squashfs.binary rename to live-build/ubuntu-server/hooks/030-root-squashfs.binary diff --git a/live-build/ubuntu-server-live/hooks/032-installer-squashfs.binary b/live-build/ubuntu-server/hooks/032-installer-squashfs.binary similarity index 100% rename from live-build/ubuntu-server-live/hooks/032-installer-squashfs.binary rename to live-build/ubuntu-server/hooks/032-installer-squashfs.binary diff --git a/live-build/ubuntu-server-live/hooks/99-fix-resolvconf.chroot b/live-build/ubuntu-server/hooks/99-fix-resolvconf.chroot similarity index 100% rename from live-build/ubuntu-server-live/hooks/99-fix-resolvconf.chroot rename to live-build/ubuntu-server/hooks/99-fix-resolvconf.chroot diff --git a/live-build/ubuntu-server-live/includes.binary/boot/overlay.dir/lib/systemd/system/getty@.service.d/autologin.conf b/live-build/ubuntu-server/includes.binary/boot/overlay.dir/lib/systemd/system/getty@.service.d/autologin.conf similarity index 100% rename from live-build/ubuntu-server-live/includes.binary/boot/overlay.dir/lib/systemd/system/getty@.service.d/autologin.conf rename to live-build/ubuntu-server/includes.binary/boot/overlay.dir/lib/systemd/system/getty@.service.d/autologin.conf diff --git a/live-build/ubuntu-server-live/includes.binary/boot/overlay.dir/lib/systemd/system/multi-user.target.wants/subiquity.service b/live-build/ubuntu-server/includes.binary/boot/overlay.dir/lib/systemd/system/multi-user.target.wants/subiquity.service similarity index 100% rename from live-build/ubuntu-server-live/includes.binary/boot/overlay.dir/lib/systemd/system/multi-user.target.wants/subiquity.service rename to live-build/ubuntu-server/includes.binary/boot/overlay.dir/lib/systemd/system/multi-user.target.wants/subiquity.service diff --git a/live-build/ubuntu-server-live/includes.binary/boot/overlay.dir/lib/systemd/system/subiquity-debug@.service b/live-build/ubuntu-server/includes.binary/boot/overlay.dir/lib/systemd/system/subiquity-debug@.service similarity index 100% rename from live-build/ubuntu-server-live/includes.binary/boot/overlay.dir/lib/systemd/system/subiquity-debug@.service rename to live-build/ubuntu-server/includes.binary/boot/overlay.dir/lib/systemd/system/subiquity-debug@.service diff --git a/live-build/ubuntu-server-live/includes.binary/boot/overlay.dir/lib/systemd/system/subiquity.service b/live-build/ubuntu-server/includes.binary/boot/overlay.dir/lib/systemd/system/subiquity.service similarity index 100% rename from live-build/ubuntu-server-live/includes.binary/boot/overlay.dir/lib/systemd/system/subiquity.service rename to live-build/ubuntu-server/includes.binary/boot/overlay.dir/lib/systemd/system/subiquity.service diff --git a/live-build/ubuntu-server-live/includes.chroot/etc/hosts b/live-build/ubuntu-server/includes.chroot/etc/hosts similarity index 100% rename from live-build/ubuntu-server-live/includes.chroot/etc/hosts rename to live-build/ubuntu-server/includes.chroot/etc/hosts From 46bae4cebfbc29a1310603875206c5cbc2e03430 Mon Sep 17 00:00:00 2001 From: Mathieu Trudel-Lapierre Date: Tue, 11 Apr 2017 17:16:35 -0400 Subject: [PATCH 14/19] Fix up functions refactoring tfor a proper path to the file. --- live-build/auto/config | 3 +++ live-build/{auto => }/functions | 11 +++++++++++ live-build/ubuntu-cpc/hooks/032-disk-image.binary | 2 +- live-build/ubuntu-cpc/hooks/032-root-squashfs.binary | 2 +- .../ubuntu-cpc/hooks/033-disk-image-uefi.binary | 2 +- .../ubuntu-cpc/hooks/034-disk-image-ppc64el.binary | 2 +- live-build/ubuntu-cpc/hooks/040-qcow2-image.binary | 2 +- live-build/ubuntu-cpc/hooks/040-vmdk-image.binary | 2 +- live-build/ubuntu-cpc/hooks/042-vagrant.binary | 2 +- live-build/ubuntu-cpc/hooks/999-extras.binary | 2 +- .../ubuntu-server/hooks/030-root-squashfs.binary | 2 +- .../ubuntu-server/hooks/032-installer-squashfs.binary | 2 +- 12 files changed, 24 insertions(+), 10 deletions(-) rename live-build/{auto => }/functions (97%) diff --git a/live-build/auto/config b/live-build/auto/config index 1521dbe7..f5835313 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -33,6 +33,9 @@ if [ -z "$MIRROR" ]; then esac fi +mkdir -p config +cp -af /usr/share/livecd-rootfs/live-build/functions config/functions + mkdir -p config/package-lists add_task () diff --git a/live-build/auto/functions b/live-build/functions similarity index 97% rename from live-build/auto/functions rename to live-build/functions index af555998..6e4668eb 100644 --- a/live-build/auto/functions +++ b/live-build/functions @@ -87,6 +87,17 @@ mount_partition() { setup_mountpoint "$mountpoint" } +mount_overlay() { + lower="$1" + upper="$2" + work="$2/../work" + path="$3" + + mkdir -p "$work" + mount -t overlay overlay \ + -olowerdir="$lower",upperdir="$upper",workdir="$work" \ + "$path" +} mount_disk_image() { local disk_image=${1} diff --git a/live-build/ubuntu-cpc/hooks/032-disk-image.binary b/live-build/ubuntu-cpc/hooks/032-disk-image.binary index 54df55a1..929c84d0 100755 --- a/live-build/ubuntu-cpc/hooks/032-disk-image.binary +++ b/live-build/ubuntu-cpc/hooks/032-disk-image.binary @@ -3,7 +3,7 @@ IMAGE_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process" FS_LABEL="cloudimg-rootfs" -. auto/functions +. config/functions BOOTPART_START= BOOTPART_END= diff --git a/live-build/ubuntu-cpc/hooks/032-root-squashfs.binary b/live-build/ubuntu-cpc/hooks/032-root-squashfs.binary index f129384c..0a1d51ce 100755 --- a/live-build/ubuntu-cpc/hooks/032-root-squashfs.binary +++ b/live-build/ubuntu-cpc/hooks/032-root-squashfs.binary @@ -17,7 +17,7 @@ if [ -n "$SUBARCH" ]; then exit 0 fi -. auto/functions +. config/functions mkdir binary/boot/squashfs.dir cp -a chroot/* binary/boot/squashfs.dir diff --git a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary index e1ea4f9b..d7885346 100755 --- a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary +++ b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary @@ -12,7 +12,7 @@ esac IMAGE_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process" FS_LABEL="cloudimg-rootfs" -. auto/functions +. config/functions apt-get -qqy install dosfstools gdisk diff --git a/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary b/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary index a0281ee2..55e1dc84 100755 --- a/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary +++ b/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary @@ -10,7 +10,7 @@ esac IMAGE_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process" FS_LABEL="cloudimg-rootfs" -. auto/functions +. config/functions create_partitions() { disk_image="$1" diff --git a/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary b/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary index 9b1c6c32..d2a00b11 100755 --- a/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary +++ b/live-build/ubuntu-cpc/hooks/040-qcow2-image.binary @@ -21,7 +21,7 @@ esac apt-get install -qqy qemu-utils -. auto/functions +. config/functions if [ -f binary/boot/disk-uefi.ext4 ]; then convert_to_qcow2 binary/boot/disk-uefi.ext4 livecd.ubuntu-cpc.img diff --git a/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary b/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary index 6c7bbeb0..7c2e0e54 100755 --- a/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary +++ b/live-build/ubuntu-cpc/hooks/040-vmdk-image.binary @@ -18,7 +18,7 @@ case ${IMAGE_TARGETS:-} in ;; esac -. auto/functions +. config/functions if [ -e binary/boot/disk-uefi.ext4 ]; then create_vmdk binary/boot/disk-uefi.ext4 livecd.ubuntu-cpc.vmdk diff --git a/live-build/ubuntu-cpc/hooks/042-vagrant.binary b/live-build/ubuntu-cpc/hooks/042-vagrant.binary index 4be0b7f8..382ac547 100755 --- a/live-build/ubuntu-cpc/hooks/042-vagrant.binary +++ b/live-build/ubuntu-cpc/hooks/042-vagrant.binary @@ -44,7 +44,7 @@ case $ARCH in exit 0;; esac -. auto/functions +. config/functions # Virtualbox is needed for making a small VMDK apt-get -qqy install genisoimage qemu-utils diff --git a/live-build/ubuntu-cpc/hooks/999-extras.binary b/live-build/ubuntu-cpc/hooks/999-extras.binary index f5790201..c36b1e7f 100755 --- a/live-build/ubuntu-cpc/hooks/999-extras.binary +++ b/live-build/ubuntu-cpc/hooks/999-extras.binary @@ -9,7 +9,7 @@ if [ ! -d ${my_dir}/extra ]; then fi # Export the common functions to the extras -. auto/functions +. config/functions # Cleaner execution /bin/run-parts --regex ".*\.binary" "${extra_d}" diff --git a/live-build/ubuntu-server/hooks/030-root-squashfs.binary b/live-build/ubuntu-server/hooks/030-root-squashfs.binary index eb03d7fc..dad337d0 100755 --- a/live-build/ubuntu-server/hooks/030-root-squashfs.binary +++ b/live-build/ubuntu-server/hooks/030-root-squashfs.binary @@ -20,7 +20,7 @@ if [ -n "$SUBARCH" ]; then exit 0 fi -. auto/functions +. config/functions mkdir binary/boot/squashfs.dir cp -a chroot/* binary/boot/squashfs.dir diff --git a/live-build/ubuntu-server/hooks/032-installer-squashfs.binary b/live-build/ubuntu-server/hooks/032-installer-squashfs.binary index f71d9674..32e57ca6 100755 --- a/live-build/ubuntu-server/hooks/032-installer-squashfs.binary +++ b/live-build/ubuntu-server/hooks/032-installer-squashfs.binary @@ -21,7 +21,7 @@ if [ -n "$SUBARCH" ]; then exit 0 fi -. auto/functions +. config/functions SQUASH_ROOT=binary/boot/squashfs.dir OVERLAY_ROOT=binary/boot/overlay.dir From 4613a2c82e23d5b6a0e002788e3e2ad534e4ada0 Mon Sep 17 00:00:00 2001 From: Mathieu Trudel-Lapierre Date: Tue, 11 Apr 2017 21:44:25 -0400 Subject: [PATCH 15/19] Don't outright remove fstab for ubuntu-server:live, that breaks grub-legacy-ec2. --- live-build/auto/config | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/live-build/auto/config b/live-build/auto/config index f5835313..77c33db4 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -713,16 +713,15 @@ EOF ;; esac -case $PROJECT in - ubuntu-server) - cat > config/hooks/100-remove-fstab.chroot < config/hooks/100-remove-fstab.chroot < config/hooks/100-ubuntukylin.chroot < config/hooks/100-ubuntukylin.chroot < config/binary_rootfs/excludes << EOF From 4e01beda8cac6b81a71cdc473f828886ca0d7f87 Mon Sep 17 00:00:00 2001 From: Mathieu Trudel-Lapierre Date: Tue, 11 Apr 2017 22:03:04 -0400 Subject: [PATCH 16/19] Set IMAGE_STR and FS_LABEL for ubuntu-cpc 999-extras.binary hook too; but also export CLOUD_IMG_STR. --- live-build/ubuntu-cpc/hooks/999-extras.binary | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/live-build/ubuntu-cpc/hooks/999-extras.binary b/live-build/ubuntu-cpc/hooks/999-extras.binary index c36b1e7f..c897359b 100755 --- a/live-build/ubuntu-cpc/hooks/999-extras.binary +++ b/live-build/ubuntu-cpc/hooks/999-extras.binary @@ -8,6 +8,10 @@ if [ ! -d ${my_dir}/extra ]; then exit 0 fi +IMAGE_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process" +CLOUD_IMG_STR="$IMAGE_STR" +FS_LABEL="cloudimg-rootfs" + # Export the common functions to the extras . config/functions From f8264a59c620563b830e362dcc10356c1f68e617 Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Tue, 11 Apr 2017 21:10:56 -0500 Subject: [PATCH 17/19] Change remaining CLOUD_IMG_STR references to IMAGE_STR --- live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary | 4 ++-- live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary index d7885346..3cf55ed1 100755 --- a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary +++ b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary @@ -78,7 +78,7 @@ install_grub() { esac cat << EOF >> mountpoint/etc/default/grub.d/50-cloudimg-settings.cfg -${CLOUD_IMG_STR} +${IMAGE_STR} # For Cloud Image compatability GRUB_PRELOAD_MODULES="${grub_modules}" EOF @@ -93,7 +93,7 @@ EOF if [ -f mountpoint/boot/efi/EFI/BOOT/grub.cfg ]; then sed -i "s| root| root hd0,gpt1|" mountpoint/boot/efi/EFI/BOOT/grub.cfg - sed -i "1i${CLOUD_IMG_STR}" mountpoint/boot/efi/EFI/BOOT/grub.cfg + sed -i "1i${IMAGE_STR}" mountpoint/boot/efi/EFI/BOOT/grub.cfg # For some reason the grub disk is looking for /boot/grub/grub.cfg on # part 15.... chroot mountpoint mkdir -p /boot/efi/boot/grub diff --git a/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary b/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary index 55e1dc84..bad7297d 100755 --- a/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary +++ b/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary @@ -36,7 +36,7 @@ install_grub() { # set the kernel commandline to use hvc0 mkdir -p mountpoint/etc/default/grub.d cat << EOF > mountpoint/etc/default/grub.d/50-cloudimg-settings.cfg -${CLOUD_IMG_STR} +${IMAGE_STR} # Set the recordfail timeout GRUB_RECORDFAIL_TIMEOUT=0 From 94275558dee8c7f519ecf8e17c6bfd4b1c48ba45 Mon Sep 17 00:00:00 2001 From: Mathieu Trudel-Lapierre Date: Tue, 11 Apr 2017 22:38:18 -0400 Subject: [PATCH 18/19] Make sure variables are exported for run-parts in 999-extras.binary; and drop the unnecessary sourcing of functions. --- live-build/ubuntu-cpc/hooks/999-extras.binary | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/live-build/ubuntu-cpc/hooks/999-extras.binary b/live-build/ubuntu-cpc/hooks/999-extras.binary index c897359b..39c464de 100755 --- a/live-build/ubuntu-cpc/hooks/999-extras.binary +++ b/live-build/ubuntu-cpc/hooks/999-extras.binary @@ -8,12 +8,9 @@ if [ ! -d ${my_dir}/extra ]; then exit 0 fi -IMAGE_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process" -CLOUD_IMG_STR="$IMAGE_STR" -FS_LABEL="cloudimg-rootfs" - -# Export the common functions to the extras -. config/functions +export IMAGE_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process" +export CLOUD_IMG_STR="$IMAGE_STR" +export FS_LABEL="cloudimg-rootfs" # Cleaner execution /bin/run-parts --regex ".*\.binary" "${extra_d}" From 22ec1d6f6fa1aa0b5b5c8758fc86bf3726d3e368 Mon Sep 17 00:00:00 2001 From: Mathieu Trudel-Lapierre Date: Tue, 11 Apr 2017 23:16:48 -0400 Subject: [PATCH 19/19] Sanitize comments. --- live-build/functions | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/live-build/functions b/live-build/functions index 6e4668eb..5abdeea1 100644 --- a/live-build/functions +++ b/live-build/functions @@ -168,9 +168,7 @@ umount_disk_image() { modify_vmdk_header() { # Modify the VMDK headers so that both VirtualBox _and_ VMware can - # read the vmdk and import them. The vodoo here is _not_ documented - # anywhere....so this will have to do. This is undocumented vodoo - # that has been learned by the Cloud Image team. + # read the vmdk and import them. vmdk_name="${1}" descriptor=$(mktemp)