[isar-cip-core][PATCH 4/6] change-root-homedir: split root home move into own package


Henning Schild <henning.schild@...>
 

Changing the homedir of root that way is required by any layer that
takes ro rootfs pieces from here. Making it its own package allows
reuse without having to take some other customizations.

Signed-off-by: Henning Schild <henning.schild@...>
---
.../change-root-homedir.bb | 5 +++++
.../change-root-homedir/files/postinst | 21 +++++++++++++++++++
recipes-core/customizations/common.inc | 5 +++--
recipes-core/customizations/files/postinst | 8 -------
4 files changed, 29 insertions(+), 10 deletions(-)
create mode 100644 recipes-core/change-root-homedir/change-root-homedir.bb
create mode 100644 recipes-core/change-root-homedir/files/postinst

diff --git a/recipes-core/change-root-homedir/change-root-homedir.bb b/recipes-core/change-root-homedir/change-root-homedir.bb
new file mode 100644
index 000000000000..dc4631bd6b16
--- /dev/null
+++ b/recipes-core/change-root-homedir/change-root-homedir.bb
@@ -0,0 +1,5 @@
+inherit dpkg-raw
+
+DESCRIPTION = "Move roots homedir to /home for read-only rootfs"
+
+SRC_URI = "file://postinst"
diff --git a/recipes-core/change-root-homedir/files/postinst b/recipes-core/change-root-homedir/files/postinst
new file mode 100644
index 000000000000..205ee4839e82
--- /dev/null
+++ b/recipes-core/change-root-homedir/files/postinst
@@ -0,0 +1,21 @@
+#!/bin/sh
+#
+# CIP Core, generic profile
+#
+# Copyright (c) Siemens AG, 2019
+#
+# Authors:
+# Jan Kiszka <jan.kiszka@...>
+#
+# SPDX-License-Identifier: MIT
+#
+
+set -e
+
+# needed for read-only rootfs with writable /home
+if [ ! -L /root ]; then
+ # usermod --move-home can not be used while the target user
+ # has running processes, also we keep a symlink here
+ mv /root /home/
+ ln -s /home/root /root
+fi
diff --git a/recipes-core/customizations/common.inc b/recipes-core/customizations/common.inc
index 1124ff2d3590..24c862c32e3b 100644
--- a/recipes-core/customizations/common.inc
+++ b/recipes-core/customizations/common.inc
@@ -22,10 +22,11 @@ SRC_URI = " \
WIRELESS_FIRMWARE_PACKAGE ?= ""
INSTALL_WIRELESS_TOOLS ??= "0"

-DEPENDS += "sshd-regen-keys"
+DEPENDS += "sshd-regen-keys change-root-homedir"

DEBIAN_DEPENDS = " \
- ifupdown, isc-dhcp-client, net-tools, iputils-ping, ssh, sshd-regen-keys \
+ ifupdown, isc-dhcp-client, net-tools, iputils-ping, ssh, sshd-regen-keys, \
+ change-root-homedir \
${@(', iw, wireless-regdb, ' + d.getVar('WIRELESS_FIRMWARE_PACKAGE')) \
if d.getVar('INSTALL_WIRELESS_TOOLS') == '1' else ''}"

diff --git a/recipes-core/customizations/files/postinst b/recipes-core/customizations/files/postinst
index 7a0b00d98680..7e7ea3692325 100644
--- a/recipes-core/customizations/files/postinst
+++ b/recipes-core/customizations/files/postinst
@@ -21,11 +21,3 @@ fi
HOSTNAME=demo
echo "$HOSTNAME" > /etc/hostname
echo "127.0.0.1 $HOSTNAME" >> /etc/hosts
-
-# needed for read-only rootfs with writable /home
-if [ ! -L /root ]; then
- # usermod --move-home can not be used while the target user
- # has running processes, also we keep a symlink here
- mv /root /home/
- ln -s /home/root /root
-fi
--
2.37.4