CHROMIUM: Avoid cross-tree renames with CROS_ARTIFACTS_TMP_DIR
/var/tmp and /var/lib may be different bind mounts, and when that
happens, we hit "cross-device link" errors like this:
OSError: [Errno 18] Invalid cross-device link:
b'/var/tmp/portage/chromeos-base/libbrillo-0.0.1-r2309/cros-artifacts'
->
b'/var/lib/chromeos/package-artifacts/chromeos-base/libbrillo-0.0.1-r2309'
We don't actually require the atomic rename semantics, so shutil.move()
would be a natural replacement. However, portage wraps shutil in an
implicit encoding class which translates our strings to bytes and breaks
shutil.move(). See https://bugs.gentoo.org/914722 for more info.
Thus, I open-code a portion of shutil.move() using shutil.copytree() and
shutil.rmtree().
BUG=b:265885353
TEST=`sudo emerge ...` after /var/tmp is on a different filesystem
sample manual hack: `sudo mount --bind /var/tmp /var/tmp`
Change-Id: Idba6cd0ce8c687b2546a798fcf914ddda4a34cd9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/portage_tool/+/4892621
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Brian Norris <briannorris@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Tested-by: Brian Norris <briannorris@chromium.org>
1 file changed