Pat Viafore 5d425edb86
Various fixes from code review.
Cleaning indices; removing superfluous apt-get update; adding debug
messages; adding better output name
2019-06-04 15:31:46 -05:00

64 lines
1.4 KiB
Bash

#!/bin/bash -eux
# vi: ts=4 expandtab
#
# Generate KVM image
#
echo "Building KVM image"
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
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
convert_to_qcow2 binary/boot/disk-kvm.ext4 livecd.ubuntu-cpc.disk-kvm.img