diff options
author | George Burgess IV <gbiv@google.com> | 2021-02-04 10:44:02 -0800 |
---|---|---|
committer | George Burgess <gbiv@chromium.org> | 2021-02-04 20:14:18 +0000 |
commit | 1ac4f769d564e21d821927e50d8cbbadd5c40def (patch) | |
tree | 33144001382f5b0104b2b5a6bbc04871d4808f22 /compiler_wrapper | |
parent | d4d6eb933c4c6c3699120ed131ccc38ec6a3b2fd (diff) | |
download | toolchain-utils-1ac4f769d564e21d821927e50d8cbbadd5c40def.tar.gz |
compiler_wrapper: add a script to restore us to a working wrapper
Sometimes, I'm guilty of using ./install_compiler_wrapper.sh on broken
sources. Restoring the world to a working state requires
knowing/remembering a command. Seems better to provide that knowledge in
executable form.
BUG=None
TEST=Ran the script
Change-Id: I772b19a0b8bebdf6af78b822b710ce6e880c7388
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2676601
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Tested-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'compiler_wrapper')
-rwxr-xr-x | compiler_wrapper/reset_compiler_wrapper.sh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/compiler_wrapper/reset_compiler_wrapper.sh b/compiler_wrapper/reset_compiler_wrapper.sh new file mode 100755 index 00000000..523e972d --- /dev/null +++ b/compiler_wrapper/reset_compiler_wrapper.sh @@ -0,0 +1,42 @@ +#!/bin/bash -eux +# +# Copyright 2021 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# If your compiler wrapper ends up broken, you can run this script to try to +# restore it to a working version. We can only use artifacts we download from +# gs://, since it's kind of hard to build a working compiler with a broken +# compiler wrapper. ;) + +if [[ ! -e "/etc/cros_chroot_version" ]]; then + echo "Run me inside of the chroot." + exit 1 +fi + +packages_to_reemerge=( + # We want to reemerge the host wrapper... + sys-devel/llvm +) + +gcc_wrappers=( + cross-x86_64-cros-linux-gnu/gcc + cross-armv7a-cros-linux-gnueabihf/gcc + cross-aarch64-cros-linux-gnu/gcc +) + +# ...and any existing target wrappers. +for gcc in "${gcc_wrappers[@]}"; do + # cheap check for whether or not the package in question is already installed + if ls /var/db/pkg/"${gcc}"-* >& /dev/null; then + packages_to_reemerge+=( "${gcc}" ) + fi +done + +# Ensure that we don't pick up any broken binpkgs for these when we install +# them below. +for pkg in "${packages_to_reemerge[@]}"; do + sudo rm -f "/var/lib/portage/pkgs/${pkg}"* +done + +sudo emerge -j16 -G "${packages_to_reemerge[@]}" |