livecd-rootfs/live-build/ubuntu-cpc/hooks/034-disk-image-ppc64el.binary
Steve Langasek 7bff7abdf4 Import patches-unapplied version 2.466 to ubuntu/artful-proposed
Imported using git-ubuntu import.

Changelog parent: 8168b7c92a3ef263d18cc2654b52b47d27b7f339

New changelog entries:
  * ubuntu-server: drop hard-coded test key from the subiquity overlay in
    favor of the generic-classic assertion from the store.
  * move snap assertion handling into the generic build script (and, in
    the process, from the subiquity overlay to the base squashfs).
  * add ubuntu-mate to the set of projects we add snap model assertions to.
  * Factor out grub-related diversions and use them consistently, so we
    don't end up with wrong os-probe output in our grub.cfg.
  * Fix the force-partuuid handling to create the file under
    /etc/default/grub.d/ with a .cfg extension as grub expects; it's unclear
    how this ever worked without.
2017-10-05 06:43:36 +00:00

82 lines
1.8 KiB
Bash
Executable File

#!/bin/bash -eux
case $ARCH in
ppc64el|powerpc)
;;
*)
exit 0
;;
esac
IMAGE_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process"
FS_LABEL="cloudimg-rootfs"
. config/functions
create_partitions() {
disk_image="$1"
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
${IMAGE_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
divert_grub mountpoint
chroot mountpoint update-grub
replace_grub_root_with_label mountpoint
undivert_grub mountpoint
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