Modify filesystem-layout hook to check for edgeos
- On EdgeOS, we need to create /export/hda3 and make some other
directories writable.
- However, this hook disallows that because these are nonstandard root
directories.
- This changeset allows ebuilds to declare themselves as EdgeOS ebuilds,
and if they do allows them to leave /export and /users in the
filesystem root.
- More context:
https://groups.google.com/a/google.com/g/chromeos-build-discuss/c/cjETHlXhUyk/m/6hH8mVGpAAAJ
BUG=b/287334438
TEST=Built an ebuild with this
RELEASE_NOTE=None
Change-Id: Ib10143f4bf890644aed2cad9c51fae2b8b2f4b33
Reviewed-on: https://cos-review.googlesource.com/c/third_party/platform/crosutils/+/60642
Reviewed-by: Robert Kolchmeyer <rkolchmeyer@google.com>
Reviewed-by: Kirill Spitsyn <ksp@google.com>
Tested-by: Cusky Presubmit Bot <presubmit@cos-infra-prod.iam.gserviceaccount.com>
diff --git a/hooks/filesystem-layout.py b/hooks/filesystem-layout.py
index 1e97cb8..c57e5d2 100755
--- a/hooks/filesystem-layout.py
+++ b/hooks/filesystem-layout.py
@@ -49,6 +49,11 @@
"postinst",
}
+VALID_EDGEOS_ROOT = {
+ "export",
+ "user",
+}
+
# Paths that are allowed in the / dir for the SDK chroot.
VALID_HOST_ROOT = set()
@@ -155,6 +160,12 @@
}
+def is_edgeos():
+ """Check if the ebuild has declared itself an EdgeOS ebuild."""
+ # True if $USE_EDGEOS_FS_LAYOUT is set to any non empty string.
+ return bool(os.environ.get("USE_EDGEOS_FS_LAYOUT"))
+
+
def has_subdirs(path):
"""See if |path| has any subdirs."""
# These checks are helpful for manually running the script when debugging.
@@ -222,7 +233,7 @@
return ret
-def check_root(root, host=False):
+def check_root(root, host=False, edgeos=False):
"""Check the filesystem |root|."""
ret = True
@@ -234,6 +245,9 @@
else:
unknown -= VALID_BOARD_ROOT
+ if edgeos:
+ unknown -= VALID_EDGEOS_ROOT
+
if unknown:
logging.error(
"Paths are not allowed in the root dir:\n %s\n |-- %s",
@@ -343,7 +357,7 @@
else:
opts.host = not bool(os.getenv("SYSROOT"))
- if not check_root(opts.root, opts.host):
+ if not check_root(opts.root, opts.host, is_edgeos()):
logging.critical(
"Package '%s' does not conform to CrOS's filesystem conventions. "
"Please review the paths flagged above and adjust its layout.",