2

I have two recipes, the first, adduser, is based on the useradd example in the meta-skeleton layer, and creates the directory /home/foo/, for the user foo:

SUMMARY = "Example recipe for using inherit useradd"
DESCRIPTION = "This recipe serves as an example for using features from useradd.bbclass"
SECTION = "examples"
PR = "r1"
LICENSE = "MIT"

S = "${WORKDIR}"

inherit useradd

# You must set USERADD_PACKAGES when you inherit useradd. This
# lists which output packages will include the user/group
# creation code.
USERADD_PACKAGES = "${PN}"

USERADD_PARAM_${PN} = "-d /home/foo -r -s /bin/bash -p 'bar' foo"

do_install () {
        install -d -m 755 ${D}/usr/share/foo
        install -d -m 755 ${D}/home/foo
    chown -R foo ${D}/usr/share/foo
    chown -R foo ${D}/home/foo
}

FILES_${PN} = "/usr/share/foo /home/foo"

# Prevents do_package failures with:
# debugsources.list: No such file or directory:
INHIBIT_PACKAGE_DEBUG_SPLIT = "1"

I then have a second recipe, which should add the directory "code" to the user's home directory, and put a file in it:

LICENSE = "CLOSED"

DEPENDS = "adduser"

FILES_${PN} += "/home/foo/code /home/foo/code/base_reading.py"

SRC_URI = "file://base_reading.py \
"

S = "${WORKDIR}"

do_install() {
    install -d ${D}/home/foo/code
    install -m 0755 ${S}/base_reading.py ${D}/home/foo/code/base_reading.py
    chown -R foo ${D}/home/foo/code
}

This is the whole error: https://paste.ubuntu.com/p/6bfH4vf8qw but the TL;DR is:

Error: Transaction check error:
  file /home/foo conflicts between attempted installs of basecode-1.0-r0.cortexa7hf_neon_vfpv4 and adduser-1.0-r1.cortexa7hf_neon_vfpv4

At first, I tried to fix this by adding the DEPENDS = "adduser", thinking that that would ensure that /home/foo exists before it tries to create /home/foo/code, but it didn't make any difference.

Alex
  • 2,270
  • 3
  • 33
  • 65
  • I added both recipes and built an image from it. It worked. Maybe you run cleansstate on both recipes and remove yout ${TMPDIR} before rerunning the build. Another point is that a DEPENDS is evaluated at built-time. I guess you want to automatically have *adduser* installed, when *basecode* installed in an image. Therefor use RDEPENDS_${PN} – guenni_90 Nov 25 '18 at 17:33
  • 1
    Thank you, but it turns out that adding DIRFILES = "1" to the second recipe works, as it apparently stops it trying to recursively create the directories above it. There is another issue, though, the code directory is owned by root. The chown line seems to not work – Alex Nov 25 '18 at 17:37
  • Well, that's fine. Do you have a solution for that *chown * problem? One idea i followed a bit was moving chown from *install* to *pkg_postinst_${PN}*. Somehow it didn't work, but maybe *pkg_postinst_ontarget_${PN}* is a quick and dirty solution for you – guenni_90 Nov 25 '18 at 19:20
  • DIRFILES is the actual answer, as stated here: https://stackoverflow.com/a/44763692/145413 – AI0867 May 10 '22 at 09:45

1 Answers1

0

You need to add DIRFILES = "1" to one of the recipes. This will cause the recipe to not own the directories it uses.

More information can be found here