diff options
| author | Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> | 2022-03-02 15:33:28 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-03-04 17:14:15 +0000 |
| commit | 2126584d61c1d94c88cceb4f5bff14d8ec60cb91 (patch) | |
| tree | 8e74739c28266aa041d01604bdf4d044da612240 /meta/classes/rootfs-postcommands.bbclass | |
| parent | b78f8b7cfa5ac9ff9254e05b00da3b1679c37876 (diff) | |
| download | poky-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/classes/rootfs-postcommands.bbclass')
| -rw-r--r-- | meta/classes/rootfs-postcommands.bbclass | 38 |
1 files changed, 29 insertions, 9 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 | ||
| 375 | python overlayfs_qa_check() { | 376 | python 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 | } |
