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.

BUG=chromium:236941
TEST=`./build_image` produces the same image

Change-Id: I7360995982f35289eda0c029493d435909b587b3
Reviewed-on: https://gerrit.chromium.org/gerrit/59826
Reviewed-by: Liam McLoughlin <lmcloughlin@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
2 files changed