Re: [yocto] Correct way for multiple recipes to install files in the same directory

2024-04-13 Thread Linus Nilsson
As I have no prior experience with classes I'll have to read through the manual 
to learn and I'll have that in mind, cheers. 

Från: Markus Volk 
Skickat: den 13 april 2024 00:48
Till: yocto@lists.yoctoproject.org ; 
linusnils...@hotmail.com 
Ämne: Re: [yocto] Correct way for multiple recipes to install files in the same 
directory

On Fri, Apr 12 2024 at 09:14:45 AM -07:00:00, Linus Nilsson 
 wrote:
I haven't worked with the classes yet but I can see how they can be used to 
make things a lot easier in my case.

But don't use classen too invasively. They can be problematic, e.g. an :append 
may be ignored depending on the BBFILE_PRIORITY of a layer

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#62927): https://lists.yoctoproject.org/g/yocto/message/62927
Mute This Topic: https://lists.yoctoproject.org/mt/105458437/21656
Group Owner: yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [yocto] Correct way for multiple recipes to install files in the same directory

2024-04-12 Thread Markus Volk
On Fri, Apr 12 2024 at 09:14:45 AM -07:00:00, Linus Nilsson 
 wrote:
I haven't worked with the classes yet but I can see how they can be 
used to make things a lot easier in my case.


But don't use classen too invasively. They can be problematic, e.g. an 
:append may be ignored depending on the BBFILE_PRIORITY of a layer



-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#62926): https://lists.yoctoproject.org/g/yocto/message/62926
Mute This Topic: https://lists.yoctoproject.org/mt/105458437/21656
Group Owner: yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [yocto] Correct way for multiple recipes to install files in the same directory

2024-04-12 Thread Linus Nilsson
I found a solution and I'll try to break it down. There was the original 
problem with the conflict between the recipes and then there were the problem 
with the recipe not being aware of the existence of the user polkitd.

The solution for the first problem was to make sure that the permissions and 
ownership set by my recipe 2 matches the one in recipe 1 exactly, hence:
> 
> 
> Changing in recipe 2 from
> chown -R user1:user1 ${D}/home/user1/.config/
> to
> chown -R user1:user1 ${D}/home/user1/
> actually seems to solve the problem with those particular recipes.

The solution to the second problem (disk-automount recipe bitbake error because 
user polkitd is invalid) was to copy the creation of the user polkitd from the 
original polkit recipe into my recipe:
inherit useradd
USERADD_PACKAGES = "${PN}"
USERADD_PARAM:${PN} = "--system --no-create-home --user-group --home-dir 
${sysconfdir}/${BPN}-1 --shell /bin/nologin polkitd"

and then make sure that my disk-automount recipe matches the permissions and 
ownerships set up by the polkit recipe as well:
do_install:append() {
#Fix up permissions on polkit rules.d to work with rpm4 constraints
chmod 700 ${D}/${datadir}/polkit-1/rules.d
chmod 700 ${D}/${sysconfdir}/polkit-1/rules.d
chown polkitd:root ${D}/${datadir}/polkit-1/rules.d
chown polkitd:root ${D}/${sysconfdir}/polkit-1/rules.d
}

This is working but I can see some issues with copying code from one recipe to 
another. If the original recipe changes, I will need to manually update every 
one of my own recipes with the corresponding changes, which doesn't scale very 
well. Having this in mind I think that Markus Volk's post might be a nicer way 
to do things so I think I will consider his way of doing it in the future. I 
haven't worked with the classes yet but I can see how they can be used to make 
things a lot easier in my case.

Big thanks and great appreciation to everyone who came up with suggestions, 
they eventually led me towards a solution! :)

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#62925): https://lists.yoctoproject.org/g/yocto/message/62925
Mute This Topic: https://lists.yoctoproject.org/mt/105458437/21656
Group Owner: yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [yocto] Correct way for multiple recipes to install files in the same directory

2024-04-12 Thread linusnilsson
> 
> Obvious solution is to copy chmod command to your recipe.

