summaryrefslogtreecommitdiffstats
path: root/meta/classes/useradd.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/useradd.bbclass')
-rw-r--r--meta/classes/useradd.bbclass27
1 files changed, 27 insertions, 0 deletions
diff --git a/meta/classes/useradd.bbclass b/meta/classes/useradd.bbclass
index 1f7afa4f8e..4373677bd6 100644
--- a/meta/classes/useradd.bbclass
+++ b/meta/classes/useradd.bbclass
@@ -106,6 +106,21 @@ useradd_sysroot () {
106 # before do_prepare_recipe_sysroot 106 # before do_prepare_recipe_sysroot
107 D=${STAGING_DIR_TARGET} 107 D=${STAGING_DIR_TARGET}
108 108
109 # base-passwd's postinst may not have run yet in which case we'll get called later, just exit.
110 # Beware that in some cases we might see the fake pseudo passwd here, in which case we also must
111 # exit.
112 if [ ! -f $D${sysconfdir}/passwd ] ||
113 grep -q this-is-the-pseudo-passwd $D${sysconfdir}/passwd; then
114 exit 0
115 fi
116
117 # It is also possible we may be in a recipe which doesn't have useradd dependencies and hence the
118 # useradd/groupadd tools are unavailable. If there is no dependency, we assume we don't want to
119 # create users in the sysroot
120 if ! command -v useradd; then
121 exit 0
122 fi
123
109 # Add groups and users defined for all recipe packages 124 # Add groups and users defined for all recipe packages
110 GROUPADD_PARAM="${@get_all_cmd_params(d, 'groupadd')}" 125 GROUPADD_PARAM="${@get_all_cmd_params(d, 'groupadd')}"
111 USERADD_PARAM="${@get_all_cmd_params(d, 'useradd')}" 126 USERADD_PARAM="${@get_all_cmd_params(d, 'useradd')}"
@@ -122,6 +137,7 @@ python useradd_sysroot_sstate () {
122 if task == "package_setscene": 137 if task == "package_setscene":
123 bb.build.exec_func("useradd_sysroot", d) 138 bb.build.exec_func("useradd_sysroot", d)
124 elif task == "prepare_recipe_sysroot": 139 elif task == "prepare_recipe_sysroot":
140 # Used to update this recipe's own sysroot so the user/groups are available to do_install
125 scriptfile = d.expand("${RECIPE_SYSROOT}${bindir}/postinst-useradd-${PN}") 141 scriptfile = d.expand("${RECIPE_SYSROOT}${bindir}/postinst-useradd-${PN}")
126 bb.utils.mkdirhier(os.path.dirname(scriptfile)) 142 bb.utils.mkdirhier(os.path.dirname(scriptfile))
127 with open(scriptfile, 'w') as script: 143 with open(scriptfile, 'w') as script:
@@ -130,12 +146,23 @@ python useradd_sysroot_sstate () {
130 script.write("useradd_sysroot\n") 146 script.write("useradd_sysroot\n")
131 os.chmod(scriptfile, 0o755) 147 os.chmod(scriptfile, 0o755)
132 bb.build.exec_func("useradd_sysroot", d) 148 bb.build.exec_func("useradd_sysroot", d)
149 elif task == "populate_sysroot":
150 # Used when installed in dependent task sysroots
151 scriptfile = d.expand("${SYSROOT_DESTDIR}${bindir}/postinst-useradd-${PN}")
152 bb.utils.mkdirhier(os.path.dirname(scriptfile))
153 with open(scriptfile, 'w') as script:
154 script.write("#!/bin/sh\n")
155 bb.data.emit_func("useradd_sysroot", script, d)
156 script.write("useradd_sysroot\n")
157 os.chmod(scriptfile, 0o755)
133} 158}
134 159
135do_prepare_recipe_sysroot[postfuncs] += "${SYSROOTFUNC}" 160do_prepare_recipe_sysroot[postfuncs] += "${SYSROOTFUNC}"
136SYSROOTFUNC_class-target = "useradd_sysroot_sstate" 161SYSROOTFUNC_class-target = "useradd_sysroot_sstate"
137SYSROOTFUNC = "" 162SYSROOTFUNC = ""
138 163
164SYSROOT_PREPROCESS_FUNCS += "${SYSROOTFUNC}"
165
139SSTATEPREINSTFUNCS_append_class-target = " useradd_sysroot_sstate" 166SSTATEPREINSTFUNCS_append_class-target = " useradd_sysroot_sstate"
140 167
141do_package_setscene[depends] += "${USERADDSETSCENEDEPS}" 168do_package_setscene[depends] += "${USERADDSETSCENEDEPS}"