cros_update_firmware: clean edb cache before emerge firmware for the board

BUG=b:122467913
TEST=run cros_update_firmware for flapjack board after modifying its firmware config

Change-Id: I9ef0bbafe3abb6ac5555f9382e9dc381256b24e1
Reviewed-on: https://chromium-review.googlesource.com/1448960
Commit-Ready: Ned Nguyen <nednguyen@google.com>
Tested-by: Ned Nguyen <nednguyen@google.com>
Reviewed-by: Ned Nguyen <nednguyen@google.com>
(cherry picked from commit fc67e1f1e5ff6d9af17d726665e210a33e2baac9)
Reviewed-on: https://chromium-review.googlesource.com/c/1480750
Commit-Queue: Chris Zhou <chris_zhou@compal.corp-partner.google.com>
Tested-by: Chris Zhou <chris_zhou@compal.corp-partner.google.com>
Reviewed-by: YH Lin <yueherngl@chromium.org>
diff --git a/contrib/cros_update_firmware b/contrib/cros_update_firmware
index efc6048..31376a7 100755
--- a/contrib/cros_update_firmware
+++ b/contrib/cros_update_firmware
@@ -86,6 +86,7 @@
 
   overlay="${GCLIENT_ROOT}/src/private-overlays/overlay-${board}-private"
   metadata="${overlay}/metadata"
+  edb_cache="/var/cache/edb/dep/mnt/host/source/src/private-overlays/overlay-${board}-private"
   base="${overlay}/chromeos-base"
   ebuild="${base}/chromeos-firmware-${board}/chromeos-firmware-${board}-9999.ebuild"
   srcuris="${base}/chromeos-firmware-${board}/files/srcuris"
@@ -94,12 +95,14 @@
   "emerge-${board}" ${cfg_bsp_baseboard_pkg} "${cfg_bsp_pkg}" chromeos-config
   cros_config_host -c "${yaml_config}" get-firmware-uris > "${srcuris}"
   touch "${ebuild}"
-  # clean metadata cache to make sure SRC_URI is fetched from ${srcuris}
-  # instead from portage cache which maybe out of sync
+  # Clean metadata cache to make sure SRC_URI is fetched from ${srcuris}
+  # instead from portage cache which maybe out of sync.
   # Note: this workaround is needed because we break the SRC_URI API contract
   # which is supposed to be a static (see
-  # https://devmanual.gentoo.org/general-concepts/portage-cache/index.html)
-  rm -rf "${metadata}/cache" "${metadata}/md5-cache"
+  # https://devmanual.gentoo.org/general-concepts/portage-cache/index.html).
+  # TODO(crbug.com/927917): find a different way to generate SRC_URI and remove
+  # these cache cleanup code.
+  rm -rf "${metadata}/cache" "${metadata}/md5-cache" "${edb_cache}"
   "ebuild-${board}" "${ebuild}" manifest
   "emerge-${board}" "chromeos-firmware-${board}"