update_chroot: clean out old binpkgs

Once we've finished updating, clear out all the old binpkgs.  We do this
for boards already in build_image, but we kind of forgot about the sdk.

BUG=None
TEST=`./update_chroot` finished with nuking lots of stale binpkgs

Change-Id: Ic7e4bd728e940248f2dae4dc7490406f6112947a
Reviewed-on: https://chromium-review.googlesource.com/728182
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/update_chroot b/update_chroot
index 9bbc287..77d5e4c 100755
--- a/update_chroot
+++ b/update_chroot
@@ -32,6 +32,8 @@
   "Don't update the toolchains."
 DEFINE_string toolchain_boards "" \
   "Extra toolchains to setup for the specified boards."
+DEFINE_boolean eclean ${FLAGS_TRUE} \
+  "Run eclean to delete old binpkgs after updating the chroot."
 
 # Parse command line flags
 FLAGS "$@" || exit 1
@@ -126,4 +128,10 @@
 # If the user still has old perl modules installed, update them.
 "${SCRIPTS_DIR}/build_library/perl_rebuild.sh"
 
+# Finally clean out any stale binpkgs we've accumulated.
+if [[ ${FLAGS_eclean} -eq ${FLAGS_TRUE} ]]; then
+  info "Running 'eclean -d packages' to clean up stale binpkgs"
+  sudo eclean -d packages
+fi
+
 command_completed