You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
1.8 KiB
84 lines
1.8 KiB
9 years ago
|
#!/bin/bash -eux
|
||
9 years ago
|
case $ARCH in
|
||
|
ppc64el|powerpc)
|
||
|
;;
|
||
|
*)
|
||
|
exit 0
|
||
|
;;
|
||
|
esac
|
||
9 years ago
|
|
||
8 years ago
|
IMAGE_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process"
|
||
|
FS_LABEL="cloudimg-rootfs"
|
||
|
|
||
7 years ago
|
. config/binary
|
||
|
|
||
8 years ago
|
. config/functions
|
||
9 years ago
|
|
||
|
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
|
||
|
|
||
9 years ago
|
chroot mountpoint apt-get -qqy update
|
||
7 years ago
|
chroot mountpoint apt-get -qqy install grub-ieee1275
|
||
9 years ago
|
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
|
||
8 years ago
|
${IMAGE_STR}
|
||
9 years ago
|
|
||
|
# Set the recordfail timeout
|
||
|
GRUB_RECORDFAIL_TIMEOUT=0
|
||
|
|
||
|
# Do not wait on grub prompt
|
||
|
GRUB_TIMEOUT=0
|
||
|
|
||
9 years ago
|
# Set the default commandline
|
||
9 years ago
|
GRUB_CMDLINE_LINUX_DEFAULT="console=hvc0 earlyprintk"
|
||
9 years ago
|
EOF
|
||
|
prep_partition="/dev/mapper${loop_device///dev/}p2"
|
||
|
chroot mountpoint grub-install "${prep_partition}" \
|
||
|
--no-nvram \
|
||
|
--boot-directory=/boot \
|
||
|
--target=powerpc-ieee1275
|
||
|
|
||
7 years ago
|
divert_grub mountpoint
|
||
9 years ago
|
chroot mountpoint update-grub
|
||
8 years ago
|
replace_grub_root_with_label mountpoint
|
||
7 years ago
|
undivert_grub mountpoint
|
||
9 years ago
|
|
||
9 years ago
|
umount_partition mountpoint
|
||
|
rmdir mountpoint
|
||
|
}
|
||
|
|
||
|
disk_image=binary/boot/disk.ext4
|
||
|
|
||
|
create_empty_disk_image "${disk_image}"
|
||
|
create_partitions "${disk_image}"
|
||
9 years ago
|
mount_image "${disk_image}" 1
|
||
9 years ago
|
|
||
|
# 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
|