简体   繁体   English

如何在 Yocto 中更改文件所有权

[英]How to change file ownership in Yocto

I need to change file ownership in Yocto.我需要更改 Yocto 中的文件所有权。 I have a recipe that creates a directory.我有一个创建目录的食谱。 To create a new group and user I added in my image.bbappend:要创建我在 image.bbappend 中添加的新组和用户:

inherit extrausers  
EXTRA_USERS_PARAMS = " groupadd new_group; \
                       useradd  -g new_group -p '' new_user; \
                       usermod -a -G new_group root \
                     "

To add a new directory to my image I added to some_recipe.bbappend:要将新目录添加到我的图像中,我添加到 some_recipe.bbappend:

FILES_${PN} = "/dir1/dir2"
do_install_append() {
    install -d ${D}/dir1/dir2
}

When I try to use chown -R my_group.my_user /dir1/dir2 in the above do_install_append() task I get an error that such group and user does't exist.当我尝试在上述 do_install_append() 任务中使用chown -R my_group.my_user /dir1/dir2 ,我收到一个错误,指出此类组和用户不存在。 So next, I tried to add the above three lines to image.bbappend file.所以接下来,我尝试将上述三行添加到 image.bbappend 文件中。 I get no errors from bitbake but in the final image directory is still own by root.我没有从 bitbake 中得到任何错误,但在最终的图像目录中仍然由 root 拥有。

Try adding this in your .bbappend file:尝试将其添加到您的 .bbappend 文件中:

pkg_postinst_${PN}{
    chown -R user:group /dir1/dir2
}

I think that the problem is that you are trying to change the ownership of the file before Yocto has created the user.我认为问题在于您试图在 Yocto 创建用户之前更改文件的所有权。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM