[oe-commits] [openembedded-core] branch master-next updated: useradd.bbclass: remove user/group created by the package in clean* task
git at git.openembedded.org
git at git.openembedded.org
Wed Apr 6 09:30:15 UTC 2016
rpurdie pushed a commit to branch master-next
in repository openembedded-core.
The following commit(s) were added to refs/heads/master-next by this push:
new b5304ce useradd.bbclass: remove user/group created by the package in clean* task
b5304ce is described below
commit b5304ce438666a7418746f4ddd32703ae3188089
Author: Maxin B. John <maxin.john at intel.com>
AuthorDate: Wed Apr 6 12:20:31 2016 +0300
useradd.bbclass: remove user/group created by the package in clean* task
At present, if a recipe is built which creates users/groups via
useradd.bbclass, those users/groups are not removed from sysroot
when the recipe/package is cleaned using clean/cleansstate/cleanall
or when a recipe is rebuild and 'unstaged' from the the sysroot.
The "userdel_sysroot_sstate()" provides that functionality.
[YOCTO #9262]
Signed-off-by: Maxin B. John <maxin.john at intel.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
meta/classes/sstate.bbclass | 5 +++++
meta/classes/useradd.bbclass | 29 +++++++++++++++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
index 6f285da..3234e79 100644
--- a/meta/classes/sstate.bbclass
+++ b/meta/classes/sstate.bbclass
@@ -51,6 +51,7 @@ SSTATEPREINSTFUNCS = ""
SSTATEPOSTUNPACKFUNCS = "sstate_hardcode_path_unpack"
SSTATEPOSTINSTFUNCS = ""
EXTRA_STAGING_FIXMES ?= ""
+SSTATECLEANFUNCS = ""
SIGGEN_LOCKEDSIGS_CHECK_LEVEL ?= 'error'
@@ -444,6 +445,10 @@ def sstate_clean(ss, d):
stfile.endswith(rm_nohash):
oe.path.remove(stfile)
+ # Removes the users/groups created by the package
+ for cleanfunc in (d.getVar('SSTATECLEANFUNCS', True) or '').split():
+ bb.build.exec_func(cleanfunc, d)
+
sstate_clean[vardepsexclude] = "SSTATE_MANFILEPREFIX"
CLEANFUNCS += "sstate_cleanall"
diff --git a/meta/classes/useradd.bbclass b/meta/classes/useradd.bbclass
index 0a6f2be..ee402ac 100644
--- a/meta/classes/useradd.bbclass
+++ b/meta/classes/useradd.bbclass
@@ -127,6 +127,35 @@ useradd_sysroot_sstate () {
fi
}
+userdel_sysroot_sstate () {
+if test "x${STAGING_DIR_TARGET}" != "x"; then
+ if [ "${BB_CURRENTTASK}" = "configure" -o "${BB_CURRENTTASK}" = "clean" ]; then
+ export PSEUDO="${FAKEROOTENV} PSEUDO_LOCALSTATEDIR=${STAGING_DIR_TARGET}${localstatedir}/pseudo ${STAGING_DIR_NATIVE}${bindir}/pseudo"
+ OPT="--root ${STAGING_DIR_TARGET}"
+
+ # Remove groups and users defined for package
+ GROUPADD_PARAM="${@get_all_cmd_params(d, 'groupadd')}"
+ USERADD_PARAM="${@get_all_cmd_params(d, 'useradd')}"
+
+ if test "x`echo $USERADD_PARAM | tr -d '[:space:]'`" != "x"; then
+ user=`echo "$USERADD_PARAM" | cut -d ';' -f 1 | awk '{ print $NF }'`
+ perform_userdel "${STAGING_DIR_TARGET}" "$OPT $user"
+ fi
+
+ if test "x`echo $GROUPADD_PARAM | tr -d '[:space:]'`" != "x"; then
+ group=`echo "$GROUPADD_PARAM" | cut -d ';' -f 1 | awk '{ print $NF }'`
+ perform_groupdel "${STAGING_DIR_TARGET}" "$OPT $group"
+ fi
+
+ fi
+fi
+}
+
+SSTATECLEANFUNCS = "userdel_sysroot_sstate"
+SSTATECLEANFUNCS_class-cross = ""
+SSTATECLEANFUNCS_class-native = ""
+SSTATECLEANFUNCS_class-nativesdk = ""
+
do_install[prefuncs] += "${SYSROOTFUNC}"
SYSROOTFUNC = "useradd_sysroot"
SYSROOTFUNC_class-cross = ""
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Openembedded-commits
mailing list