livecd-rootfs/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary
Steve Langasek 4109c1c2b3 Import patches-unapplied version 2.419 to ubuntu/yakkety-proposed
Imported using git-ubuntu import.

Changelog parent: eb0cb09a8d5c77853e7f9cba2b79270e12dc6a59

New changelog entries:
  [ Daniel Watkins ]
  * Consolidate cloud images
    - Remove .tar.gz and .tar.xz (removed in favour of the squashfs).
    - Remove the MBR-only disk image in favour of the shared GPT/MBR UEFI
      image.
    - Remove '-disk1' from bootable image names.
  [ Phil Roche ]
  * Removed HWCLOCKACCESS=no from /etc/default/rcS (LP: #1581044)
2016-06-28 23:54:13 +00:00

80 lines
1.9 KiB
Bash
Executable File

#!/bin/bash -eux
case $ARCH in
ppc64el|powerpc)
;;
*)
exit 0
;;
esac
. /build/config/functions
create_partitions() {
disk_image="$1"
apt-get install -qqy gdisk
sgdisk "${disk_image}" \
--zap-all
sgdisk "${disk_image}" \
--new=2::+8M \
--new=1:
sgdisk "${disk_image}" -t 2:4100
sgdisk "${disk_image}" \
--print
}
install_grub() {
mkdir mountpoint
mount_partition "${rootfs_dev_mapper}" mountpoint
chroot mountpoint apt-get -qqy update
chroot mountpoint apt-get -qqy install grub2
chroot mountpoint apt-get -qqy remove --purge grub-legacy-ec2
# 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}
# Set the recordfail timeout
GRUB_RECORDFAIL_TIMEOUT=0
# Do not wait on grub prompt
GRUB_TIMEOUT=0
# Set the default commandline
GRUB_CMDLINE_LINUX_DEFAULT="console=hvc0 earlyprintk"
EOF
prep_partition="/dev/mapper${loop_device///dev/}p2"
chroot mountpoint grub-install "${prep_partition}" \
--no-nvram \
--boot-directory=/boot \
--target=powerpc-ieee1275
chroot mountpoint dpkg-divert --local --rename /etc/grub.d/30_os-prober
chroot mountpoint update-grub
sed -i "s,root=.* ,root=LABEL=cloudimg-rootfs ,g" mountpoint/boot/grub/grub.cfg
chroot mountpoint dpkg-divert --remove --local --rename /etc/grub.d/30_os-prober
umount_partition mountpoint
rmdir mountpoint
}
disk_image=binary/boot/disk.ext4
create_empty_disk_image "${disk_image}"
create_partitions "${disk_image}"
mount_image "${disk_image}" 1
# Copy the chroot in to the disk
make_ext4_partition "${rootfs_dev_mapper}"
mkdir mountpoint
mount "${rootfs_dev_mapper}" mountpoint
cp -a chroot/* mountpoint/
umount mountpoint
rmdir mountpoint
install_grub
clean_loops
trap - EXIT