diff options
-rw-r--r-- | meta/classes/overlayfs.bbclass | 36 | ||||
-rw-r--r-- | meta/lib/oe/overlayfs.py | 5 |
2 files changed, 39 insertions, 2 deletions
diff --git a/meta/classes/overlayfs.bbclass b/meta/classes/overlayfs.bbclass index 8d9b59c9bf..9397ab44f9 100644 --- a/meta/classes/overlayfs.bbclass +++ b/meta/classes/overlayfs.bbclass | |||
@@ -37,6 +37,8 @@ REQUIRED_DISTRO_FEATURES += "systemd overlayfs" | |||
37 | inherit systemd features_check | 37 | inherit systemd features_check |
38 | 38 | ||
39 | python do_create_overlayfs_units() { | 39 | python do_create_overlayfs_units() { |
40 | from oe.overlayfs import mountUnitName | ||
41 | |||
40 | CreateDirsUnitTemplate = """[Unit] | 42 | CreateDirsUnitTemplate = """[Unit] |
41 | Description=Overlayfs directories setup | 43 | Description=Overlayfs directories setup |
42 | Requires={DATA_MOUNT_UNIT} | 44 | Requires={DATA_MOUNT_UNIT} |
@@ -66,9 +68,22 @@ Options=lowerdir={LOWERDIR},upperdir={DATA_MOUNT_POINT}/upper{LOWERDIR},workdir= | |||
66 | [Install] | 68 | [Install] |
67 | WantedBy=multi-user.target | 69 | WantedBy=multi-user.target |
68 | """ | 70 | """ |
71 | AllOverlaysTemplate = """[Unit] | ||
72 | Description=Groups all overlays required by {PN} in one unit | ||
73 | After={ALL_OVERLAYFS_UNITS} | ||
74 | Requires={ALL_OVERLAYFS_UNITS} | ||
75 | |||
76 | [Service] | ||
77 | Type=oneshot | ||
78 | ExecStart=/bin/true | ||
79 | RemainAfterExit=true | ||
80 | |||
81 | [Install] | ||
82 | WantedBy=local-fs.target | ||
83 | """ | ||
69 | 84 | ||
70 | def prepareUnits(data, lower): | 85 | def prepareUnits(data, lower): |
71 | from oe.overlayfs import mountUnitName, helperUnitName | 86 | from oe.overlayfs import helperUnitName |
72 | 87 | ||
73 | args = { | 88 | args = { |
74 | 'DATA_MOUNT_POINT': data, | 89 | 'DATA_MOUNT_POINT': data, |
@@ -83,10 +98,27 @@ WantedBy=multi-user.target | |||
83 | with open(os.path.join(d.getVar('WORKDIR'), helperUnitName(lower)), 'w') as f: | 98 | with open(os.path.join(d.getVar('WORKDIR'), helperUnitName(lower)), 'w') as f: |
84 | f.write(CreateDirsUnitTemplate.format(**args)) | 99 | f.write(CreateDirsUnitTemplate.format(**args)) |
85 | 100 | ||
101 | def prepareGlobalUnit(dependentUnits): | ||
102 | from oe.overlayfs import allOverlaysUnitName | ||
103 | args = { | ||
104 | 'ALL_OVERLAYFS_UNITS': " ".join(dependentUnits), | ||
105 | 'PN': d.getVar('PN') | ||
106 | } | ||
107 | |||
108 | with open(os.path.join(d.getVar('WORKDIR'), allOverlaysUnitName(d)), 'w') as f: | ||
109 | f.write(AllOverlaysTemplate.format(**args)) | ||
110 | |||
111 | mountUnitList = [] | ||
86 | overlayMountPoints = d.getVarFlags("OVERLAYFS_MOUNT_POINT") | 112 | overlayMountPoints = d.getVarFlags("OVERLAYFS_MOUNT_POINT") |
87 | for mountPoint in overlayMountPoints: | 113 | for mountPoint in overlayMountPoints: |
88 | for lower in d.getVarFlag('OVERLAYFS_WRITABLE_PATHS', mountPoint).split(): | 114 | for lower in d.getVarFlag('OVERLAYFS_WRITABLE_PATHS', mountPoint).split(): |
89 | prepareUnits(d.getVarFlag('OVERLAYFS_MOUNT_POINT', mountPoint), lower) | 115 | prepareUnits(d.getVarFlag('OVERLAYFS_MOUNT_POINT', mountPoint), lower) |
116 | mountUnitList.append(mountUnitName(lower)) | ||
117 | |||
118 | # set up one unit, which depends on all mount units, so users can set | ||
119 | # only one dependency in their units to make sure software starts | ||
120 | # when all overlays are mounted | ||
121 | prepareGlobalUnit(mountUnitList) | ||
90 | } | 122 | } |
91 | 123 | ||
92 | # we need to generate file names early during parsing stage | 124 | # we need to generate file names early during parsing stage |
@@ -95,7 +127,7 @@ python () { | |||
95 | 127 | ||
96 | unitList = unitFileList(d) | 128 | unitList = unitFileList(d) |
97 | for unit in unitList: | 129 | for unit in unitList: |
98 | d.appendVar('SYSTEMD_SERVICE:' + d.getVar('PN'), ' ' + unit); | 130 | d.appendVar('SYSTEMD_SERVICE:' + d.getVar('PN'), ' ' + unit) |
99 | d.appendVar('FILES:' + d.getVar('PN'), ' ' + strForBash(unit)) | 131 | d.appendVar('FILES:' + d.getVar('PN'), ' ' + strForBash(unit)) |
100 | 132 | ||
101 | d.setVar('OVERLAYFS_UNIT_LIST', ' '.join([strForBash(s) for s in unitList])) | 133 | d.setVar('OVERLAYFS_UNIT_LIST', ' '.join([strForBash(s) for s in unitList])) |
diff --git a/meta/lib/oe/overlayfs.py b/meta/lib/oe/overlayfs.py index 21ef710509..b5d5e88e80 100644 --- a/meta/lib/oe/overlayfs.py +++ b/meta/lib/oe/overlayfs.py | |||
@@ -15,6 +15,9 @@ def escapeSystemdUnitName(path): | |||
15 | def strForBash(s): | 15 | def strForBash(s): |
16 | return s.replace('\\', '\\\\') | 16 | return s.replace('\\', '\\\\') |
17 | 17 | ||
18 | def allOverlaysUnitName(d): | ||
19 | return d.getVar('PN') + '-overlays.service' | ||
20 | |||
18 | def mountUnitName(unit): | 21 | def mountUnitName(unit): |
19 | return escapeSystemdUnitName(unit) + '.mount' | 22 | return escapeSystemdUnitName(unit) + '.mount' |
20 | 23 | ||
@@ -39,5 +42,7 @@ def unitFileList(d): | |||
39 | fileList.append(mountUnitName(path)) | 42 | fileList.append(mountUnitName(path)) |
40 | fileList.append(helperUnitName(path)) | 43 | fileList.append(helperUnitName(path)) |
41 | 44 | ||
45 | fileList.append(allOverlaysUnitName(d)) | ||
46 | |||
42 | return fileList | 47 | return fileList |
43 | 48 | ||