build_image: cache DISK_LAYOUT_PATH early

Since get_disk_layout_path gets run in subshells, the computed value of
DISK_LAYOUT_PATH never makes it to the larger env.  Even if it did, we
currently always recompute it.  This can be a little expensive since it
involves walking all our overlays to find the json file.

Instead, let's compute this value once before we start building the image
and have the code use that value if it's been set already.  This should
be backwards compatible.

TEST=`./build_image` produces the same image

Change-Id: I7360995982f35289eda0c029493d435909b587b3
Reviewed-by: Liam McLoughlin <>
Commit-Queue: Mike Frysinger <>
Tested-by: Mike Frysinger <>
2 files changed