Yes and I did that but that line alone didn't suffice. I also had to copy the 
'chown'-line but since the polkit user was created in another recipe it is not 
recognized in this recipe and so I have to somehow figure out a way to fix that.

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#62924): https://lists.yoctoproject.org/g/yocto/message/62924
Mute This Topic: https://lists.yoctoproject.org/mt/105458437/21656
Group Owner: yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [yocto] Correct way for multiple recipes to install files in the same directory

2024-04-11 Thread Peter Marko via lists.yoctoproject.org
Obvious solution is to copy chmod command to your recipe.
Peter

From: linusnilsson via Lists.Yoctoproject.Org 

Sent: Thursday, April 11, 2024 14:38
To: Marko, Peter (ADV D EU SK BFS1) ; 
yocto@lists.yoctoproject.org
Subject: Re: [yocto] Correct way for multiple recipes to install files in the 
same directory

> Changing in recipe 2 from
> chown -R user1:user1 ${D}/home/user1/.config/
> to
> chown -R user1:user1 ${D}/home/user1
> actually seems to solve the problem with those particular recipes.
>
> After getting a bit further in the bitbake process I now have the same 
> problem with another recipe that wants to add custom files to 
> /etc/polkit-1/rules.d/ but this recipe doesn't contain any 'chown' statement 
> so I can't apply the same solution here.
> file /etc/polkit-1/rules.d conflicts between attempted installs of 
> disk-automount-0.1-r0.core2_64 and polkit-124-r0.core2_64
>
> disk-automount-0.1 recipe contains:
> do_install(){
>  install -d ${D}/${sysconfdir}/polkit-1/rules.d
>  install -m 0644 ${S}/00-mount-internal.rules 
> ${D}/${sysconfdir}/polkit-1/rules.d
> }
>
> polkit-124 recipe contains:
> do_install:append() {
>  #Fix up permissions on polkit rules.d to work with rpm4 constraints
>  chmod 700 ${D}/${datadir}/polkit-1/rules.d
>  chmod 700 ${D}/${sysconfdir}/polkit-1/rules.d
>  chown polkitd:root ${D}/${datadir}/polkit-1/rules.d
>  chown polkitd:root ${D}/${sysconfdir}/polkit-1/rules.d
> }
>
> Since polkit is maintained by yocto I want to avoid making changes to it but 
> rather adapt my disk-automount recipe somehow since the problem probably is 
> on my end.
> IIRC install -d will set the permissions to 0755 unless otherwise specified 
> which might conflict with polkit's chmod 700 so I might try copying chmod 700 
> ${D}/${sysconfdir}/polkit-1/rules.d to my disk-automount recipe.

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#62921): https://lists.yoctoproject.org/g/yocto/message/62921
Mute This Topic: https://lists.yoctoproject.org/mt/105458437/21656
Group Owner: yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [yocto] Correct way for multiple recipes to install files in the same directory

2024-04-11 Thread linusnilsson
After adding
chmod 700 ${D}/${sysconfdir}/polkit-1/rules.d
chown polkit:root ${D}/${sysconfdir}/polkit-1/rules.d
to the disk-automount recipe I get error with chown not knowing about the 
polkit user, even though I've added polkit to both DEPENDS and RDEPENDS of 
disk-automount recipe so now I've got figure out how to make it aware that the 
user polkit exists.

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#62919): https://lists.yoctoproject.org/g/yocto/message/62919
Mute This Topic: https://lists.yoctoproject.org/mt/105458437/21656
Group Owner: yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [yocto] Correct way for multiple recipes to install files in the same directory

2024-04-11 Thread linusnilsson
Changing in recipe 2 from
chown -R user1:user1 ${D}/home/user1/.config/
to
chown -R user1:user1 ${D}/home/user1
actually seems to solve the problem with those particular recipes.

After getting a bit further in the bitbake process I now have the same problem 
with another recipe that wants to add custom files to /etc/polkit-1/rules.d/ 
but this recipe doesn't contain any 'chown' statement so I can't apply the same 
solution here.
file /etc/polkit-1/rules.d conflicts between attempted installs of 
disk-automount-0.1-r0.core2_64 and polkit-124-r0.core2_64

