|
@@ -106,6 +106,21 @@ useradd_sysroot () {
|
|
|
# before do_prepare_recipe_sysroot
|
|
|
D=${STAGING_DIR_TARGET}
|
|
|
|
|
|
+ # base-passwd's postinst may not have run yet in which case we'll get called later, just exit.
|
|
|
+ # Beware that in some cases we might see the fake pseudo passwd here, in which case we also must
|
|
|
+ # exit.
|
|
|
+ if [ ! -f $D${sysconfdir}/passwd ] ||
|
|
|
+ grep -q this-is-the-pseudo-passwd $D${sysconfdir}/passwd; then
|
|
|
+ exit 0
|
|
|
+ fi
|
|
|
+
|
|
|
+ # It is also possible we may be in a recipe which doesn't have useradd dependencies and hence the
|
|
|
+ # useradd/groupadd tools are unavailable. If there is no dependency, we assume we don't want to
|
|
|
+ # create users in the sysroot
|
|
|
+ if ! command -v useradd; then
|
|
|
+ exit 0
|
|
|
+ fi
|
|
|
+
|
|
|
# Add groups and users defined for all recipe packages
|
|
|
GROUPADD_PARAM="${@get_all_cmd_params(d, 'groupadd')}"
|
|
|
USERADD_PARAM="${@get_all_cmd_params(d, 'useradd')}"
|
|
@@ -122,6 +137,7 @@ python useradd_sysroot_sstate () {
|
|
|
if task == "package_setscene":
|
|
|
bb.build.exec_func("useradd_sysroot", d)
|
|
|
elif task == "prepare_recipe_sysroot":
|
|
|
+ # Used to update this recipe's own sysroot so the user/groups are available to do_install
|
|
|
scriptfile = d.expand("${RECIPE_SYSROOT}${bindir}/postinst-useradd-${PN}")
|
|
|
bb.utils.mkdirhier(os.path.dirname(scriptfile))
|
|
|
with open(scriptfile, 'w') as script:
|
|
@@ -130,12 +146,23 @@ python useradd_sysroot_sstate () {
|
|
|
script.write("useradd_sysroot\n")
|
|
|
os.chmod(scriptfile, 0o755)
|
|
|
bb.build.exec_func("useradd_sysroot", d)
|
|
|
+ elif task == "populate_sysroot":
|
|
|
+ # Used when installed in dependent task sysroots
|
|
|
+ scriptfile = d.expand("${SYSROOT_DESTDIR}${bindir}/postinst-useradd-${PN}")
|
|
|
+ bb.utils.mkdirhier(os.path.dirname(scriptfile))
|
|
|
+ with open(scriptfile, 'w') as script:
|
|
|
+ script.write("#!/bin/sh\n")
|
|
|
+ bb.data.emit_func("useradd_sysroot", script, d)
|
|
|
+ script.write("useradd_sysroot\n")
|
|
|
+ os.chmod(scriptfile, 0o755)
|
|
|
}
|
|
|
|
|
|
do_prepare_recipe_sysroot[postfuncs] += "${SYSROOTFUNC}"
|
|
|
SYSROOTFUNC_class-target = "useradd_sysroot_sstate"
|
|
|
SYSROOTFUNC = ""
|
|
|
|
|
|
+SYSROOT_PREPROCESS_FUNCS += "${SYSROOTFUNC}"
|
|
|
+
|
|
|
SSTATEPREINSTFUNCS_append_class-target = " useradd_sysroot_sstate"
|
|
|
|
|
|
do_package_setscene[depends] += "${USERADDSETSCENEDEPS}"
|