mirror of
https://git.launchpad.net/livecd-rootfs
synced 2026-03-18 05:27:45 +00:00
- Adding parition ordering using imagecraft - Removing redundant locales install - Better logging for empty ARCH and SUBPROJECT - Using mktemp for mountpoint
82 lines
2.0 KiB
Bash
82 lines
2.0 KiB
Bash
#!/bin/bash -eux
|
|
|
|
. config/functions
|
|
|
|
ARCH="${ARCH:-}"
|
|
SUBPROJECT="${SUBPROJECT:-}"
|
|
|
|
# We want to start off imagecraft builds with just amd64 support right now
|
|
case $ARCH in
|
|
amd64)
|
|
;;
|
|
*)
|
|
echo "imagecraft build is currently not implemented for ARCH=${ARCH:-unset}."
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
case ${SUBPROJECT} in
|
|
minimized)
|
|
;;
|
|
*)
|
|
echo "imagecraft build is currently not implemented for SUBPROJECT=${SUBPROJECT:-unset}."
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
_src_d=$(dirname $(readlink -f ${0}))
|
|
|
|
snap install imagecraft --classic --channel latest/edge
|
|
|
|
cp -r "$_src_d"/imagecraft-configs/* .
|
|
|
|
CRAFT_BUILD_ENVIRONMENT=host imagecraft --verbosity debug pack
|
|
|
|
# We are using this function instead of mount_disk_image from functions
|
|
# because imagecraft doesn't currently support XBOOTLDR's GUID and
|
|
# mount_disk_image has an explicit check for the XBOOTLDR GUID
|
|
# TODO: Use mount_disk_image once imagecraft supports XBOOTLDR's GUID
|
|
mount_image_partitions() {
|
|
mount_image "${disk_image}" "$ROOT_PARTITION"
|
|
|
|
# Making sure that the loop device is ready
|
|
partprobe "${loop_device}"
|
|
udevadm settle
|
|
mount_partition "${rootfs_dev_mapper}" "$mountpoint"
|
|
mount "${loop_device}p13" "$mountpoint/boot"
|
|
mount "${loop_device}p15" "$mountpoint/boot/efi"
|
|
}
|
|
|
|
install_grub_on_image() {
|
|
divert_grub "$mountpoint"
|
|
chroot "$mountpoint" grub-install --target=i386-pc "${loop_device}"
|
|
chroot "$mountpoint" update-grub
|
|
undivert_grub "$mountpoint"
|
|
|
|
echo "GRUB for BIOS boot installed successfully."
|
|
}
|
|
|
|
unmount_image_partitions() {
|
|
umount "$mountpoint/boot/efi"
|
|
umount "$mountpoint/boot"
|
|
|
|
umount_partition "$mountpoint"
|
|
rmdir "$mountpoint"
|
|
}
|
|
|
|
disk_image="pc.img"
|
|
ROOT_PARTITION=1
|
|
mountpoint=$(mktemp -d)
|
|
|
|
mount_image_partitions
|
|
|
|
install_grub_on_image
|
|
create_manifest "$mountpoint/" "$PWD/livecd.ubuntu-cpc.imagecraft.manifest" "$PWD/livecd.ubuntu-cpc.imagecraft.spdx" "cloud-image-$ARCH-$(date +%Y%m%dT%H:%M:%S)" "false"
|
|
|
|
unmount_image_partitions
|
|
|
|
clean_loops
|
|
trap - EXIT
|
|
|
|
qemu-img convert -f raw -O qcow2 "${disk_image}" livecd.ubuntu-cpc.imagecraft.img
|