From ff2f282dd49deac30014db57515483ed31497907 Mon Sep 17 00:00:00 2001
From: Andrei Gherzan <andrei.gherzan@huawei.com>
Date: Mon, 18 Jul 2022 16:14:10 +0200
Subject: [PATCH] oniro-mounts: Have the entire /home mounted from appdata

This offers the ability to have persistent data for features that
requires user data: for example running podman in rootless mode.
This change also makes sure that the home directory of user 'oniro'
exists on the appdata partition (using systemd tmpfiles).

Signed-off-by: Andrei Gherzan <andrei.gherzan@huawei.com>
---
 .../recipes-core/oniro-mounts/oniro-mounts.bb   |  7 +++++++
 .../oniro-mounts/oniro-mounts/home.mount        | 17 +++++++++++++++++
 .../oniro-mounts/oniro-homes.conf.tmpfiles      |  6 ++++++
 3 files changed, 30 insertions(+)
 create mode 100644 meta-oniro-core/recipes-core/oniro-mounts/oniro-mounts/home.mount
 create mode 100644 meta-oniro-core/recipes-core/oniro-mounts/oniro-mounts/oniro-homes.conf.tmpfiles

diff --git a/meta-oniro-core/recipes-core/oniro-mounts/oniro-mounts.bb b/meta-oniro-core/recipes-core/oniro-mounts/oniro-mounts.bb
index ee74a666..ccd0d8bb 100644
--- a/meta-oniro-core/recipes-core/oniro-mounts/oniro-mounts.bb
+++ b/meta-oniro-core/recipes-core/oniro-mounts/oniro-mounts.bb
@@ -12,15 +12,18 @@ LICENSE = "Apache-2.0"
 LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
 
 SRC_URI = " \
+    file://home.mount \
     file://run-mount-boot.mount \
     file://run-mount-devdata.mount \
     file://run-mount-appdata.mount \
     file://run-mount-sysdata.mount \
+    file://oniro-homes.conf.tmpfiles \
     "
 
 inherit allarch systemd
 
 SYSTEMD_SERVICE:${PN} = " \
+    home.mount \
     run-mount-boot.mount \
     run-mount-sysdata.mount \
     run-mount-devdata.mount \
@@ -40,6 +43,10 @@ do_install () {
     for label in ${LABELS}; do
         install -m 0644 "${WORKDIR}/run-mount-${label}.mount" "${D}${systemd_unitdir}/system"
     done
+    install -m 0644 "${WORKDIR}/home.mount" "${D}${systemd_unitdir}/system"
+
+    install -D "${WORKDIR}/oniro-homes.conf.tmpfiles" \
+        "${D}${sysconfdir}/tmpfiles.d/oniro-homes.conf"
 }
 
 FILES:${PN} += "${systemd_unitdir}"
diff --git a/meta-oniro-core/recipes-core/oniro-mounts/oniro-mounts/home.mount b/meta-oniro-core/recipes-core/oniro-mounts/oniro-mounts/home.mount
new file mode 100644
index 00000000..83b282d2
--- /dev/null
+++ b/meta-oniro-core/recipes-core/oniro-mounts/oniro-mounts/home.mount
@@ -0,0 +1,17 @@
+# SPDX-FileCopyrightText: Huawei Inc.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+[Unit]
+Description=home mount - appdata
+Before=sysinit.target
+Requires=run-mount-appdata.mount
+After=run-mount-appdata.mount
+
+[Mount]
+What=/run/mount/appdata/user-data/home
+Where=/home
+Options=bind
+
+[Install]
+WantedBy=sysinit.target
diff --git a/meta-oniro-core/recipes-core/oniro-mounts/oniro-mounts/oniro-homes.conf.tmpfiles b/meta-oniro-core/recipes-core/oniro-mounts/oniro-mounts/oniro-homes.conf.tmpfiles
new file mode 100644
index 00000000..8cce21e9
--- /dev/null
+++ b/meta-oniro-core/recipes-core/oniro-mounts/oniro-mounts/oniro-homes.conf.tmpfiles
@@ -0,0 +1,6 @@
+# SPDX-FileCopyrightText: Huawei Inc.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+# The home directory of the oniro user.
+d /run/mount/appdata/user-data/home/oniro 0700 oniro oniro - -
-- 
GitLab