poky-contrib/meta/lib/oe/overlayfs.py
Vyacheslav Yurkov 2eb933bb8c overlayfs: Allow not used mount points
When machine configuration defines a mount point, which is not used in
any recipe, allow to fall through and only report a note in the logs.
This can be expected behavior, when a mount point is defined for several
machines, but not used in all of them

(From OE-Core rev: a9c604b5e0d943b5b5f7c8bdd5be730c2abcf866)

Signed-off-by: Vyacheslav Yurkov <Vyacheslav.Yurkov@bruker.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-10-26 12:28:37 +01:00

55 lines
1.8 KiB
Python

#
# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: GPL-2.0-only
#
# This file contains common functions for overlayfs and its QA check
# this function is based on https://github.com/systemd/systemd/blob/main/src/basic/unit-name.c
def escapeSystemdUnitName(path):
escapeMap = {
'/': '-',
'-': "\\x2d",
'\\': "\\x5d"
}
return "".join([escapeMap.get(c, c) for c in path.strip('/')])
def strForBash(s):
return s.replace('\\', '\\\\')
def allOverlaysUnitName(d):
return d.getVar('PN') + '-overlays.service'
def mountUnitName(unit):
return escapeSystemdUnitName(unit) + '.mount'
def helperUnitName(unit):
return escapeSystemdUnitName(unit) + '-create-upper-dir.service'
def unitFileList(d):
fileList = []
overlayMountPoints = d.getVarFlags("OVERLAYFS_MOUNT_POINT")
if not overlayMountPoints:
bb.fatal("A recipe uses overlayfs class but there is no OVERLAYFS_MOUNT_POINT set in your MACHINE configuration")
# check that we have required mount points set first
requiredMountPoints = d.getVarFlags('OVERLAYFS_WRITABLE_PATHS')
for mountPoint in requiredMountPoints:
if mountPoint not in overlayMountPoints:
bb.fatal("Missing required mount point for OVERLAYFS_MOUNT_POINT[%s] in your MACHINE configuration" % mountPoint)
for mountPoint in overlayMountPoints:
mountPointList = d.getVarFlag('OVERLAYFS_WRITABLE_PATHS', mountPoint)
if not mountPointList:
bb.debug(1, "No mount points defined for %s flag, don't add to file list", mountPoint)
continue
for path in mountPointList.split():
fileList.append(mountUnitName(path))
fileList.append(helperUnitName(path))
fileList.append(allOverlaysUnitName(d))
return fileList