summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVyacheslav Yurkov <uvv.mail@gmail.com>2021-08-06 14:06:05 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-08-12 06:26:15 +0100
commit2377193d7a11b093e5225623de67e5cbae23a30f (patch)
treea6fbb5b3f19c174b8a55539f4d67614c68383a24
parenta99473976d9dae0e5e446f696d3176a09a2fb61f (diff)
downloadpoky-2377193d7a11b093e5225623de67e5cbae23a30f.tar.gz
lib/oe: add generic functions for overlayfs
(From OE-Core rev: 53f0af20f94399335c8a5a6b7001994e332b69a6) Signed-off-by: Vyacheslav Yurkov <uvv.mail@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oe/overlayfs.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/meta/lib/oe/overlayfs.py b/meta/lib/oe/overlayfs.py
new file mode 100644
index 0000000000..21ef710509
--- /dev/null
+++ b/meta/lib/oe/overlayfs.py
@@ -0,0 +1,43 @@
1#
2# SPDX-License-Identifier: GPL-2.0-only
3#
4# This file contains common functions for overlayfs and its QA check
5
6# this function is based on https://github.com/systemd/systemd/blob/main/src/basic/unit-name.c
7def escapeSystemdUnitName(path):
8 escapeMap = {
9 '/': '-',
10 '-': "\\x2d",
11 '\\': "\\x5d"
12 }
13 return "".join([escapeMap.get(c, c) for c in path.strip('/')])
14
15def strForBash(s):
16 return s.replace('\\', '\\\\')
17
18def mountUnitName(unit):
19 return escapeSystemdUnitName(unit) + '.mount'
20
21def helperUnitName(unit):
22 return escapeSystemdUnitName(unit) + '-create-upper-dir.service'
23
24def unitFileList(d):
25 fileList = []
26 overlayMountPoints = d.getVarFlags("OVERLAYFS_MOUNT_POINT")
27
28 if not overlayMountPoints:
29 bb.fatal("A recipe uses overlayfs class but there is no OVERLAYFS_MOUNT_POINT set in your MACHINE configuration")
30
31 # check that we have required mount points set first
32 requiredMountPoints = d.getVarFlags('OVERLAYFS_WRITABLE_PATHS')
33 for mountPoint in requiredMountPoints:
34 if mountPoint not in overlayMountPoints:
35 bb.fatal("Missing required mount point for OVERLAYFS_MOUNT_POINT[%s] in your MACHINE configuration" % mountPoint)
36
37 for mountPoint in overlayMountPoints:
38 for path in d.getVarFlag('OVERLAYFS_WRITABLE_PATHS', mountPoint).split():
39 fileList.append(mountUnitName(path))
40 fileList.append(helperUnitName(path))
41
42 return fileList
43