我有两个秘诀,第一个是adduser,它是基于meta-skeleton层中的useradd示例的,并为用户foo创建了目录/ home / 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"
然后我有了第二个配方,应该将目录“代码”添加到用户的主目录,并在其中放置文件:
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
}
这是整个错误:https://paste.ubuntu.com/p/6bfH4vf8qw,但TL; DR是:
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
起初,我尝试通过添加DEPENDS = "adduser"
来解决此问题,认为这样做可以确保/home/foo
在尝试创建/home/foo/code
之前就已经存在,但是它没有做出任何贡献差异。