summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jansa <Martin.Jansa@gmail.com>2020-10-09 01:00:46 +0200
committerMartin Jansa <Martin.Jansa@gmail.com>2020-11-20 15:29:03 +0100
commit5caf6cb6dbc3f0d8d806e95ff975f3ee2f610339 (patch)
treeb1da2699726a0d11d19d7c1331f123e162645b8f
parent6ed84d3522bb8b8908f0c93ab28b2b313203acaa (diff)
downloadopenembedded-core-contrib-jansa/gatesgarth.tar.gz
openembedded-core-contrib-jansa/gatesgarth.tar.bz2
openembedded-core-contrib-jansa/gatesgarth.zip
meta-skeleton: useradd-dep: add example of recipe using useradd and group created in other recipejansa/gatesgarth
* maybe this would be better in meta-selftest, I can move it there once we agree how this is supposed to work * https://www.openembedded.org/pipermail/bitbake-devel/2018-March/009256.html says that RDEPENDS_${PN} should be enough, but in my testing we need built time dependency as well for groups to exist early enough * and unfortunately even with the "useradd dependency" in DEPENDS is see very rare failures (in dunfell but I haven't found any changes in this area in master) when useradd-dep and useradd-example are reused from sstate. In these cases I've noticed that useradd-dep.do_package_setscene is running before useradd-example.do_package_setscene: NOTE: Running setscene task 268 of 3783 (useradd-dep.bb:do_package_write_ipk_setscene) NOTE: Running setscene task 269 of 3783 (useradd-dep.bb:do_populate_lic_setscene) NOTE: useradd-dep-1.0-r1: task do_package_write_ipk_setscene: Started NOTE: useradd-dep-1.0-r1: task do_populate_lic_setscene: Started NOTE: useradd-dep-1.0-r1: task do_package_write_ipk_setscene: Succeeded NOTE: Running setscene task 279 of 3783 (useradd-dep.bb:do_packagedata_setscene) NOTE: useradd-dep-1.0-r1: task do_populate_lic_setscene: Succeeded NOTE: useradd-dep-1.0-r1: task do_packagedata_setscene: Started NOTE: useradd-dep-1.0-r1: task do_packagedata_setscene: Succeeded NOTE: Running setscene task 3336 of 3783 (useradd-dep.bb:do_package_setscene) NOTE: Running setscene task 3337 of 3783 (useradd-dep.bb:do_populate_sysroot_setscene) NOTE: useradd-dep-1.0-r1: task do_package_setscene: Started NOTE: useradd-dep-1.0-r1: task do_populate_sysroot_setscene: Started ERROR: useradd-dep-1.0-r1 do_package_setscene: useradd-dep: useradd command did not succeed. ERROR: useradd-dep-1.0-r1 do_package_setscene: Error executing a python function in exec_python_func() autogenerated: ... Exception: bb.process.ExecutionError: Execution of 'useradd-dep/1.0-r1/temp/run.useradd_sysroot.8980' failed with exit code 1: useradd-dep/1.0-r1/recipe-sysroot-native/usr/sbin/useradd Running useradd commands... useradd: Warning: missing or non-executable shell '/bin/bash' useradd: group 'group1' does not exist WARNING: exit code 1 from a shell command. ... WARNING: Setscene task (useradd-dep.bb:do_package_setscene) failed with exit code '1' - real task will be run instead NOTE: Running setscene task 3347 of 3783 (useradd-example.bb:do_packagedata_setscene) NOTE: Running setscene task 3348 of 3783 (useradd-example.bb:do_populate_sysroot_setscene) NOTE: recipe useradd-example-1.0-r1: task do_packagedata_setscene: Started NOTE: recipe useradd-example-1.0-r1: task do_populate_sysroot_setscene: Started NOTE: recipe useradd-example-1.0-r1: task do_packagedata_setscene: Succeeded NOTE: Running setscene task 3358 of 3783 (useradd-example.bb:do_package_setscene) NOTE: recipe useradd-example-1.0-r1: task do_populate_sysroot_setscene: Succeeded NOTE: recipe useradd-example-1.0-r1: task do_package_setscene: Started NOTE: recipe useradd-example-1.0-r1: task do_package_setscene: Succeeded and then the real task works fine. Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
-rw-r--r--meta-skeleton/recipes-skeleton/useradd/useradd-dep.bb39
1 files changed, 39 insertions, 0 deletions
diff --git a/meta-skeleton/recipes-skeleton/useradd/useradd-dep.bb b/meta-skeleton/recipes-skeleton/useradd/useradd-dep.bb
new file mode 100644
index 0000000000..b5cbc5d170
--- /dev/null
+++ b/meta-skeleton/recipes-skeleton/useradd/useradd-dep.bb
@@ -0,0 +1,39 @@
+SUMMARY = "Example recipe for using inherit useradd and reusing group from useradd-example"
+DESCRIPTION = "This recipe serves as an example for using features from useradd.bbclass"
+SECTION = "examples"
+PR = "r1"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
+
+S = "${WORKDIR}"
+
+EXCLUDE_FROM_WORLD = "1"
+
+inherit useradd
+
+# https://www.openembedded.org/pipermail/bitbake-devel/2018-March/009256.html
+# says that RDEPENDS_${PN} should be enough, but in my testing we need
+# built time dependency as well for groups to exist early enough
+DEPENDS = "useradd-example"
+
+RDEPENDS_${PN} = "useradd-example"
+RDEPENDS_${PN}-user3 = "useradd-example-user3"
+
+# You must set USERADD_PACKAGES when you inherit useradd. This
+# lists which output packages will include the user/group
+# creation code.
+USERADD_PACKAGES = "${PN} ${PN}-user3"
+
+# USERADD_PARAM specifies command line options to pass to the
+# useradd command. Multiple users can be created by separating
+# the commands with a semicolon. Here we'll create two users,
+# user1 and user2:
+USERADD_PARAM_${PN} = "-u 2200 -d /home/user1dep -r -s /bin/bash -G group1 user1dep; -u 2201 -d /home/user2dep -r -s /bin/bash -G group2 user2dep"
+
+# user3 will be managed in the useradd-example-user3 pacakge:
+# As an example, we use the -P option to set clear text password for user3
+USERADD_PARAM_${PN}-user3 = "-u 2202 -d /home/user3dep -r -s /bin/bash -P 'user3' -G group3 user3dep"
+
+# Prevents do_package failures with:
+# debugsources.list: No such file or directory:
+INHIBIT_PACKAGE_DEBUG_SPLIT = "1"