All of lore.kernel.org
 help / color / mirror / Atom feed
* How to create a directory in multiple packages?
@ 2020-12-14 17:43 Peter Kjellerstedt
  2020-12-14 17:46 ` [OE-core] " Robert P. J. Day
  2020-12-15  1:01 ` Mark Hatle
  0 siblings, 2 replies; 6+ messages in thread
From: Peter Kjellerstedt @ 2020-12-14 17:43 UTC (permalink / raw)
  To: OE Core (openembedded-core@lists.openembedded.org)

Say we have a recipe that creates an empty /etc/foo directory. Now we 
want to add a new file in that directory /etc/foo/bar and package it as 
${PN}-bar. This means the creation of the /etc/foo directory is moved 
from the ${PN} package to the ${PN}-bar package. Is there any way to 
make ${PN} continue to create an empty /etc/foo, or is the only 
alternative to introduce an /etc/foo/.dummy and package it in ${PN}?

//Peter


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [OE-core] How to create a directory in multiple packages?
  2020-12-14 17:43 How to create a directory in multiple packages? Peter Kjellerstedt
@ 2020-12-14 17:46 ` Robert P. J. Day
  2020-12-14 18:20   ` Konrad Weihmann
  2020-12-15  1:01 ` Mark Hatle
  1 sibling, 1 reply; 6+ messages in thread
From: Robert P. J. Day @ 2020-12-14 17:46 UTC (permalink / raw)
  To: Peter Kjellerstedt; +Cc: OE Core (openembedded-core@lists.openembedded.org)

On Mon, 14 Dec 2020, Peter Kjellerstedt wrote:

> Say we have a recipe that creates an empty /etc/foo directory. Now we
> want to add a new file in that directory /etc/foo/bar and package it as
> ${PN}-bar. This means the creation of the /etc/foo directory is moved
> from the ${PN} package to the ${PN}-bar package. Is there any way to
> make ${PN} continue to create an empty /etc/foo, or is the only
> alternative to introduce an /etc/foo/.dummy and package it in ${PN}?

  it strikes me that creating an empty directory for no other reason
than creating an empty directory is less-than-optimal design. the
proper approach is that all file installation should create
directories as needed.

rday

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [OE-core] How to create a directory in multiple packages?
  2020-12-14 17:46 ` [OE-core] " Robert P. J. Day
@ 2020-12-14 18:20   ` Konrad Weihmann
  0 siblings, 0 replies; 6+ messages in thread
From: Konrad Weihmann @ 2020-12-14 18:20 UTC (permalink / raw)
  To: openembedded-core; +Cc: peter.kjellerstedt

Clearly an empty dir seems to be sub-optimal design, but if one would 
need it, I'd recommend to add a pkg_postinst_${PN} script and 
dynamically determine at installation time if this path needs to be 
created or not.
So the dir either will be create by ${PN}-bin or by the script - I think 
I've seen at a couple of times like that

On 14.12.20 18:46, Robert P. J. Day wrote:
> On Mon, 14 Dec 2020, Peter Kjellerstedt wrote:
> 
>> Say we have a recipe that creates an empty /etc/foo directory. Now we
>> want to add a new file in that directory /etc/foo/bar and package it as
>> ${PN}-bar. This means the creation of the /etc/foo directory is moved
>> from the ${PN} package to the ${PN}-bar package. Is there any way to
>> make ${PN} continue to create an empty /etc/foo, or is the only
>> alternative to introduce an /etc/foo/.dummy and package it in ${PN}?
> 
>    it strikes me that creating an empty directory for no other reason
> than creating an empty directory is less-than-optimal design. the
> proper approach is that all file installation should create
> directories as needed.
> 
> rday
> 
> 
> 
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [OE-core] How to create a directory in multiple packages?
  2020-12-14 17:43 How to create a directory in multiple packages? Peter Kjellerstedt
  2020-12-14 17:46 ` [OE-core] " Robert P. J. Day
@ 2020-12-15  1:01 ` Mark Hatle
  2020-12-15 14:24   ` Peter Kjellerstedt
  1 sibling, 1 reply; 6+ messages in thread
