主目录不是由 useradd-example.bb 创建的
我正在使用 useradd-example.bb 仅创建 user1
。 USERADD_PARAMS
建议应在 /home/user1
下创建主目录。
构建映像时,user1
按预期添加,目录 /usr/share/user
也具有正确的权限。但是,未创建 /home/user1
目录。实际上,我已经很惊讶 USERADD_PARAMS
中不需要指定诸如 -d ${D}/home/user1
之类的路径。
我是否必须使用适当的权限在 do_install
中手动添加路径?我是否从原始示例中删除了导致主目录丢失的某些内容,或者我是否必须在 USERADD_PARAM
中指定完整路径,例如 -d ${D}/home/user1?
这是被 user2
和 user3
部分剥离的示例(我发现这使示例过于复杂)。
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"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
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}"
# You must also set USERADD_PARAM and/or GROUPADD_PARAM when
# you inherit useradd.
# 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 1210 -d /home/user1 -r -s /bin/bash user1"
# GROUPADD_PARAM works the same way, which you set to the options
# you'd normally pass to the groupadd command. This will create
# groups group1 and group2:
GROUPADD_PARAM:${PN} = "-g 880 group1"
do_install () {
install -d -m 755 ${D}${datadir}/user1
# The new users and groups are created before the do_install
# step, so you are now free to make use of them:
chown -R user1 ${D}${datadir}/user1
chgrp -R group1 ${D}${datadir}/user1
}
FILES:${PN} = "${datadir}/user1 /usr/share/user1"
# Prevents do_package failures with:
# debugsources.list: No such file or directory:
INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
I'm using a modified version of the useradd-example.bb to create only user1
. The USERADD_PARAMS
suggest that a home directory should be created under /home/user1
.
When building the image, user1
is added as expected and so is the directory /usr/share/user
with the correct permissions. However, the /home/user1
directory is not created. Actually, I was already surprised that no specification of the path such as -d ${D}/home/user1
was needed in USERADD_PARAMS
.
Do I have to add the path manually in do_install
with the appropriate permissions? Did I strip something from the original example that caused the home directory gone missing or do I have to specify the full path in USERADD_PARAM
such as -d ${D}/home/user1
?
This is the example stripped by the user2
and user3
parts (which I find make the example overly complex).
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"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
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}"
# You must also set USERADD_PARAM and/or GROUPADD_PARAM when
# you inherit useradd.
# 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 1210 -d /home/user1 -r -s /bin/bash user1"
# GROUPADD_PARAM works the same way, which you set to the options
# you'd normally pass to the groupadd command. This will create
# groups group1 and group2:
GROUPADD_PARAM:${PN} = "-g 880 group1"
do_install () {
install -d -m 755 ${D}${datadir}/user1
# The new users and groups are created before the do_install
# step, so you are now free to make use of them:
chown -R user1 ${D}${datadir}/user1
chgrp -R group1 ${D}${datadir}/user1
}
FILES:${PN} = "${datadir}/user1 /usr/share/user1"
# Prevents do_package failures with:
# debugsources.list: No such file or directory:
INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定这是否是一种干净的方法,但我最终创建了主目录,如下所示:
重要的教训:如果您打算将文件从另一个配方移动到创建的主目录中,请确保您在那里创建的目录与此处设置的权限。否则,您将收到错误消息,指出存在冲突的目录。
I'm not sure if it's a clean way but I ended up creating the home directories as follows:
Important lesson learned: If you plan to move files into the created home directory from another recipe, make sure that the directories you create there match the permissions as they are set here. Otherwise you will get an error saying that there are conflicting directories.