toolchain: rm build caches in linting endpoints
This CL implements removing the portage temp files from previous calls to
emerge for packages being linted. This is helpful behavior for
because linting artifiacts are not produced if emerge skips the package
due to there being no changes since the last build. This doesn't matter
on builders, but makes it easier to use the endpoint locally.
BUG=b:229143726, b:187790543
TEST=tested with call_scripts
Change-Id: Ib7a3b4c7481f968a3e9dec708fe2c7b762ddda41
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/3586244
Reviewed-by: Alex Klein <saklein@chromium.org>
Commit-Queue: Ryan Beltran <ryanbeltran@chromium.org>
Tested-by: Ryan Beltran <ryanbeltran@chromium.org>
diff --git a/api/controller/toolchain.py b/api/controller/toolchain.py
index 57ae7eb..57fdc3a 100644
--- a/api/controller/toolchain.py
+++ b/api/controller/toolchain.py
@@ -335,6 +335,12 @@
osutils.RmDir(TIDY_BASE_DIR, ignore_missing=True, sudo=True)
osutils.SafeMakedirs(TIDY_BASE_DIR, 0o777, sudo=True)
+ # rm any existing temporary portage files from builds of affected packages:
+ # this is required to make sure lints are always regenerated
+ for package in packages:
+ cache_files_dir = f'{input_proto.sysroot.path}/var/cache/portage/{package}'
+ osutils.RmDir(cache_files_dir, ignore_missing=True)
+
emerge_cmd = chroot_util.GetEmergeCommand(input_proto.sysroot.path)
cros_build_lib.sudo_run(
emerge_cmd + packages,