]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
files: rootfs-postcommands: move helper commands to script
authorVyacheslav Yurkov <v.yurkov@precitec.de>
Wed, 1 Jun 2022 19:30:10 +0000 (21:30 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sat, 4 Jun 2022 10:27:09 +0000 (11:27 +0100)
OverlayFS systemd helper unit might require more pre-processing
commands. It gets more complicated to embed them in a unit file, because
systemd shell subset is limited and might require additional escaping.
Move the command to a separate script, thus simplifying systemd unit.

Signed-off-by: Vyacheslav Yurkov <v.yurkov@precitec.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/rootfs-postcommands.bbclass
meta/files/overlayfs-create-dirs.service.in
meta/files/overlayfs-create-dirs.sh [new file with mode: 0644]

index d302c23cf4daed44e65f6098b7a377c9074ab885..3f9fdb602d4820711cb1655ada57ef653b22a58f 100644 (file)
@@ -39,7 +39,7 @@ ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("DISTRO_FEATURES", "systemd"
 
 ROOTFS_POSTPROCESS_COMMAND += 'empty_var_volatile;'
 
-ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("DISTRO_FEATURES", "overlayfs", "overlayfs_qa_check;", "", d)}'
+ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("DISTRO_FEATURES", "overlayfs", "overlayfs_qa_check; overlayfs_postprocess;", "", d)}'
 
 inherit image-artifact-names
 
@@ -422,3 +422,14 @@ python overlayfs_qa_check() {
     if not allUnitExist:
         bb.fatal('Not all mount paths and units are installed in the image')
 }
+
+python overlayfs_postprocess() {
+    import shutil
+
+    # install helper script
+    helperScriptName = "overlayfs-create-dirs.sh"
+    helperScriptSource = oe.path.join(d.getVar("COREBASE"), "meta/files", helperScriptName)
+    helperScriptDest = oe.path.join(d.getVar("IMAGE_ROOTFS"), "/usr/sbin/", helperScriptName)
+    shutil.copyfile(helperScriptSource, helperScriptDest)
+    os.chmod(helperScriptDest, 0o755)
+}
index 61b2b9321b97439025f7b6e6ebad2b9b3d819145..c949a6dc7363332749f6ea7828fb93e005b2ef67 100644 (file)
@@ -6,8 +6,7 @@ DefaultDependencies=no
 
 [Service]
 Type=oneshot
-ExecStart=mkdir -p {DATA_MOUNT_POINT}/upper{LOWERDIR}
-ExecStart=mkdir -p {DATA_MOUNT_POINT}/workdir{LOWERDIR}
+ExecStart=/usr/sbin/overlayfs-create-dirs.sh {LOWERDIR} {DATA_MOUNT_POINT}
 RemainAfterExit=true
 StandardOutput=journal
 
diff --git a/meta/files/overlayfs-create-dirs.sh b/meta/files/overlayfs-create-dirs.sh
new file mode 100644 (file)
index 0000000..06c7587
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+# This script is intended to be used sorely by overlayfs-create-dirs.service
+# Usage: overlayfs-create-dirs.sh <LOWERDIR> <DATA_MOUNT_POINT>
+
+lowerdir=$1
+datamountpoint=$2
+mkdir -p ${datamountpoint}/upper${lowerdir}
+mkdir -p ${datamountpoint}/workdir${lowerdir}