summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorStefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>2022-03-02 15:33:28 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-03-04 17:14:15 +0000
commit2126584d61c1d94c88cceb4f5bff14d8ec60cb91 (patch)
tree8e74739c28266aa041d01604bdf4d044da612240 /meta
parentb78f8b7cfa5ac9ff9254e05b00da3b1679c37876 (diff)
downloadpoky-2126584d61c1d94c88cceb4f5bff14d8ec60cb91.tar.gz
classes: rootfs-postcommands: include /etc/fstab in overlayfs_qa_check
The systemd init manager support mount point configuration via mount units and /etc/fstab. 'Mounts listed in /etc/fstab will be converted into native units dynamically at boot and when the configuration of the system manager is reloaded. In general, configuring mount points through /etc/fstab is the preferred approach.' [1] Read mount points from /etc/fstab to determine dynamic mount units. [1] https://www.freedesktop.org/software/systemd/man/systemd.mount.html (From OE-Core rev: 9db988dae6dbf6da7b066728bc13b59a5c45b75c) Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/rootfs-postcommands.bbclass38
-rw-r--r--meta/lib/oeqa/selftest/cases/overlayfs.py4
2 files changed, 31 insertions, 11 deletions
diff --git a/meta/classes/rootfs-postcommands.bbclass b/meta/classes/rootfs-postcommands.bbclass
index b63a5b90d3..7b92df69c5 100644
--- a/meta/classes/rootfs-postcommands.bbclass
+++ b/meta/classes/rootfs-postcommands.bbclass
@@ -372,25 +372,45 @@ rootfs_reproducible () {
372 fi 372 fi
373} 373}
374 374
375# Perform a dumb check for unit existence, not its validity
375python overlayfs_qa_check() { 376python overlayfs_qa_check() {
376 from oe.overlayfs import mountUnitName 377 from oe.overlayfs import mountUnitName
377 378
378 # this is a dumb check for unit existence, not its validity
379 overlayMountPoints = d.getVarFlags("OVERLAYFS_MOUNT_POINT") or {} 379 overlayMountPoints = d.getVarFlags("OVERLAYFS_MOUNT_POINT") or {}
380 imagepath = d.getVar("IMAGE_ROOTFS") 380 imagepath = d.getVar("IMAGE_ROOTFS")
381 searchpaths = [oe.path.join(imagepath, d.getVar("sysconfdir"), "systemd", "system"), 381 sysconfdir = d.getVar("sysconfdir")
382 searchpaths = [oe.path.join(imagepath, sysconfdir, "systemd", "system"),
382 oe.path.join(imagepath, d.getVar("systemd_system_unitdir"))] 383 oe.path.join(imagepath, d.getVar("systemd_system_unitdir"))]
384 fstabpath = oe.path.join(imagepath, sysconfdir, "fstab")
385
386 if not any(os.path.exists(path) for path in [*searchpaths, fstabpath]):
387 return
388
389 fstabDevices = []
390 if os.path.isfile(fstabpath):
391 with open(fstabpath, 'r') as f:
392 for line in f:
393 if line[0] == '#':
394 continue
395 path = line.split(maxsplit=2)
396 if len(path) > 2:
397 fstabDevices.append(path[1])
383 398
384 allUnitExist = True; 399 allUnitExist = True;
385 for mountPoint in overlayMountPoints: 400 for mountPoint in overlayMountPoints:
386 path = d.getVarFlag('OVERLAYFS_MOUNT_POINT', mountPoint) 401 mountPath = d.getVarFlag('OVERLAYFS_MOUNT_POINT', mountPoint)
387 unit = mountUnitName(path) 402 if mountPath in fstabDevices:
403 continue
404
405 mountUnit = mountUnitName(mountPath)
406 if any(os.path.isfile(oe.path.join(dirpath, mountUnit))
407 for dirpath in searchpaths):
408 continue
388 409
389 if not any(os.path.isfile(oe.path.join(dirpath, unit)) 410 bb.warn('Mount path %s not found in fstat and unit %s not found '
390 for dirpath in searchpaths): 411 'in systemd unit directories' % (mountPath, mountUnit))
391 bb.warn('Unit name %s not found in systemd unit directories' % unit) 412 allUnitExist = False;
392 allUnitExist = False;
393 413
394 if not allUnitExist: 414 if not allUnitExist:
395 bb.fatal('Not all mount units are installed by the BSP') 415 bb.fatal('Not all mount paths and units are installed in the image')
396} 416}
diff --git a/meta/lib/oeqa/selftest/cases/overlayfs.py b/meta/lib/oeqa/selftest/cases/overlayfs.py
index 82007fade7..79d36fa93c 100644
--- a/meta/lib/oeqa/selftest/cases/overlayfs.py
+++ b/meta/lib/oeqa/selftest/cases/overlayfs.py
@@ -61,9 +61,9 @@ DISTRO_FEATURES += "systemd overlayfs"
61 self.add_overlay_conf_to_machine() 61 self.add_overlay_conf_to_machine()
62 62
63 res = bitbake('core-image-minimal', ignore_status=True) 63 res = bitbake('core-image-minimal', ignore_status=True)
64 line = getline(res, "Unit name mnt-overlay.mount not found in systemd unit directories") 64 line = getline(res, " Mount path /mnt/overlay not found in fstat and unit mnt-overlay.mount not found in systemd unit directories")
65 self.assertTrue(line and line.startswith("WARNING:"), msg=res.output) 65 self.assertTrue(line and line.startswith("WARNING:"), msg=res.output)
66 line = getline(res, "Not all mount units are installed by the BSP") 66 line = getline(res, "Not all mount paths and units are installed in the image")
67 self.assertTrue(line and line.startswith("ERROR:"), msg=res.output) 67 self.assertTrue(line and line.startswith("ERROR:"), msg=res.output)
68 68
69 def test_mount_unit_not_set(self): 69 def test_mount_unit_not_set(self):