Use --usepkgonly in build_image to ensure no accidental builds of packages.
Use --usepkgonly in build_image to ensure no accidental builds of packages.

Historically, we used --usepkgonly in build_image to ensure that packages
were not accidentally built during this step. Recently, build_image was
updated to use --usepkg. The benefit of using --usepkg was that it would not
install obsolete binary packages to your image. It was counter-intuitive that
--usepkgonly would install packages to your image that are not actually
installed to your board root. The disadvantage, however, of --usepkg, was that
it sometimes tried to build packages afresh using the image as your build root,
and this failed with strange errors because you're not supposed to do that.

This change fixes build_image to give useful errors by switching back to
--usepkgonly. To fix the problem where --usepkgonly installs packages that are
not installed, we first run eclean-<board> to clean all unused packages from
the board root.

This change is a big improvement because a number of people have run into
strange issues with build_image due to this problem and have had trouble
debugging them.

This change was actually written by Sean Paul, and I am shepherding his change
through for him because he doesn't have a Chromium account yet.

BUG=chromium-os:6437
TEST=
 1) build_packages && build_image should still work
 2) build_packages && ./cros_workon start power_manager && build_image should
    fail with an error that all versions of the power manager are masked. This
    happens because you started working on the power manager, but did not build
    the version of the power manager you were working on before installing it.
 3) Assuming you are working on the power manager, build_packages && build_image
    should succeed because your cros_workon'd version of the package is built.
 4) ( ./cros_workon start power_manager && build_packages &&
      ./cros_workon stop power_manager && build_image ) should fail with the
    same error message as case 2 for similar reasons.
 5) ( ./cros_workon start power_manager && build_packages &&
      ./cros_workon stop power_manager && build_packages && build_image )
    should work because you've built your new version of the stable package.

Change-Id: Ia3858c70997bc6f0ec0b6d1bfaede8d3272a0976

Review URL: http://codereview.chromium.org/3305010

crawford/scripts,nicescale/scripts,mischief/scripts,endocode/scripts,endocode/scripts,nicescale/scripts,bcwaldon/coreos-scripts,endocode/scripts,andrejro/coreos--scripts,sigma/coreos-scripts,BugRoger/scripts,fivethreeo/scripts,zhang0137/scripts,bcwaldon/coreos-scripts,coreos/scripts,bcwaldon/coreos-scripts,mjg59/scripts,vmware/coreos-scripts,vmware/coreos-scripts,fivethreeo/scripts,zhang0137/scripts,sigma/coreos-scripts,trnubo/scripts,crawford/scripts,sigma/coreos-scripts,marineam/coreos-scripts,BugRoger/scripts,marineam/coreos-scripts,trnubo/scripts,zhang0137/scripts,smilart/scripts,gtank/scripts,mischief/scripts,andrejro/coreos--scripts,mjg59/scripts,mjg59/scripts,mischief/scripts,gtank/scripts,coreos/scripts,vmware/coreos-scripts,gtank/scripts,andrejro/coreos--scripts,glevand/coreos--scripts,smilart/scripts,glevand/coreos--scripts,crawford/scripts,fivethreeo/scripts,BugRoger/scripts,nicescale/scripts,trnubo/scripts,smilart/scripts,marineam/coreos-scripts