summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEilís 'pidge' Ní Fhlannagáin <pidge@baylibre.com>2023-12-07 12:45:32 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-12-08 17:51:10 +0000
commitecef665062be55fcfa0915216335d08883aa86f7 (patch)
tree7526dc8da27cf82895da01ed0994cb1071e6bc91
parentd14eb12deb625e6644c0e727c336ad6bfafd0793 (diff)
downloadpoky-ecef665062be55fcfa0915216335d08883aa86f7.tar.gz
useradd: Fix issues with useradd dependencies
If recipe A requires the useradd actions of recipe B we need to ensure that recipe B is part of the recipe A dependancy chain. In order to do that, we introduce USERADD_DEPENDS. This makes sure that the do_populate_sysroot_setscene of recipe B exists for recipe A in case of a missing TMPDIR. This requires changes made in runqueue.py by RP. This commit along with the runqueue fixes effects: Bug 13419 - recipes that add users to groups cannot rely on other recipes creating those groups (when population from sstate happens) Bug 13904 - do_prepare_recipe_sysroot: postinst-useradd-* does not run in order of dependency and sometimes fails Bug 13279 - Make sure users/groups exist for package_write_* tasks Bug 15084 - For some reason using of same user in two recipes does not work properly I've included the start of self-testing for useradd by adding tests for 13419 (which ends up testing 13904, 13279, 15084 by virtue of them all having the same root cause) (From OE-Core rev: b47f2352376bd16b7e7087b4dab143403e67e094) Signed-off-by: Eilís 'pidge' Ní Fhlannagáin <pidge@baylibre.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta-selftest/recipes-test/selftest-users/creategroup1.bb32
-rw-r--r--meta-selftest/recipes-test/selftest-users/creategroup2.bb33
-rw-r--r--meta/classes/useradd.bbclass4
-rw-r--r--meta/lib/oeqa/selftest/cases/usergrouptests.py17
4 files changed, 85 insertions, 1 deletions
diff --git a/meta-selftest/recipes-test/selftest-users/creategroup1.bb b/meta-selftest/recipes-test/selftest-users/creategroup1.bb
new file mode 100644
index 0000000000..ebbbfaa83d
--- /dev/null
+++ b/meta-selftest/recipes-test/selftest-users/creategroup1.bb
@@ -0,0 +1,32 @@
1SUMMARY = "creategroup pt 1"
2LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
3
4LICENSE = "MIT"
5
6DEPENDS = "coreutils-native"
7
8S = "${WORKDIR}"
9
10inherit useradd allarch
11
12USERADD_PACKAGES = "${PN}"
13USERADD_PARAM:${PN} = "-u 5555 --gid grouptest gt1"
14GROUPADD_PARAM:${PN} = "-r grouptest"
15
16TESTDIR = "${D}${sysconfdir}/creategroup"
17
18do_install() {
19 install -d ${TESTDIR}
20 install -d ${TESTDIR}/dir
21 touch ${TESTDIR}/file
22 ln -s ./file ${TESTDIR}/symlink
23 install -d ${TESTDIR}/fifotest
24 mkfifo ${TESTDIR}/fifotest/fifo
25
26 chown gt1:grouptest ${TESTDIR}/file
27 chown -R gt1:grouptest ${TESTDIR}/dir
28 chown -h gt1:grouptest ${TESTDIR}/symlink
29 chown -R gt1:grouptest ${TESTDIR}/fifotest
30}
31
32FILES:${PN} = "${sysconfdir}/creategroup/*"
diff --git a/meta-selftest/recipes-test/selftest-users/creategroup2.bb b/meta-selftest/recipes-test/selftest-users/creategroup2.bb
new file mode 100644
index 0000000000..ef697f09b4
--- /dev/null
+++ b/meta-selftest/recipes-test/selftest-users/creategroup2.bb
@@ -0,0 +1,33 @@
1SUMMARY = "creategroup pt 2"
2LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
3
4LICENSE = "MIT"
5
6DEPENDS = "coreutils-native"
7USERADD_DEPENDS = "creategroup1"
8
9S = "${WORKDIR}"
10
11inherit useradd allarch
12
13USERADD_PACKAGES = "${PN}"
14USERADD_PARAM:${PN} = "-u 5556 --gid grouptest gt2"
15
16TESTDIR = "${D}${sysconfdir}/creategroup"
17
18do_install() {
19 install -d ${TESTDIR}
20 install -d ${TESTDIR}/dir
21 touch ${TESTDIR}/file
22 ln -s ./file ${TESTDIR}/symlink
23 install -d ${TESTDIR}/fifotest
24 mkfifo ${TESTDIR}/fifotest/fifo
25
26 chown gt2:grouptest ${TESTDIR}/file
27 chown -R gt2:grouptest ${TESTDIR}/dir
28 chown -h gt2:grouptest ${TESTDIR}/symlink
29 chown -R gt2:grouptest ${TESTDIR}/fifotest
30}
31
32FILES:${PN} = "${sysconfdir}/creategroup/*"
33
diff --git a/meta/classes/useradd.bbclass b/meta/classes/useradd.bbclass
index 4d3bd9a5f5..a4b8a2d6d6 100644
--- a/meta/classes/useradd.bbclass
+++ b/meta/classes/useradd.bbclass
@@ -177,9 +177,11 @@ SYSROOT_PREPROCESS_FUNCS += "${SYSROOTFUNC}"
177 177
178SSTATEPREINSTFUNCS:append:class-target = " useradd_sysroot_sstate" 178SSTATEPREINSTFUNCS:append:class-target = " useradd_sysroot_sstate"
179 179
180USERADD_DEPENDS ??= ""
181DEPENDS += "${USERADD_DEPENDS}"
180do_package_setscene[depends] += "${USERADDSETSCENEDEPS}" 182do_package_setscene[depends] += "${USERADDSETSCENEDEPS}"
181do_populate_sysroot_setscene[depends] += "${USERADDSETSCENEDEPS}" 183do_populate_sysroot_setscene[depends] += "${USERADDSETSCENEDEPS}"
182USERADDSETSCENEDEPS:class-target = "${MLPREFIX}base-passwd:do_populate_sysroot_setscene pseudo-native:do_populate_sysroot_setscene shadow-native:do_populate_sysroot_setscene ${MLPREFIX}shadow-sysroot:do_populate_sysroot_setscene" 184USERADDSETSCENEDEPS:class-target = "${MLPREFIX}base-passwd:do_populate_sysroot_setscene pseudo-native:do_populate_sysroot_setscene shadow-native:do_populate_sysroot_setscene ${MLPREFIX}shadow-sysroot:do_populate_sysroot_setscene ${@' '.join(['%s:do_populate_sysroot_setscene' % pkg for pkg in d.getVar("USERADD_DEPENDS").split()])}"
183USERADDSETSCENEDEPS = "" 185USERADDSETSCENEDEPS = ""
184 186
185# Recipe parse-time sanity checks 187# Recipe parse-time sanity checks
diff --git a/meta/lib/oeqa/selftest/cases/usergrouptests.py b/meta/lib/oeqa/selftest/cases/usergrouptests.py
new file mode 100644
index 0000000000..98e8102590
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/usergrouptests.py
@@ -0,0 +1,17 @@
1#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7from oeqa.selftest.case import OESelftestTestCase
8from oeqa.utils.commands import bitbake
9
10class UserGroupTests(OESelftestTestCase):
11 def test_group_from_dep_package(self):
12 self.logger.info("Building creategroup2")
13 bitbake(' creategroup2 creategroup1')
14 bitbake(' creategroup2 creategroup1 -c clean')
15 self.logger.info("Packaging creategroup2")
16 self.assertTrue(bitbake(' creategroup2 -c package'))
17