2015-11-06 09:54:59 +00:00
|
|
|
#!/bin/bash -eux
|
2016-04-07 14:34:12 +01:00
|
|
|
case $ARCH in
|
|
|
|
ppc64el|powerpc)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
2015-11-06 09:54:59 +00:00
|
|
|
|
2017-04-07 17:14:56 -04:00
|
|
|
IMAGE_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process"
|
|
|
|
FS_LABEL="cloudimg-rootfs"
|
|
|
|
|
2017-11-23 20:27:16 +01:00
|
|
|
. config/binary
|
|
|
|
|
2017-04-11 17:16:35 -04:00
|
|
|
. config/functions
|
2015-11-06 09:54:59 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2016-06-09 15:48:38 +01:00
|
|
|
chroot mountpoint apt-get -qqy update
|
2017-12-01 13:44:32 +13:00
|
|
|
chroot mountpoint apt-get -qqy install grub-ieee1275
|
2015-11-06 09:54:59 +00:00
|
|
|
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
|
2017-04-11 21:10:56 -05:00
|
|
|
${IMAGE_STR}
|
2016-01-28 09:34:52 +00:00
|
|
|
|
|
|
|
# Set the recordfail timeout
|
|
|
|
GRUB_RECORDFAIL_TIMEOUT=0
|
|
|
|
|
|
|
|
# Do not wait on grub prompt
|
|
|
|
GRUB_TIMEOUT=0
|
|
|
|
|
2015-11-06 09:54:59 +00:00
|
|
|
# Set the default commandline
|
2016-04-14 11:06:33 -07:00
|
|
|
GRUB_CMDLINE_LINUX_DEFAULT="console=hvc0 earlyprintk"
|
2015-11-06 09:54:59 +00:00
|
|
|
EOF
|
|
|
|
prep_partition="/dev/mapper${loop_device///dev/}p2"
|
|
|
|
chroot mountpoint grub-install "${prep_partition}" \
|
|
|
|
--no-nvram \
|
|
|
|
--boot-directory=/boot \
|
|
|
|
--target=powerpc-ieee1275
|
|
|
|
|
2017-10-04 22:33:41 -07:00
|
|
|
divert_grub mountpoint
|
2016-01-27 15:49:05 +00:00
|
|
|
chroot mountpoint update-grub
|
2016-09-02 12:54:19 +01:00
|
|
|
replace_grub_root_with_label mountpoint
|
2017-10-04 22:33:41 -07:00
|
|
|
undivert_grub mountpoint
|
2016-01-27 15:49:05 +00:00
|
|
|
|
2015-11-06 09:54:59 +00:00
|
|
|
umount_partition mountpoint
|
|
|
|
rmdir mountpoint
|
|
|
|
}
|
|
|
|
|
|
|
|
disk_image=binary/boot/disk.ext4
|
|
|
|
|
|
|
|
create_empty_disk_image "${disk_image}"
|
|
|
|
create_partitions "${disk_image}"
|
2016-02-06 00:34:16 -08:00
|
|
|
mount_image "${disk_image}" 1
|
2015-11-06 09:54:59 +00:00
|
|
|
|
|
|
|
# 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
|