services: chroot tempdir cleanup
Switch some trailing manual chroot tmp dir tempdir creations
to use the Chroot.tempdir method instead.
BUG=None
TEST=run_tests
Change-Id: Id63d4f93e0d2dc6002f1c074815a95f8da552236
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1834108
Tested-by: Alex Klein <saklein@chromium.org>
Auto-Submit: Alex Klein <saklein@chromium.org>
Reviewed-by: Michael Mortensen <mmortensen@google.com>
Commit-Queue: Michael Mortensen <mmortensen@google.com>
diff --git a/service/artifacts.py b/service/artifacts.py
index d510df8..0a53717 100644
--- a/service/artifacts.py
+++ b/service/artifacts.py
@@ -354,8 +354,7 @@
chroot_args = chroot.get_enter_args()
extra_env = {'USE': 'chrome_internal'}
- base_dir = os.path.join(chroot.path, 'tmp')
- with osutils.TempDir(base_dir=base_dir) as tempdir:
+ with chroot.tempdir() as tempdir:
in_chroot_path = os.path.relpath(tempdir, chroot.path)
cmd = ['cros_generate_sysroot', '--out-dir', in_chroot_path, '--board',
build_target.name, '--deps-only', '--package', constants.CHROME_CP]
diff --git a/service/test.py b/service/test.py
index 8f10c2e..6cb831a 100644
--- a/service/test.py
+++ b/service/test.py
@@ -68,8 +68,7 @@
# Set up the failed package status file.
extra_env = chroot.env
- base_dir = os.path.join(chroot.path, 'tmp')
- with osutils.TempDir(base_dir=base_dir) as tempdir:
+ with chroot.tempdir() as tempdir:
extra_env[constants.CROS_METRICS_DIR_ENVVAR] = tempdir
result = cros_build_lib.run(cmd, enter_chroot=True,