]> code.ossystems Code Review - openembedded-core.git/commitdiff
useradd.bbclass: Unify writing of script file in useradd_sysroot_sstate()
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>
Fri, 15 Sep 2017 14:48:59 +0000 (16:48 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 18 Sep 2017 10:07:24 +0000 (11:07 +0100)
There were two identical code blocks for writing the
postinst-useradd-${PN} scripts. This combines them into one.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
meta/classes/useradd.bbclass

index 0f51e5522b1d60159fc521c0a91a09c47959841c..686e5fbefe7e5f6f44aa06a15b49f5a3fc0b2b26 100644 (file)
@@ -138,22 +138,19 @@ useradd_sysroot () {
 EXTRA_STAGING_FIXMES += "COMPONENTS_DIR"
 
 python useradd_sysroot_sstate () {
+    scriptfile = None
     task = d.getVar("BB_CURRENTTASK")
     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:
-            script.write("#!/bin/sh\n")
-            bb.data.emit_func("useradd_sysroot", script, d)
-            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}")
+
+    if scriptfile:
         bb.utils.mkdirhier(os.path.dirname(scriptfile))
         with open(scriptfile, 'w') as script:
             script.write("#!/bin/sh\n")