From: Mark Hatle @ 2020-12-15  1:01 UTC (permalink / raw)
  To: openembedded-core



On 12/14/20 11:43 AM, Peter Kjellerstedt wrote:
> Say we have a recipe that creates an empty /etc/foo directory. Now we 
> want to add a new file in that directory /etc/foo/bar and package it as 
> ${PN}-bar. This means the creation of the /etc/foo directory is moved 
> from the ${PN} package to the ${PN}-bar package. Is there any way to 
> make ${PN} continue to create an empty /etc/foo, or is the only 
> alternative to introduce an /etc/foo/.dummy and package it in ${PN}?

try adjust the order of the PACKAGES variant.  Something like:

PACKAGES = "${PN}-bar ... ${PN}"

FILES_${PN}-bar = "/etc/foo/bar"
FILES_${PN} = "/etc/foo"

That SHOULD package the file 'bar' in -bar, and the directory in ${PN}.

(Some of the people commenting this isn't less then optimal, actually it's not
that unusual.. Typical case I see is creating a directory in /var or /usr/share
for datafiles and the main package owns the directory, with sub-packages [or
other packages] contributing data into that directory.)

--Mark

> //Peter
> 
> 
> 
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [OE-core] How to create a directory in multiple packages?
  2020-12-15  1:01 ` Mark Hatle
@ 2020-12-15 14:24   ` Peter Kjellerstedt
  2020-12-15 22:05     ` Mark Hatle
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Kjellerstedt @ 2020-12-15 14:24 UTC (permalink / raw)
  To: Mark Hatle, openembedded-core

> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-
> core@lists.openembedded.org> On Behalf Of Mark Hatle
> Sent: den 15 december 2020 02:02
> To: openembedded-core@lists.openembedded.org
> Subject: Re: [OE-core] How to create a directory in multiple packages?
> 
> On 12/14/20 11:43 AM, Peter Kjellerstedt wrote:
> > Say we have a recipe that creates an empty /etc/foo directory. Now we
> > want to add a new file in that directory /etc/foo/bar and package it as
> > ${PN}-bar. This means the creation of the /etc/foo directory is moved
> > from the ${PN} package to the ${PN}-bar package. Is there any way to
> > make ${PN} continue to create an empty /etc/foo, or is the only
> > alternative to introduce an /etc/foo/.dummy and package it in ${PN}?
> 
> try adjust the order of the PACKAGES variant.  Something like:
> 
> PACKAGES = "${PN}-bar ... ${PN}"
> 
> FILES_${PN}-bar = "/etc/foo/bar"
> FILES_${PN} = "/etc/foo"
> 
> That SHOULD package the file 'bar' in -bar, and the directory in ${PN}.

Unfortunately that does not work (seems bitbake is too smart). What I have 
is basically:

PACKAGE_BEFORE_PN = "${PN}-bar"
FILES_${PN} += "${sysconfdir}/foo"
FILES_${PN}-bar = "${sysconfdir}/foo/bar"

which results in the following in the spec file:

%files -n foo-bar
%defattr(-,-,-,-)
%dir "/etc"
%dir "/etc/foo"
"/etc/foo/bar"

There is nothing else about /etc or /etc/foo in the spec file.

After delving into the code for at bit, I believe this is due to how 
populate_packages() works. When it handles the ${PN}-bar package and 
finds the /etc/foo/bar file, it will also mark /etc and /etc/foo as  
seen, which means they will not be added to any other package, unless 
that package has an entry for some other /etc/foo/something file, even 
if /etc/foo is explicitly listed in, e.g., FILES_${PN}.

So for now, it seems we will have to resort to using a pkg_postinst_${PN}.

> (Some of the people commenting this isn't less then optimal, actually
> it's not that unusual.. Typical case I see is creating a directory in 
> /var or /usr/share for datafiles and the main package owns the directory, 
> with sub-packages [or other packages] contributing data into that 
> directory.)

Yes, there are reason why the empty directory needs to be installed as 
part of the image. Otherwise I would just have used a file in 
"/usr/lib/tmpfiles.d".

> --Mark
> 
> > //Peter

//Peter


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [OE-core] How to create a directory in multiple packages?
  2020-12-15 14:24   ` Peter Kjellerstedt
