Fix EROFS error when root fs is mounted read-only
repo attempts to create /etc/.repo_gitconfig.json file, and fails if
root file system is mounted read-only. Removing non-existing file on
read-only filesystem results in EROFS instead of ENOENT.
Bug: 401018409
Change-Id: I64edc0567fb88649f3fd8cacb65a8780744640d4
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/458821
Reviewed-by: Mike Frysinger
Tested-by: Egor Duda
Commit-Queue: Egor Duda
diff --git a/platform_utils.py b/platform_utils.py
index e20198e..45ffec7 100644
--- a/platform_utils.py
+++ b/platform_utils.py
@@ -156,6 +156,12 @@
os.rmdir(longpath)
else:
os.remove(longpath)
+ elif (
+ e.errno == errno.EROFS
+ and missing_ok
+ and not os.path.exists(longpath)
+ ):
+ pass
elif missing_ok and e.errno == errno.ENOENT:
pass
else: