Patchwork [CONSOLIDATED,PULL,08/27] base-passwd: move initial criation of group and passwd to preinst

login
register
mail settings
Submitter Saul Wold
Date Oct. 23, 2011, 6:26 p.m.
Message ID <cdfa5a93d862f5b0fa4b8b723e825411906ad8c6.1319394187.git.sgw@linux.intel.com>
Download mbox | patch
Permalink /patch/13765/
State New, archived
Headers show

Comments

Saul Wold - Oct. 23, 2011, 6:26 p.m.
From: Otavio Salvador <otavio@ossystems.com.br>

To allow use and manipulation of users and groups at rootfs building
time, the '/etc/passwd' and '/etc/group' needs to be available as soon
as possible.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
---
 .../recipes-core/base-passwd/base-passwd_3.5.22.bb |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

Patch

diff --git a/meta/recipes-core/base-passwd/base-passwd_3.5.22.bb b/meta/recipes-core/base-passwd/base-passwd_3.5.22.bb
index 137512d..aa90a6d 100644
--- a/meta/recipes-core/base-passwd/base-passwd_3.5.22.bb
+++ b/meta/recipes-core/base-passwd/base-passwd_3.5.22.bb
@@ -1,7 +1,7 @@ 
 SUMMARY = "Base system master password/group files."
 DESCRIPTION = "The master copies of the user database files (/etc/passwd and /etc/group).  The update-passwd tool is also provided to keep the system databases synchronized with these master files."
 SECTION = "base"
-PR = "r3"
+PR = "r4"
 LICENSE = "GPLv2+"
 LIC_FILES_CHKSUM = "file://COPYING;md5=eb723b61539feef013de476e68b5c50a"
 
@@ -37,6 +37,23 @@  do_install () {
 	install -p -m 644 debian/copyright ${D}${docdir}/${BPN}/
 }
 
+pkg_preinst_${PN} () {
+	set -e
+
+	# Used for rootfs generation. On in-target install this will be run
+        # before the unpack so the files won't be available
+
+	if [ ! -e $D${sysconfdir}/passwd ] && [ -e $D${datadir}/base-passwd/passwd.master ]; then
+		cp $D${datadir}/base-passwd/passwd.master $D${sysconfdir}/passwd
+	fi
+
+	if [ ! -e $D${sysconfdir}/group ] && [ -e $D${datadir}/base-passwd/group.master ]; then
+		cp $D${datadir}/base-passwd/group.master $D${sysconfdir}/group
+	fi
+
+	exit 0
+}
+
 pkg_postinst_${PN} () {
 	set -e