disk-automount-0.1 recipe contains:
do_install(){
install -d ${D}/${sysconfdir}/polkit-1/rules.d
install -m 0644 ${S}/00-mount-internal.rules ${D}/${sysconfdir}/polkit-1/rules.d
}

polkit-124 recipe contains:
do_install:append() {
#Fix up permissions on polkit rules.d to work with rpm4 constraints
chmod 700 ${D}/${datadir}/polkit-1/rules.d
chmod 700 ${D}/${sysconfdir}/polkit-1/rules.d
chown polkitd:root ${D}/${datadir}/polkit-1/rules.d
chown polkitd:root ${D}/${sysconfdir}/polkit-1/rules.d
}

Since polkit is maintained by yocto I want to avoid making changes to it but 
rather adapt my disk-automount recipe somehow since the problem probably is on 
my end.
IIRC install -d will set the permissions to 0755 unless otherwise specified 
which might conflict with polkit's chmod 700 so I might try copying chmod 700 
${D}/${sysconfdir}/polkit-1/rules.d to my disk-automount recipe.

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#62918): https://lists.yoctoproject.org/g/yocto/message/62918
Mute This Topic: https://lists.yoctoproject.org/mt/105458437/21656
Group Owner: yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [yocto] Correct way for multiple recipes to install files in the same directory

2024-04-11 Thread Peter Marko via lists.yoctoproject.org
From: yocto@lists.yoctoproject.org  On Behalf Of 
linusnilsson via lists.yoctoproject.org
Sent: Thursday, April 11, 2024 9:53
To: yocto@lists.yoctoproject.org
Subject: [yocto] Correct way for multiple recipes to install files in the same 
directory


> Hi!
> How/can I let multiple recipes install files in the same directory without 
> getting a conflict during bitbake process?
>
> Recipe 1 creates a user and its homedir:
> inherit useradd
> USERADD_PACKAGES = "${PN}"
> USERADD_PARAM:${PN} = "-u 1000 -d /home/user1 -m -s /bin/bash -p 'XXX' user1"
> do_install(){
>  install -d ${D}/home/user1
>  chown -R user1:user1 ${D}/home/user1
> }
>
> Recipe 2 wants to install some config-files inside /home/user1/.config/.
> DEPENDS = "recipe1"
> RDEPENDS:${PN} = "recipe1"
> do_install(){
>  install -d ${D}/home/user1/.config/
>  install -m 0644 sourcefile ${D}/home/user1/.config/
>  chown -R user1:user1 ${D}/home/user1/.config/

Have you tried to change this line to

chown -R user1:user1 ${D}/home/user1

The error may come from fact that directory /home/user1 has different ownership 
in both recipes
> }
>
> There is also FILES directives at the end of each recipe for the 
> corresponding files. For better readability I've removed everything that I 
> deemed was irrelevant.
> The problem I get when trying to bitbake the image is during the do_rootfs 
> stage:
> file /home/user1 conflicts between attempted installs of  and 
> 
>
> If I comment out the "chown" line from both recipes it seems to work but then 
> I guess those directories will be owned by root during runtime, which will be 
> a problem for user1.
>
> Is there a proper way to do this?
>
> Kind regards, Linus

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#62916): https://lists.yoctoproject.org/g/yocto/message/62916
Mute This Topic: https://lists.yoctoproject.org/mt/105458437/21656
Group Owner: yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [yocto] Correct way for multiple recipes to install files in the same directory

2024-04-11 Thread Markus Volk
On Thu, Apr 11 2024 at 12:52:49 AM -07:00:00, linusnils...@hotmail.com 
wrote:

Is there a proper way to do this?

Kind regards, Linus


Hi,
can't tell if this would be a proper way, but this is how I do it and 
what works for me:


Create a main user:


Inherit a main-user class for every recipe that wants to write stuff to 
/home/user



You can override the values set in main-user.bbclass to fit your needs 
in e.g. local.conf


Regards,
Markus



-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#62915): https://lists.yoctoproject.org/g/yocto/message/62915
Mute This Topic: https://lists.yoctoproject.org/mt/105458437/21656
Group Owner: yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-