build-vm, tar2fs: added VM_PARTTABLE

For Raspberry Pi needed to build grub-efi + MBR images.
This commit is contained in:
Anton Midyukov 2020-04-01 23:25:52 +07:00
parent 32b4711351
commit 0f28ee414f
2 changed files with 19 additions and 8 deletions

View File

@ -68,6 +68,15 @@ ppc*)
;; ;;
esac esac
PARTTABLE="$7"
if [ -z "$PARTTABLE" ]; then
if [ "$BOOTLOADER" == grub-efi ]; then
PARTTABLE=gpt
else
PARTTABLE=msdos
fi
fi
# figure out the part taken by /boot in the given tarball # figure out the part taken by /boot in the given tarball
boot_size() { boot_size() {
if [ -n "$BOOTPART" ]; then if [ -n "$BOOTPART" ]; then
@ -185,11 +194,7 @@ OFFSET="$(($CUR_BOUNDARY + $EFIPARTSIZEM + $BOOTLOADERPARTSIZEM + $BOOTSIZEM + $
dd if=/dev/zero of="$IMG" conv=notrunc bs=$MB count=1 seek="$OFFSET" dd if=/dev/zero of="$IMG" conv=notrunc bs=$MB count=1 seek="$OFFSET"
losetup "$LOOPDEV" "$IMG" losetup "$LOOPDEV" "$IMG"
if [ "$BOOTLOADER" == grub-efi ]; then parting mklabel "$PARTTABLE"
parting mklabel gpt
else
parting mklabel msdos
fi
if [ -n "$BOOTLOADERPART" ] && [ -n "$BOOTLOADERPARTSIZEM" ]; then if [ -n "$BOOTLOADERPART" ] && [ -n "$BOOTLOADERPARTSIZEM" ]; then
case "$ARCH" in case "$ARCH" in
@ -204,10 +209,16 @@ fi
if [ -n "$EFIPART" ]; then if [ -n "$EFIPART" ]; then
EFIDEV="$EFIDEV$EFIPART" EFIDEV="$EFIDEV$EFIPART"
parting mkpart fat32 2048s $(($EFIPARTSIZEM + 1))MiB if [ "$PARTTABLE" == gpt ]; then
parting mkpart fat32 2048s $(($EFIPARTSIZEM + 1))MiB
else
parting mkpart primary fat32 2048s $(($EFIPARTSIZEM + 1))MiB
fi
CUR_BOUNDARY="$EFIPARTSIZEM" CUR_BOUNDARY="$EFIPARTSIZEM"
parting set 1 boot on parting set 1 boot on
parting set 1 esp on if [ "$PARTTABLE" == gpt ]; then
parting set 1 esp on
fi
fi fi
if [ -n "$BOOTPART" ]; then if [ -n "$BOOTPART" ]; then

View File

@ -45,7 +45,7 @@ tar2fs: check-sudo prepare-tarball-qemu
fi; \ fi; \
if ! sudo $$TOPDIR/bin/tar2fs \ if ! sudo $$TOPDIR/bin/tar2fs \
"$(VM_TARBALL)" "$(VM_RAWDISK)" "$(VM_SIZE)" "$(VM_FSTYPE)" \ "$(VM_TARBALL)" "$(VM_RAWDISK)" "$(VM_SIZE)" "$(VM_FSTYPE)" \
"$(VM_BOOTLOADER)" "$(ARCH)"; then \ "$(VM_BOOTLOADER)" "$(ARCH)" "$(VM_PARTTABLE)"; then \
echo "** error: sudo tar2fs failed, see build log" >&2; \ echo "** error: sudo tar2fs failed, see build log" >&2; \
exit 1; \ exit 1; \
fi fi