@ 2020-12-15 22:05     ` Mark Hatle
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Hatle @ 2020-12-15 22:05 UTC (permalink / raw)
  To: Peter Kjellerstedt, openembedded-core

On 12/15/20 8:24 AM, Peter Kjellerstedt wrote:
>> -----Original Message-----
>> From: openembedded-core@lists.openembedded.org <openembedded-
>> core@lists.openembedded.org> On Behalf Of Mark Hatle
>> Sent: den 15 december 2020 02:02
>> To: openembedded-core@lists.openembedded.org
>> Subject: Re: [OE-core] How to create a directory in multiple packages?
>>
>> On 12/14/20 11:43 AM, Peter Kjellerstedt wrote:
>>> Say we have a recipe that creates an empty /etc/foo directory. Now we
>>> want to add a new file in that directory /etc/foo/bar and package it as
>>> ${PN}-bar. This means the creation of the /etc/foo directory is moved
>>> from the ${PN} package to the ${PN}-bar package. Is there any way to
>>> make ${PN} continue to create an empty /etc/foo, or is the only
>>> alternative to introduce an /etc/foo/.dummy and package it in ${PN}?
>>
>> try adjust the order of the PACKAGES variant.  Something like:
>>
>> PACKAGES = "${PN}-bar ... ${PN}"
>>
>> FILES_${PN}-bar = "/etc/foo/bar"
>> FILES_${PN} = "/etc/foo"
>>
>> That SHOULD package the file 'bar' in -bar, and the directory in ${PN}.
> 
> Unfortunately that does not work (seems bitbake is too smart). What I have 
> is basically:
> 
> PACKAGE_BEFORE_PN = "${PN}-bar"
> FILES_${PN} += "${sysconfdir}/foo"
> FILES_${PN}-bar = "${sysconfdir}/foo/bar"
> 
> which results in the following in the spec file:
> 
> %files -n foo-bar
> %defattr(-,-,-,-)
> %dir "/etc"
> %dir "/etc/foo"
> "/etc/foo/bar"
> 
> There is nothing else about /etc or /etc/foo in the spec file.

Ya, there definitely should be a way to do this...  If not, it will be
problematic as more or more recipes get split into smaller chunks.

> After delving into the code for at bit, I believe this is due to how 
> populate_packages() works. When it handles the ${PN}-bar package and 
> finds the /etc/foo/bar file, it will also mark /etc and /etc/foo as  
> seen, which means they will not be added to any other package, unless 
> that package has an entry for some other /etc/foo/something file, even 
> if /etc/foo is explicitly listed in, e.g., FILES_${PN}.
> 
> So for now, it seems we will have to resort to using a pkg_postinst_${PN}.

Big problem with pkg_postinst, the system won't be able to track
perms/owner/group for the directory and ensure they are synced like the package
manager itself can.

For RPM, I know the %dir directive can (and should be) used to do this kind of
thing, but I don't know what the equivalencies are in opkg and deb.  If there is
a similar mechanism there to specify a directory (not not it's contents) then I
suspect may want to extend recipe syntax to match.

--Mark

>> (Some of the people commenting this isn't less then optimal, actually
>> it's not that unusual.. Typical case I see is creating a directory in 
>> /var or /usr/share for datafiles and the main package owns the directory, 
>> with sub-packages [or other packages] contributing data into that 
>> directory.)
> 
> Yes, there are reason why the empty directory needs to be installed as 
> part of the image. Otherwise I would just have used a file in 
> "/usr/lib/tmpfiles.d".
> 
>> --Mark
>>
>>> //Peter
> 
> //Peter
> 
> 
> 
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-12-15 22:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-14 17:43 How to create a directory in multiple packages? Peter Kjellerstedt
2020-12-14 17:46 ` [OE-core] " Robert P. J. Day
2020-12-14 18:20   ` Konrad Weihmann
2020-12-15  1:01 ` Mark Hatle
2020-12-15 14:24   ` Peter Kjellerstedt
2020-12-15 22:05     ` Mark Hatle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.