summaryrefslogtreecommitdiffstats
path: root/meta-agl/classes/useradd.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta-agl/classes/useradd.bbclass')
-rw-r--r--meta-agl/classes/useradd.bbclass93
1 files changed, 57 insertions, 36 deletions
diff --git a/meta-agl/classes/useradd.bbclass b/meta-agl/classes/useradd.bbclass
index 83425c820..bf62ada8b 100644
--- a/meta-agl/classes/useradd.bbclass
+++ b/meta-agl/classes/useradd.bbclass
@@ -3,11 +3,7 @@ inherit useradd_base
# base-passwd-cross provides the default passwd and group files in the
# target sysroot, and shadow -native and -sysroot provide the utilities
# and support files needed to add and modify user and group accounts
-DEPENDS_append = "${USERADDDEPENDS}"
-USERADDDEPENDS = " base-files shadow-native shadow-sysroot shadow"
-USERADDDEPENDS_class-cross = ""
-USERADDDEPENDS_class-native = ""
-USERADDDEPENDS_class-nativesdk = ""
+DEPENDS_append_class-target = " base-files shadow-native shadow-sysroot shadow"
# This preinstall function can be run in four different contexts:
#
@@ -50,51 +46,51 @@ fi
# Perform group additions first, since user additions may depend
# on these groups existing
-if test "x$GROUPADD_PARAM" != "x"; then
+if test "x`echo $GROUPADD_PARAM | tr -d '[:space:]'`" != "x"; then
echo "Running groupadd commands..."
# Invoke multiple instances of groupadd for parameter lists
# separated by ';'
- opts=`echo "$GROUPADD_PARAM" | cut -d ';' -f 1`
- remaining=`echo "$GROUPADD_PARAM" | cut -d ';' -f 2-`
+ opts=`echo "$GROUPADD_PARAM" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
+ remaining=`echo "$GROUPADD_PARAM" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
while test "x$opts" != "x"; do
perform_groupadd "$SYSROOT" "$OPT $opts"
if test "x$opts" = "x$remaining"; then
break
fi
- opts=`echo "$remaining" | cut -d ';' -f 1`
- remaining=`echo "$remaining" | cut -d ';' -f 2-`
+ opts=`echo "$remaining" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
+ remaining=`echo "$remaining" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
done
fi
-if test "x$USERADD_PARAM" != "x"; then
+if test "x`echo $USERADD_PARAM | tr -d '[:space:]'`" != "x"; then
echo "Running useradd commands..."
# Invoke multiple instances of useradd for parameter lists
# separated by ';'
- opts=`echo "$USERADD_PARAM" | cut -d ';' -f 1`
- remaining=`echo "$USERADD_PARAM" | cut -d ';' -f 2-`
+ opts=`echo "$USERADD_PARAM" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
+ remaining=`echo "$USERADD_PARAM" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
while test "x$opts" != "x"; do
perform_useradd "$SYSROOT" "$OPT $opts"
if test "x$opts" = "x$remaining"; then
break
fi
- opts=`echo "$remaining" | cut -d ';' -f 1`
- remaining=`echo "$remaining" | cut -d ';' -f 2-`
+ opts=`echo "$remaining" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
+ remaining=`echo "$remaining" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
done
fi
-if test "x$GROUPMEMS_PARAM" != "x"; then
+if test "x`echo $GROUPMEMS_PARAM | tr -d '[:space:]'`" != "x"; then
echo "Running groupmems commands..."
# Invoke multiple instances of groupmems for parameter lists
# separated by ';'
- opts=`echo "$GROUPMEMS_PARAM" | cut -d ';' -f 1`
- remaining=`echo "$GROUPMEMS_PARAM" | cut -d ';' -f 2-`
+ opts=`echo "$GROUPMEMS_PARAM" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
+ remaining=`echo "$GROUPMEMS_PARAM" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
while test "x$opts" != "x"; do
perform_groupmems "$SYSROOT" "$OPT $opts"
if test "x$opts" = "x$remaining"; then
break
fi
- opts=`echo "$remaining" | cut -d ';' -f 1`
- remaining=`echo "$remaining" | cut -d ';' -f 2-`
+ opts=`echo "$remaining" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
+ remaining=`echo "$remaining" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
done
fi
}
@@ -103,7 +99,7 @@ useradd_sysroot () {
# Pseudo may (do_install) or may not (do_populate_sysroot_setscene) be running
# at this point so we're explicit about the environment so pseudo can load if
# not already present.
- export PSEUDO="${FAKEROOTENV} PSEUDO_LOCALSTATEDIR=${STAGING_DIR_TARGET}${localstatedir}/pseudo ${STAGING_DIR_NATIVE}${bindir}/pseudo"
+ export PSEUDO="${FAKEROOTENV} PSEUDO_LOCALSTATEDIR=${STAGING_DIR_TARGET}${localstatedir}/pseudo ${STAGING_DIR_NATIVE}${bindir_native}/pseudo"
# Explicitly set $D since it isn't set to anything
# before do_install
@@ -127,23 +123,48 @@ useradd_sysroot_sstate () {
fi
}
+userdel_sysroot_sstate () {
+if test "x${STAGING_DIR_TARGET}" != "x"; then
+ if [ "${BB_CURRENTTASK}" = "clean" ]; then
+ export PSEUDO="${FAKEROOTENV} PSEUDO_LOCALSTATEDIR=${STAGING_DIR_TARGET}${localstatedir}/pseudo ${STAGING_DIR_NATIVE}${bindir_native}/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')}"
+
+ user=`echo "$USERADD_PARAM" | cut -d ';' -f 1 | awk '{ print $NF }'`
+ remaining=`echo "$USERADD_PARAM" | cut -d ';' -f 2- -s | sed -e 's#[ \t]*$##'`
+ while test "x$user" != "x"; do
+ perform_userdel "${STAGING_DIR_TARGET}" "$OPT $user"
+ user=`echo "$remaining" | cut -d ';' -f 1 | awk '{ print $NF }'`
+ remaining=`echo "$remaining" | cut -d ';' -f 2- -s | sed -e 's#[ \t]*$##'`
+ done
+
+ user=`echo "$GROUPADD_PARAM" | cut -d ';' -f 1 | awk '{ print $NF }'`
+ remaining=`echo "$GROUPADD_PARAM" | cut -d ';' -f 2- -s | sed -e 's#[ \t]*$##'`
+ while test "x$user" != "x"; do
+ perform_groupdel "${STAGING_DIR_TARGET}" "$OPT $user"
+ user=`echo "$remaining" | cut -d ';' -f 1 | awk '{ print $NF }'`
+ remaining=`echo "$remaining" | cut -d ';' -f 2- -s | sed -e 's#[ \t]*$##'`
+ done
+
+ fi
+fi
+}
+
+SSTATECLEANFUNCS_append_class-target = " userdel_sysroot_sstate"
+
do_install[prefuncs] += "${SYSROOTFUNC}"
-SYSROOTFUNC = "useradd_sysroot"
-SYSROOTFUNC_class-cross = ""
-SYSROOTFUNC_class-native = ""
-SYSROOTFUNC_class-nativesdk = ""
-SSTATEPREINSTFUNCS += "${SYSROOTPOSTFUNC}"
-SYSROOTPOSTFUNC = "useradd_sysroot_sstate"
-SYSROOTPOSTFUNC_class-cross = ""
-SYSROOTPOSTFUNC_class-native = ""
-SYSROOTPOSTFUNC_class-nativesdk = ""
-
-USERADDSETSCENEDEPS = "${MLPREFIX}base-passwd:do_populate_sysroot_setscene pseudo-native:do_populate_sysroot_setscene shadow-native:do_populate_sysroot_setscene ${MLPREFIX}shadow-sysroot:do_populate_sysroot_setscene"
-USERADDSETSCENEDEPS_class-cross = ""
-USERADDSETSCENEDEPS_class-native = ""
-USERADDSETSCENEDEPS_class-nativesdk = ""
+SYSROOTFUNC_class-target = "useradd_sysroot"
+SYSROOTFUNC = ""
+
+SSTATEPREINSTFUNCS_append_class-target = " useradd_sysroot_sstate"
+
do_package_setscene[depends] += "${USERADDSETSCENEDEPS}"
do_populate_sysroot_setscene[depends] += "${USERADDSETSCENEDEPS}"
+USERADDSETSCENEDEPS_class-target = "${MLPREFIX}base-passwd:do_populate_sysroot_setscene pseudo-native:do_populate_sysroot_setscene shadow-native:do_populate_sysroot_setscene ${MLPREFIX}shadow-sysroot:do_populate_sysroot_setscene"
+USERADDSETSCENEDEPS = ""
# Recipe parse-time sanity checks
def update_useradd_after_parse(d):
@@ -174,7 +195,7 @@ def get_all_cmd_params(d, cmd_type):
for pkg in useradd_packages.split():
param = d.getVar(param_type % pkg, True)
if param:
- params.append(param)
+ params.append(param.rstrip(" ;"))
return "; ".join(params)