Load partition numbers from the GPT

The recent break (
was caused because the failing parrot test
copies a test qemu image out of the build area without also including
the partition script.

The script tries to use --from to load the partition
script. When this fails (because it was not copied with the image), it
tries to use --rootfs_mountpt -- which also fails, because the rootfs
isn't actually mounted. This means all of the PARTITION_NUM_* variables
are not defined, which causes the parrot test error.

In general we handled this in the past by using cgpt_py to get the
partition number from the disk_layout.json, but it looks like we can
just read using ${GPT} directly. This avoids needing to supply the image
type needed to satisfy cgpt_py, since we're using the GPT directly.

TEST=Build parrot qemu test image, verify against an
image, and verify the commands succeed:

  ./build_packages --board=$b
  ./build_image --board=$b test
  ./ --board=$b --from=../build/images/$b/latest --test_image
  T=$(mktemp -d);mkdir -p $T/{s,m}
  cp ../build/images/$b/latest/chromiumos_qemu_image.bin $T
  ./ --from=$T --image=chromiumos_qemu_image.bin \
      --rootfs_mountpt=$T/m --stateful_mountpt=$T/s --safe
  ./ --from=$T --image=chromiumos_qemu_image.bin \
      --rootfs_mountpt=$T/m --stateful_mountpt=$T/s --safe -u

Change-Id: I90f444c1dd2077474a122d3fc93ca57282f94be5
Commit-Ready: Ian Coolidge <>
Tested-by: Ian Coolidge <>
Reviewed-by: Joshua Emele <>
Reviewed-by: Mike Frysinger <>
2 files changed