From: Stefan Herbrechtsmeier <stefan.herbrechtsme...@weidmueller.com>
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 Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsme...@weidmueller.com> --- meta/classes/rootfs-postcommands.bbclass | 38 +++++++++++++++++------ meta/lib/oeqa/selftest/cases/overlayfs.py | 4 +-- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/meta/classes/rootfs-postcommands.bbclass b/meta/classes/rootfs-postcommands.bbclass index cd8986d8a9..e1276a220a 100644 --- a/meta/classes/rootfs-postcommands.bbclass +++ b/meta/classes/rootfs-postcommands.bbclass @@ -376,25 +376,45 @@ rootfs_reproducible () { fi } +# Perform a dumb check for unit existence, not its validity python overlayfs_qa_check() { from oe.overlayfs import mountUnitName - # this is a dumb check for unit existence, not its validity overlayMountPoints = d.getVarFlags("OVERLAYFS_MOUNT_POINT") or {} imagepath = d.getVar("IMAGE_ROOTFS") - searchpaths = [oe.path.join(imagepath, d.getVar("sysconfdir"), "systemd", "system"), + sysconfdir = d.getVar("sysconfdir") + searchpaths = [oe.path.join(imagepath, sysconfdir, "systemd", "system"), oe.path.join(imagepath, d.getVar("systemd_system_unitdir"))] + fstabpath = oe.path.join(imagepath, sysconfdir, "fstab") + + if not any(os.path.exists(path) for path in [*searchpaths, fstabpath]): + return + + fstabDevices = [] + if os.path.isfile(fstabpath): + with open(fstabpath, 'r') as f: + for line in f: + if line[0] == '#': + continue + path = line.split(maxsplit=2) + if len(path) > 2: + fstabDevices.append(path[1]) allUnitExist = True; for mountPoint in overlayMountPoints: - path = d.getVarFlag('OVERLAYFS_MOUNT_POINT', mountPoint) - unit = mountUnitName(path) + mountPath = d.getVarFlag('OVERLAYFS_MOUNT_POINT', mountPoint) + if mountPath in fstabDevices: + continue + + mountUnit = mountUnitName(mountPath) + if any(os.path.isfile(oe.path.join(dirpath, mountUnit)) + for dirpath in searchpaths): + continue - if not any(os.path.isfile(oe.path.join(dirpath, unit)) - for dirpath in searchpaths): - bb.warn('Unit name %s not found in systemd unit directories' % unit) - allUnitExist = False; + bb.warn('Mount path %s not found in fstat and unit %s not found ' + 'in systemd unit directories' % (mountPath, mountUnit)) + allUnitExist = False; if not allUnitExist: - bb.fatal('Not all mount units are installed by the BSP') + bb.fatal('Not all mount paths and units are installed in the image') } 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" self.add_overlay_conf_to_machine() res = bitbake('core-image-minimal', ignore_status=True) - line = getline(res, "Unit name mnt-overlay.mount not found in systemd unit directories") + line = getline(res, " Mount path /mnt/overlay not found in fstat and unit mnt-overlay.mount not found in systemd unit directories") self.assertTrue(line and line.startswith("WARNING:"), msg=res.output) - line = getline(res, "Not all mount units are installed by the BSP") + line = getline(res, "Not all mount paths and units are installed in the image") self.assertTrue(line and line.startswith("ERROR:"), msg=res.output) def test_mount_unit_not_set(self): -- 2.30.2
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#162612): https://lists.openembedded.org/g/openembedded-core/message/162612 Mute This Topic: https://lists.openembedded.org/mt/89502037/21656 Group Owner: openembedded-core+ow...@lists.openembedded.org Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-