further refactoring of partition handling

ubuntu/yakkety
Steve Langasek 9 years ago
parent 6fce3b879d
commit 24b9feb58a

@ -9,24 +9,41 @@ case $ARCH in
;; ;;
*) *)
ROOTPART=1 ROOTPART=1
ROOTPART_START=1
;; ;;
esac esac
create_empty_partition() { create_empty_partition_table() {
apt-get install -qqy parted apt-get install -qqy parted
parted_prefix="parted $1 --script --"
${parted_prefix} mklabel msdos parted "$1" --script -- mklabel msdos
${parted_prefix} mkpart primary 1 -1 }
${parted_prefix} set 1 B
create_empty_partition() {
local disk="$1"
local part="$2"
local start="$3"
local end="$4"
local bootable="$5"
parted_prefix="parted $disk --script --"
${parted_prefix} mkpart primary "$start" "$end"
if [ -n "$bootable" ]; then
${parted_prefix} set "$part" B
fi
${parted_prefix} print ${parted_prefix} print
${parted_prefix} align-check opt "$2" ${parted_prefix} align-check opt "$part"
} }
disk_image=binary/boot/disk.ext4 disk_image=binary/boot/disk.ext4
create_empty_disk_image "${disk_image}" create_empty_disk_image "${disk_image}"
create_empty_partition "${disk_image}" "$ROOTPART" create_empty_partition_table "${disk_image}"
if [ -n "$BOOTPART_START" ]; then
create_empty_partition "$disk_image" 1 "$BOOTPART_START" "$BOOTPART_END" 1
fi
create_empty_partition "${disk_image}" "$ROOTPART" "$ROOTPART_START" -1
mount_image "${disk_image}" "$ROOTPART" mount_image "${disk_image}" "$ROOTPART"
# Copy the chroot in to the disk # Copy the chroot in to the disk
@ -34,8 +51,6 @@ make_ext4_partition "${rootfs_dev_mapper}"
mkdir mountpoint mkdir mountpoint
mount "${rootfs_dev_mapper}" mountpoint mount "${rootfs_dev_mapper}" mountpoint
cp -a chroot/* mountpoint/ cp -a chroot/* mountpoint/
umount mountpoint
rmdir mountpoint
case $ARCH in case $ARCH in
amd64|i386) should_install_grub=1;; amd64|i386) should_install_grub=1;;
@ -43,9 +58,6 @@ case $ARCH in
esac esac
if [ "${should_install_grub}" -eq 1 ]; then if [ "${should_install_grub}" -eq 1 ]; then
mkdir mountpoint
mount_partition "${rootfs_dev_mapper}" mountpoint
echo "(hd0) ${loop_device}" > mountpoint/tmp/device.map echo "(hd0) ${loop_device}" > mountpoint/tmp/device.map
chroot mountpoint grub-install ${loop_device} chroot mountpoint grub-install ${loop_device}
chroot mountpoint grub-bios-setup \ chroot mountpoint grub-bios-setup \
@ -56,14 +68,10 @@ if [ "${should_install_grub}" -eq 1 ]; then
${loop_device} ${loop_device}
rm mountpoint/tmp/device.map rm mountpoint/tmp/device.map
umount_partition mountpoint
rmdir mountpoint
fi fi
if [ "$ARCH" = "s390x" ]; then if [ "$ARCH" = "s390x" ]; then
# Do ZIPL install bits # Do ZIPL install bits
mkdir mountpoint
mount_partition "${rootfs_dev_mapper}" mountpoint
# Write out cloudy zipl.conf for future kernel updates # Write out cloudy zipl.conf for future kernel updates
cat << EOF > mountpoint/etc/zipl.conf cat << EOF > mountpoint/etc/zipl.conf
@ -89,9 +97,10 @@ EOF
--targetblocksize=512 \ --targetblocksize=512 \
--targetoffset=2048 --targetoffset=2048
fi
umount_partition mountpoint umount_partition mountpoint
rmdir mountpoint rmdir mountpoint
fi
clean_loops clean_loops
trap - EXIT trap - EXIT

Loading…
Cancel
Save