tar2fs: Add support of ppc64le vm images

This commit is contained in:
Gleb Fotengauer-Malinovskiy 2019-07-09 13:20:56 +03:00 committed by Michael Shigorin
parent 15845d51e5
commit d4cbbcba76

View File

@ -24,6 +24,7 @@ MB=1048576 # a parted's "megabyte" in bytes is *broken*
SIZE_FACTOR=2 # multiply the sizes found by this value
BOOT_SIZE_FACTOR=2 # multiply /boot size by this value additionally
BOOTLOADERPARTSIZEM=0 # PReP partition size (ppc*)
CUR_BOUNDARY=0 # align first partition at 1MB for performance (+1)
@ -41,6 +42,13 @@ e2k)
BOOTPART="1"
ROOTPART="2"
;;
ppc*)
BOOTFSTYPE="ext4"
BLOCKDEV="/dev/sda"
BOOTLOADERPART="1"
BOOTLOADERPARTSIZEM="8"
ROOTPART="2"
;;
*)
ROOTPART="1"
BLOCKDEV="/dev/sda"
@ -149,12 +157,24 @@ trap exit_handler EXIT ERR
# prepare disk image and a filesystem inside it
rm -f -- "$IMG"
OFFSET="$(($CUR_BOUNDARY + $BOOTSIZEM + $ROOTSIZEM - 1))"
OFFSET="$(($CUR_BOUNDARY + $BOOTLOADERPARTSIZEM + $BOOTSIZEM + $ROOTSIZEM - 1))"
dd if=/dev/zero of="$IMG" conv=notrunc bs=$MB count=1 seek="$OFFSET"
losetup "$LOOPDEV" "$IMG"
parting mklabel msdos
if [ -n "$BOOTLOADERPART" ] && [ -n "$BOOTLOADERPARTSIZEM" ]; then
case "$ARCH" in
ppc*)
parting mkpart primary ext2 2048s ${BOOTLOADERPARTSIZEM}M
CUR_BOUNDARY="$(($CUR_BOUNDARY + $BOOTLOADERPARTSIZEM))"
parting set 1 prep on
parting set 1 boot on
;;
esac
fi
if [ -n "$BOOTPART" ]; then
BOOTDEV="$BLOCKDEV$BOOTPART"
mkpart "$BOOTSIZEM"
@ -173,6 +193,10 @@ if [ -n "$BOOTPART" ]; then
mkfs."$BOOTFSTYPE" "$LOOPBOOT"
fi
if [ -n "$BOOTLOADERPART" ] && [ -n "$BOOTLOADERPARTSIZEM" ]; then
LOOPBOOTLOADER="/dev/mapper/$(basename "$LOOPDEV")p$BOOTLOADERPART"
fi
ROOTUUID="$(blkid -s UUID -o value -c /dev/null "$LOOPROOT")"
if [ -n "$ROOTUUID" ]; then
ROOTDEV="UUID=$ROOTUUID"
@ -299,7 +323,16 @@ grub-efi)
;;
grub)
chroot "$ROOTFS" grub-mkconfig -o /boot/grub/grub.cfg
chroot "$ROOTFS" grub-install --target=i386-pc "$LOOPDEV"
case "$ARCH" in
*86*)
chroot "$ROOTFS" grub-install --target=i386-pc "$LOOPDEV"
;;
ppc*)
[ -z "$LOOPBOOTLOADER" ] ||
chroot "$ROOTFS" grub-install --target=powerpc-ieee1275 \
--no-nvram "$LOOPBOOTLOADER"
;;
esac
;;
esac