Robert C Jennings 14b7f62b17
ubuntu-cpc: Only produce explicitly named artifacts (LP: #1837254)
In parallel builds where a list of image targets are provided the build
may produce binaries that are not part of the named set of targets but
are created by series dependencies.  These implicitly created binaries
may be generated by multiple builds but are unused as our convention for
the ubuntu-cpc project is to only consume binaries from the explicitly
named image targets; this avoid overwriting the same object by multiple
parallel builds.

This patch adds support for a 'provides' keyword for series files. It can
be specified multiple times per series file.  The field is used by the
make-hooks script to generate a list of output files created explicitly by
the named image targets.  The list is saved to the "explicit_provides"
file in the hooks output directory. In the case of the "all" target
this list would be empty.  This list is consumed by the "final.binary"
hook file.

This patch adds support for optional final.binary hooks in hooks.d/base
and/or hooks.d/extra.  These final.binary hooks are always included as
the last hook(s) if either exist with the hook in "extra" running last.

The base/final.binary hook includes logic to parse the "explicit_provides"
file generated by the make-hooks script and remove any binary output not
explicitly specified.

Some series files named unnecessary dependencies, specifically
disk-image, to keep output of implicit artifacts consistent between
parallel builds.  These unnecessary dependencies are removed in this
patch.
2019-07-22 11:29:04 -05:00

73 lines
1.8 KiB
Bash
Executable File

#!/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