[OE-core] [PATCH] useradd.bbclass: Make sure users/groups exist for package_write_* tasks

Peter Kjellerstedt peter.kjellerstedt at axis.com
Wed Apr 3 12:26:26 UTC 2019


If the populate_lic task and any of the package_write_* tasks need to
run, but the package task can be restored from the sstate cache, then
the fetch task, which is a dependency of populate_lic, will wipe out
the RSS including any users/groups that have been created. This
results in that the package_write_* tasks are run without any
user/group information, which causes them to fallback to either use
the root user for any unknown users/groups (rpm) or to use the numeric
UIDs/GIDs (deb/ipk). Neither solution will yield correct packages.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt at axis.com>
---
 meta/classes/useradd.bbclass | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/meta/classes/useradd.bbclass b/meta/classes/useradd.bbclass
index 124becd082..e32315a1af 100644
--- a/meta/classes/useradd.bbclass
+++ b/meta/classes/useradd.bbclass
@@ -4,7 +4,7 @@ inherit useradd_base
 # target sysroot, and shadow -native and -sysroot provide the utilities
 # and support files needed to add and modify user and group accounts
 DEPENDS_append_class-target = " base-files shadow-native shadow-sysroot shadow base-passwd"
-PACKAGE_WRITE_DEPS += "shadow-native"
+PACKAGE_WRITE_DEPS += "shadow-native shadow-sysroot base-passwd"
 
 # This preinstall function can be run in four different contexts:
 #
@@ -144,7 +144,10 @@ python useradd_sysroot_sstate () {
     task = d.getVar("BB_CURRENTTASK")
     if task == "package_setscene":
         bb.build.exec_func("useradd_sysroot", d)
-    elif task == "prepare_recipe_sysroot":
+    elif (task == "prepare_recipe_sysroot" or
+          task == "package_write_deb" or
+          task == "package_write_ipk" or
+          task == "package_write_rpm"):
         # 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.build.exec_func("useradd_sysroot", d)
@@ -161,13 +164,16 @@ python useradd_sysroot_sstate () {
         os.chmod(scriptfile, 0o755)
 }
 
-do_prepare_recipe_sysroot[postfuncs] += "${SYSROOTFUNC}"
-SYSROOTFUNC_class-target = "useradd_sysroot_sstate"
 SYSROOTFUNC = ""
+SYSROOTFUNC_class-target = "useradd_sysroot_sstate"
 
-SYSROOT_PREPROCESS_FUNCS += "${SYSROOTFUNC}"
+do_prepare_recipe_sysroot[postfuncs] += "${SYSROOTFUNC}"
+do_package_write_deb[prefuncs] += "${SYSROOTFUNC}"
+do_package_write_ipk[prefuncs] += "${SYSROOTFUNC}"
+do_package_write_rpm[prefuncs] += "${SYSROOTFUNC}"
 
-SSTATEPREINSTFUNCS_append_class-target = " useradd_sysroot_sstate"
+SYSROOT_PREPROCESS_FUNCS += "${SYSROOTFUNC}"
+SSTATEPREINSTFUNCS += "${SYSROOTFUNC}"
 
 do_package_setscene[depends] += "${USERADDSETSCENEDEPS}"
 do_populate_sysroot_setscene[depends] += "${USERADDSETSCENEDEPS}"
-- 
2.12.0



More information about the Openembedded-core mailing list