setup_board: save/restore package.{mask,keywords} files

If we try to setup multiple boards that use the same toolchain, we end up
deleting the package.{mask,keywords} files for the existing toolchain so
that we can detect if there are upgrades available.  If there aren't, the
files don't get recreated (since we were relying on crossdev for it), and
the installed toolchain packages may no longer be directly reinstalled if
they aren't incidentally marked stable.

Normally this isn't an issue since people build for target boards only
rather than installing toolchains, but this breaks the sdk bot since it
sets up a bunch of bots and then tries to emerge all the toolchain pkgs
directly.  With packages we've pinned that are unstable, portage fails:

	The following keyword changes are necessary to proceed:
	#required by =cross-arm-none-eabi/newlib-1.18.0 (argument)
	>=cross-arm-none-eabi/newlib-1.18.0 **

So backup & restore the files in the update path rather than just blowing
them away.  If we end up installing things anyways, crossdev will do the
right thing.

BUG=None
TEST=`cbuildbot chromiumos-sdk` passes

Change-Id: I6efc71179d6f897af91deaefe1ce6c62df10ebf6
Reviewed-on: https://gerrit.chromium.org/gerrit/16220
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
Mike Frysinger 2012-02-18 22:07:43 -05:00 committed by Gerrit
parent a9043f5a99
commit 551123f7ca

View File

@ -150,7 +150,10 @@ toolchain_needs_update() {
# Unmask any ebuilds previously [un]masked by crossdev. crossdev will # Unmask any ebuilds previously [un]masked by crossdev. crossdev will
# re-setup its masks appropriately the next time we run it. # re-setup its masks appropriately the next time we run it.
sudo rm -f /etc/portage/package.{mask,keywords}/cross-$toolchain local d
for d in package.{mask,keywords} ; do
sudo mv -f /etc/portage/${d}/{,.bak.}cross-${toolchain}
done
pkg_to_flag() { pkg_to_flag() {
[ "${1}" = "glibc" ] && echo "libc" || echo "$1" [ "${1}" = "glibc" ] && echo "libc" || echo "$1"
@ -199,6 +202,14 @@ toolchain_needs_update() {
pkgs+=" cross-$toolchain/gdb" pkgs+=" cross-$toolchain/gdb"
fi fi
ACCEPT_KEYWORDS="~* *" emerge $flags $pkgs | grep cross-$toolchain/ ACCEPT_KEYWORDS="~* *" emerge $flags $pkgs | grep cross-$toolchain/
local ret=$?
# Restore the masks in case we don't end up running crossdev.
for d in package.{mask,keywords} ; do
sudo mv -f /etc/portage/${d}/{.bak.,}cross-${toolchain}
done
return ${ret}
} }
uninstall_toolchain() { uninstall_toolchain() {