Merge patviafore/linux_kvm_image: Add linux-kvm image

We are creating a derivative of disk-image, replacing the kernel with
linux-kvm, removing initramfs, and creating a qcow2 image.

Source: ~patviafore/livecd-rootfs/+git/livecd-rootfs:linux_kvm_image

Modifications: fixed conflict in debian/changelog entry and bumped
version.

Signed-off-by: Tiago Stürmer Daitx <tdaitx@gmail.com>
sil2100/enable-universe-none
Tiago Stürmer Daitx 6 years ago
commit f2bbe1fd85
No known key found for this signature in database
GPG Key ID: 9C3244263BD41DE0

6
debian/changelog vendored

@ -1,3 +1,9 @@
livecd-rootfs (2.594) UNRELEASED; urgency=medium
* Add support for linux-kvm images
-- Patrick Viafore <patrick.viafore@ubuntu.com> Tue, 04 Jun 2019 02:13:00 -0500
livecd-rootfs (2.593) eoan; urgency=medium livecd-rootfs (2.593) eoan; urgency=medium
* Use boot-partition for cloud-init seed on RPi * Use boot-partition for cloud-init seed on RPi

@ -877,3 +877,19 @@ is_live_layer () {
done done
return 1 return 1
} }
replace_kernel () {
mountpoint=$1
new_kernel=$2
# Install custom kernel (N.B. the trailing + retains linux-base during this
# operation)
env DEBIAN_FRONTEND=noninteractive chroot "${mountpoint}" apt-get \
remove --purge --assume-yes '^linux-.*' 'linux-base+'
env DEBIAN_FRONTEND=noninteractive chroot "${mountpoint}" apt-get \
update --assume-yes
env DEBIAN_FRONTEND=noninteractive chroot "${mountpoint}" apt-get \
install --assume-yes "${new_kernel}"
env DEBIAN_FRONTEND=noninteractive chroot "${mountpoint}" apt-get \
autoremove --purge --assume-yes
}

@ -0,0 +1,73 @@
#!/bin/bash -eux
# vi: ts=4 expandtab
#
# Generate KVM image
#
echo "Building KVM image"
IMAGE_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process"
case ${SUBPROJECT:-} in
minimized)
echo "Skipping minimized $0 builds"
exit 0
;;
*)
;;
esac
# Only allow amd64 builds for now
case $ARCH in
amd64)
;;
*)
echo "Linux KVM images are not supported for $ARCH yet.";
exit 0;;
esac
. config/functions
mount_d=$(mktemp -d)
create_derivative "disk" "kvm" #sets ${derivative_img}
mount_disk_image ${derivative_img} ${mount_d}
# unmount disk image and remove created folders on exit
# even though we unmount manually before we convert to
# qcow2, we have this here just in case we error out before
# that step
cleanup_kvm() {
if [ -d "$mount_d" ]; then
umount_disk_image "$mount_d"
fi
rm -rf ${mount_d} ${derivative_img}
}
trap cleanup_kvm EXIT
divert_grub "${mount_d}"
replace_kernel ${mount_d} "linux-kvm"
undivert_grub "${mount_d}"
#setup grub correctly
env DEBIAN_FRONTEND=noninteractive chroot "${mount_d}" update-grub
replace_grub_root_with_label "${mount_d}"
# Remove initramfs for kvm image
env DEBIAN_FRONTEND=noninteractive chroot "${mount_d}" apt-get \
purge -y initramfs-tools busybox-initramfs
env DEBIAN_FRONTEND=noninteractive chroot "${mount_d}" rm \
-rf /boot/initrd.img-* /boot/initrd.img
# Remove indices
env DEBIAN_FRONTEND=noninteractive chroot "${mount_d}" apt-get \
clean
create_manifest ${mount_d} livecd.ubuntu-cpc.disk-kvm.manifest
# unmount disk image to prevent corruption
# and remove it so the trap doesn't try to unmount it again
umount_disk_image ${mount_d}
rm -rf ${mount_d}
convert_to_qcow2 ${derivative_img} livecd.ubuntu-cpc.disk-kvm.img

@ -2,6 +2,7 @@ depends root-dir
depends tarball depends tarball
depends squashfs depends squashfs
depends disk-image depends disk-image
depends kvm
depends qcow2 depends qcow2
depends vmdk depends vmdk
depends vagrant depends vagrant

@ -0,0 +1,2 @@
depends disk-image
base/kvm-image.binary
Loading…
Cancel
Save