diff mbox

core/legal-info: allow ignoring packages from the legal-info

Message ID 1476538102-8779-1-git-send-email-yann.morin.1998@free.fr
State Changes Requested
Headers show

Commit Message

Yann E. MORIN Oct. 15, 2016, 1:28 p.m. UTC
It might be necessary to not even mention a package in the output of
legal-info:

  - virtual packages have virtually nothing to save in the legal-info
    output;

  - for proprietary packages, it might not even be legal to even
    mention them, being under NDA or some other such restrictive
    conditions.

Introduce the new FOO_GEN_LEGAL_INFO variable that a package can set
to 'NO' (default to 'YES') to indicate that the package should be
completely ignored from the legal-info output, in which case the
package is not mentioned in the maniufest, its source archive,
patches and license files are not saved into legal-info/ .

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Luca Ceresoli <luca@lucaceresoli.net>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Peter Korsgaard <jacmet@uclibc.org>

---
Note: the name of the variable if up for discussion. However, this will
most probably never be used in Buildroot itself, but only in local
proprietary forks or br2-external trees. So we will probably never ever
see it publicly. So, we do not care much about that variable name...

---
Changes v6 -> v7:
  - rename the variable  (Thomas, Luca, Peter)
  - remove Luca's reviewed/tested-by tags (too much churn since given)
---
 docs/manual/adding-packages-generic.txt | 13 +++++++++++++
 package/pkg-generic.mk                  | 16 +++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)

Comments

Samuel Martin Oct. 15, 2016, 2:58 p.m. UTC | #1
Yann,

On Sat, Oct 15, 2016 at 3:28 PM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> It might be necessary to not even mention a package in the output of
> legal-info:
>
>   - virtual packages have virtually nothing to save in the legal-info
>     output;
>
>   - for proprietary packages, it might not even be legal to even
>     mention them, being under NDA or some other such restrictive
>     conditions.
>
> Introduce the new FOO_GEN_LEGAL_INFO variable that a package can set
> to 'NO' (default to 'YES') to indicate that the package should be
> completely ignored from the legal-info output, in which case the
> package is not mentioned in the maniufest, its source archive,

s/maniufest/manifest/

> patches and license files are not saved into legal-info/ .
>
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Cc: Luca Ceresoli <luca@lucaceresoli.net>
> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> Cc: Peter Korsgaard <jacmet@uclibc.org>
>
> ---
> Note: the name of the variable if up for discussion. However, this will

s/if up/is up/

> most probably never be used in Buildroot itself, but only in local
> proprietary forks or br2-external trees. So we will probably never ever
> see it publicly. So, we do not care much about that variable name...
>

Yann, you mention setting FOO_GEN_LEGAL_INFO=NO could benefit to
virtual packages, but I see no change/patch on the virtual-package
infrastructure. Did I miss something?

> ---
> Changes v6 -> v7:
>   - rename the variable  (Thomas, Luca, Peter)
>   - remove Luca's reviewed/tested-by tags (too much churn since given)
> ---
>  docs/manual/adding-packages-generic.txt | 13 +++++++++++++
>  package/pkg-generic.mk                  | 16 +++++++++++++++-
>  2 files changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/docs/manual/adding-packages-generic.txt b/docs/manual/adding-packages-generic.txt
> index 51408e8..0dccfb4 100644
> --- a/docs/manual/adding-packages-generic.txt
> +++ b/docs/manual/adding-packages-generic.txt
> @@ -443,6 +443,19 @@ information is (assuming the package name is +libfoo+) :
>    non-opensource packages: Buildroot will not save the source code for this
>    package when collecting the +legal-info+.
>
> +* +LIBFOO_GEN_LEGAL_INFO+ can be set to +YES+ (default) or +NO+ to indicate
> +  that this package should be included or not in the output of the
> +  +legal-info+.  If set to +NO+, that package will be completely excluded
> +  from the output of +legal-info+: it will not be listed in the manifest,
> +  the license files and the sources are not saved (the legal-info related
> +  variables are all ignored: +LIBFOO_LICENSE+, +LIBFOO_LICENSE_FILES+,
> +  +LIBFOO_ACTUAL_SOURCE_TARBALL+, +LIBFOO_ACTUAL_SOURCE_SITE+,
> +  +LIBFOO_REDISTRIBUTE+).
> ++
> +.Note
> +You probably do not want to set it to +NO+ for a package bundled in Buildroot.
> +  It is meant for non-public, confidential, company-proprietary packages.
> +
>  * +LIBFOO_FLAT_STACKSIZE+ defines the stack size of an application built into
>    the FLAT binary format. The application stack size on the NOMMU architecture
>    processors can't be enlarged at run time. The default stack size for the
> diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
> index 12ae86f..165000c 100644
> --- a/package/pkg-generic.mk
> +++ b/package/pkg-generic.mk
> @@ -502,6 +502,14 @@ endif
>
>  $(2)_REDISTRIBUTE              ?= YES
>
> +ifndef $(2)_GEN_LEGAL_INFO
> + ifdef $(3)_GEN_LEGAL_INFO
> +  $(2)_GEN_LEGAL_INFO = $$($(3)_GEN_LEGAL_INFO)
> + endif
> +endif
> +
> +$(2)_GEN_LEGAL_INFO                    ?= YES
> +
>  $(2)_REDIST_SOURCES_DIR = $$(REDIST_SOURCES_DIR_$$(call UPPERCASE,$(4)))/$$($(2)_RAW_BASE_NAME)
>
>  # When a target package is a toolchain dependency set this variable to
> @@ -782,8 +790,10 @@ endif
>
>  # We need to extract and patch a package to be able to retrieve its
>  # license files (if any) and the list of patches applied to it (if
> -# any).
> +# any). But not if we want to ignore that package completely.
> +ifeq ($$($(2)_GEN_LEGAL_INFO),YES)
>  $(1)-legal-info: $(1)-patch
> +endif
>
>  # We only save the sources of packages we want to redistribute, that are
>  # non-overriden (local or true override).
> @@ -796,6 +806,8 @@ endif
>
>  # legal-info: produce legally relevant info.
>  $(1)-legal-info:
> +ifeq ($$($(2)_GEN_LEGAL_INFO),YES)
> +
>  # Packages without a source are assumed to be part of Buildroot, skip them.
>         $$(foreach hook,$$($(2)_PRE_LEGAL_INFO_HOOKS),$$(call $$(hook))$$(sep))
>  ifneq ($$(call qstrip,$$($(2)_SOURCE)),)
> @@ -843,6 +855,8 @@ endif # other packages
>  endif # ifneq ($$(call qstrip,$$($(2)_SOURCE)),)
>         $$(foreach hook,$$($(2)_POST_LEGAL_INFO_HOOKS),$$(call $$(hook))$$(sep))
>
> +endif # $(2)_GEN_LEGAL_INFO == YES
> +
>  # add package to the general list of targets if requested by the buildroot
>  # configuration
>  ifeq ($$($$($(2)_KCONFIG_VAR)),y)
> --
> 2.7.4
>
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

Regards,
Yann E. MORIN Oct. 15, 2016, 3:03 p.m. UTC | #2
Samuel, All,

On 2016-10-15 16:58 +0200, Samuel Martin spake thusly:
> On Sat, Oct 15, 2016 at 3:28 PM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> > It might be necessary to not even mention a package in the output of
> > legal-info:
> >
> >   - virtual packages have virtually nothing to save in the legal-info
> >     output;
> >
> >   - for proprietary packages, it might not even be legal to even
> >     mention them, being under NDA or some other such restrictive
> >     conditions.
> >
> > Introduce the new FOO_GEN_LEGAL_INFO variable that a package can set
> > to 'NO' (default to 'YES') to indicate that the package should be
> > completely ignored from the legal-info output, in which case the
> > package is not mentioned in the maniufest, its source archive,
> s/maniufest/manifest/

Fixed.

> > patches and license files are not saved into legal-info/ .
> >
> > Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> > Cc: Luca Ceresoli <luca@lucaceresoli.net>
> > Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> > Cc: Peter Korsgaard <jacmet@uclibc.org>
> >
> > ---
> > Note: the name of the variable if up for discussion. However, this will
> s/if up/is up/

Fixed.

> > most probably never be used in Buildroot itself, but only in local
> > proprietary forks or br2-external trees. So we will probably never ever
> > see it publicly. So, we do not care much about that variable name...
> Yann, you mention setting FOO_GEN_LEGAL_INFO=NO could benefit to
> virtual packages, but I see no change/patch on the virtual-package
> infrastructure. Did I miss something?

Indeed. No, you did not miss anything: I did not (yet) change the
virtual packages. I'll do so when this patch gets applied (after all the
controversy about it have been shaken out).

Regards,
Yann E. MORIN.
Peter Korsgaard Oct. 15, 2016, 3:13 p.m. UTC | #3
>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:

 > It might be necessary to not even mention a package in the output of
 > legal-info:

 >   - virtual packages have virtually nothing to save in the legal-info
 >     output;

 >   - for proprietary packages, it might not even be legal to even
 >     mention them, being under NDA or some other such restrictive
 >     conditions.

 > Introduce the new FOO_GEN_LEGAL_INFO variable that a package can set
 > to 'NO' (default to 'YES') to indicate that the package should be
 > completely ignored from the legal-info output, in which case the
 > package is not mentioned in the maniufest, its source archive,
 > patches and license files are not saved into legal-info/ .

Couldn't / shouldn't the 2nd part already be handled by
<foo>_REDISTRIBUTE = NO and/or <foo>_LICENSE = PROPRIETARY?
Yann E. MORIN Oct. 15, 2016, 3:32 p.m. UTC | #4
Peter, All,

On 2016-10-15 17:13 +0200, Peter Korsgaard spake thusly:
> >>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:
> 
>  > It might be necessary to not even mention a package in the output of
>  > legal-info:
> 
>  >   - virtual packages have virtually nothing to save in the legal-info
>  >     output;
> 
>  >   - for proprietary packages, it might not even be legal to even
>  >     mention them, being under NDA or some other such restrictive
>  >     conditions.
> 
>  > Introduce the new FOO_GEN_LEGAL_INFO variable that a package can set
>  > to 'NO' (default to 'YES') to indicate that the package should be
>  > completely ignored from the legal-info output, in which case the
>  > package is not mentioned in the maniufest, its source archive,
>  > patches and license files are not saved into legal-info/ .
> 
> Couldn't / shouldn't the 2nd part already be handled by
> <foo>_REDISTRIBUTE = NO and/or <foo>_LICENSE = PROPRIETARY?

No, because for a proprietary license, you may still have to at least
list it in the manifest.

For example, the nvidia-driver package has a proprietary license, is not
redistributable, but we must still list it in the manifest.

I'll update the commit log accordingly. Thanks! ;-)

Regards,
Yann E. MORIN.
Luca Ceresoli Oct. 15, 2016, 3:40 p.m. UTC | #5
Hi,

On 15/10/2016 17:32, Yann E. MORIN wrote:
> Peter, All,
> 
> On 2016-10-15 17:13 +0200, Peter Korsgaard spake thusly:
>>>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:
>>
>>  > It might be necessary to not even mention a package in the output of
>>  > legal-info:
>>
>>  >   - virtual packages have virtually nothing to save in the legal-info
>>  >     output;
>>
>>  >   - for proprietary packages, it might not even be legal to even
>>  >     mention them, being under NDA or some other such restrictive
>>  >     conditions.
>>
>>  > Introduce the new FOO_GEN_LEGAL_INFO variable that a package can set
>>  > to 'NO' (default to 'YES') to indicate that the package should be
>>  > completely ignored from the legal-info output, in which case the
>>  > package is not mentioned in the maniufest, its source archive,
>>  > patches and license files are not saved into legal-info/ .
>>
>> Couldn't / shouldn't the 2nd part already be handled by
>> <foo>_REDISTRIBUTE = NO and/or <foo>_LICENSE = PROPRIETARY?
> 
> No, because for a proprietary license, you may still have to at least
> list it in the manifest.
> 
> For example, the nvidia-driver package has a proprietary license, is not
> redistributable, but we must still list it in the manifest.
> 
> I'll update the commit log accordingly. Thanks! ;-)

I suggest listing the three possible cases:

 * FOO_GEN_LEGAL_INFO = NO: save nothing
 * FOO_GEN_LEGAL_INFO = YES, FOO_REDISTRIBUTE = NO: list only
 * FOO_GEN_LEGAL_INFO = YES, FOO_REDISTRIBUTE = NO: list + save source

Maybe in the manual as well?
Yann E. MORIN Oct. 15, 2016, 3:45 p.m. UTC | #6
Luca, All,

On 2016-10-15 17:40 +0200, Luca Ceresoli spake thusly:
> On 15/10/2016 17:32, Yann E. MORIN wrote:
> > Peter, All,
> > 
> > On 2016-10-15 17:13 +0200, Peter Korsgaard spake thusly:
> >>>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:
> >>
> >>  > It might be necessary to not even mention a package in the output of
> >>  > legal-info:
> >>
> >>  >   - virtual packages have virtually nothing to save in the legal-info
> >>  >     output;
> >>
> >>  >   - for proprietary packages, it might not even be legal to even
> >>  >     mention them, being under NDA or some other such restrictive
> >>  >     conditions.
> >>
> >>  > Introduce the new FOO_GEN_LEGAL_INFO variable that a package can set
> >>  > to 'NO' (default to 'YES') to indicate that the package should be
> >>  > completely ignored from the legal-info output, in which case the
> >>  > package is not mentioned in the maniufest, its source archive,
> >>  > patches and license files are not saved into legal-info/ .
> >>
> >> Couldn't / shouldn't the 2nd part already be handled by
> >> <foo>_REDISTRIBUTE = NO and/or <foo>_LICENSE = PROPRIETARY?
> > 
> > No, because for a proprietary license, you may still have to at least
> > list it in the manifest.
> > 
> > For example, the nvidia-driver package has a proprietary license, is not
> > redistributable, but we must still list it in the manifest.
> > 
> > I'll update the commit log accordingly. Thanks! ;-)
> 
> I suggest listing the three possible cases:
> 
>  * FOO_GEN_LEGAL_INFO = NO: save nothing
>  * FOO_GEN_LEGAL_INFO = YES, FOO_REDISTRIBUTE = NO: list only
>  * FOO_GEN_LEGAL_INFO = YES, FOO_REDISTRIBUTE = NO: list + save source
> 
> Maybe in the manual as well?

ACK.

Regards,
Yann E. MORIN.
Arnout Vandecappelle Oct. 15, 2016, 5:22 p.m. UTC | #7
On 15-10-16 17:40, Luca Ceresoli wrote:
> Hi,
> 
> On 15/10/2016 17:32, Yann E. MORIN wrote:
>> Peter, All,
>>
>> On 2016-10-15 17:13 +0200, Peter Korsgaard spake thusly:
>>>>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:
>>>
>>>  > It might be necessary to not even mention a package in the output of
>>>  > legal-info:
>>>
>>>  >   - virtual packages have virtually nothing to save in the legal-info
>>>  >     output;
>>>
>>>  >   - for proprietary packages, it might not even be legal to even
>>>  >     mention them, being under NDA or some other such restrictive
>>>  >     conditions.
>>>
>>>  > Introduce the new FOO_GEN_LEGAL_INFO variable that a package can set
>>>  > to 'NO' (default to 'YES') to indicate that the package should be
>>>  > completely ignored from the legal-info output, in which case the
>>>  > package is not mentioned in the maniufest, its source archive,
>>>  > patches and license files are not saved into legal-info/ .
>>>
>>> Couldn't / shouldn't the 2nd part already be handled by
>>> <foo>_REDISTRIBUTE = NO and/or <foo>_LICENSE = PROPRIETARY?
>>
>> No, because for a proprietary license, you may still have to at least
>> list it in the manifest.
>>
>> For example, the nvidia-driver package has a proprietary license, is not
>> redistributable, but we must still list it in the manifest.
>>
>> I'll update the commit log accordingly. Thanks! ;-)
> 
> I suggest listing the three possible cases:
> 
>  * FOO_GEN_LEGAL_INFO = NO: save nothing
>  * FOO_GEN_LEGAL_INFO = YES, FOO_REDISTRIBUTE = NO: list only
>  * FOO_GEN_LEGAL_INFO = YES, FOO_REDISTRIBUTE = NO: list + save source

 I hate that we have all these combinations. That was actually my first thought
when I saw this patch: oh no, yet another variation point. But I don't see a way
to simplify it. So OK.

 One remark though: I think the pre- and post-hooks should still run even if
_GEN_LEGAL_INFO = NO.

 Regards,
 Arnout

> 
> Maybe in the manual as well?
>
Peter Korsgaard Oct. 15, 2016, 5:36 p.m. UTC | #8
>>>>> "Arnout" == Arnout Vandecappelle <arnout@mind.be> writes:

Hi,
 >> 
 >> * FOO_GEN_LEGAL_INFO = NO: save nothing
 >> * FOO_GEN_LEGAL_INFO = YES, FOO_REDISTRIBUTE = NO: list only
 >> * FOO_GEN_LEGAL_INFO = YES, FOO_REDISTRIBUTE = NO: list + save source

The last is presumably FOO_REDISTRIBUTE = YES.

 >  I hate that we have all these combinations. That was actually my first thought
 > when I saw this patch: oh no, yet another variation point. But I don't see a way
 > to simplify it. So OK.

yeah, me too. I also cannot think of a simpler approach if we want to do
it.

I don't think it is really a big deal to list the virtual packages in
the legal info, and people doing funky stuff in br2-external can also
post process their legal info data to remove unwanted stuff if needed.

But OK, it doesn't add a lot of complexity, so if others think it is
worthwhile, I'm OK with it as well.
Yann E. MORIN Oct. 15, 2016, 5:37 p.m. UTC | #9
Arnout, All,

On 2016-10-15 19:22 +0200, Arnout Vandecappelle spake thusly:
> On 15-10-16 17:40, Luca Ceresoli wrote:
> > On 15/10/2016 17:32, Yann E. MORIN wrote:
> >> Peter, All,
> >>
> >> On 2016-10-15 17:13 +0200, Peter Korsgaard spake thusly:
> >>>>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:
> >>>
> >>>  > It might be necessary to not even mention a package in the output of
> >>>  > legal-info:
> >>>
> >>>  >   - virtual packages have virtually nothing to save in the legal-info
> >>>  >     output;
> >>>
> >>>  >   - for proprietary packages, it might not even be legal to even
> >>>  >     mention them, being under NDA or some other such restrictive
> >>>  >     conditions.
> >>>
> >>>  > Introduce the new FOO_GEN_LEGAL_INFO variable that a package can set
> >>>  > to 'NO' (default to 'YES') to indicate that the package should be
> >>>  > completely ignored from the legal-info output, in which case the
> >>>  > package is not mentioned in the maniufest, its source archive,
> >>>  > patches and license files are not saved into legal-info/ .
> >>>
> >>> Couldn't / shouldn't the 2nd part already be handled by
> >>> <foo>_REDISTRIBUTE = NO and/or <foo>_LICENSE = PROPRIETARY?
> >>
> >> No, because for a proprietary license, you may still have to at least
> >> list it in the manifest.
> >>
> >> For example, the nvidia-driver package has a proprietary license, is not
> >> redistributable, but we must still list it in the manifest.
> >>
> >> I'll update the commit log accordingly. Thanks! ;-)
> > 
> > I suggest listing the three possible cases:
> > 
> >  * FOO_GEN_LEGAL_INFO = NO: save nothing
> >  * FOO_GEN_LEGAL_INFO = YES, FOO_REDISTRIBUTE = NO: list only
> >  * FOO_GEN_LEGAL_INFO = YES, FOO_REDISTRIBUTE = NO: list + save source
> 
>  I hate that we have all these combinations. That was actually my first thought
> when I saw this patch: oh no, yet another variation point. But I don't see a way
> to simplify it. So OK.

The alternative would be:

  - get rid of LIBFOO_REDISTRIBUTE
  - add LIBFOO_LEGAL_INFO = {IGNORE,LIST,FULL} (or whatever name/values).

Thomas, Peter and Luca were not very happy with such a tristate, and in
retrospect, neither am I...

>  One remark though: I think the pre- and post-hooks should still run even if
> _GEN_LEGAL_INFO = NO.

Not so sure... Such hooks are made to save extra stuff into legal-info,
or to prepare the package for legal-info. So, if the package is excluded
for legal-info, there is no reason to run those hooks to start with, is
there?

Regards,
Yann E. MORIN.
Arnout Vandecappelle Oct. 15, 2016, 6:06 p.m. UTC | #10
On 15-10-16 19:37, Yann E. MORIN wrote:
> Arnout, All,
> 
> On 2016-10-15 19:22 +0200, Arnout Vandecappelle spake thusly:
>> On 15-10-16 17:40, Luca Ceresoli wrote:
>>> On 15/10/2016 17:32, Yann E. MORIN wrote:
>>>> Peter, All,
>>>>
>>>> On 2016-10-15 17:13 +0200, Peter Korsgaard spake thusly:
>>>>>>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:
>>>>>
>>>>>  > It might be necessary to not even mention a package in the output of
>>>>>  > legal-info:
>>>>>
>>>>>  >   - virtual packages have virtually nothing to save in the legal-info
>>>>>  >     output;
>>>>>
>>>>>  >   - for proprietary packages, it might not even be legal to even
>>>>>  >     mention them, being under NDA or some other such restrictive
>>>>>  >     conditions.
>>>>>
>>>>>  > Introduce the new FOO_GEN_LEGAL_INFO variable that a package can set
>>>>>  > to 'NO' (default to 'YES') to indicate that the package should be
>>>>>  > completely ignored from the legal-info output, in which case the
>>>>>  > package is not mentioned in the maniufest, its source archive,
>>>>>  > patches and license files are not saved into legal-info/ .
>>>>>
>>>>> Couldn't / shouldn't the 2nd part already be handled by
>>>>> <foo>_REDISTRIBUTE = NO and/or <foo>_LICENSE = PROPRIETARY?
>>>>
>>>> No, because for a proprietary license, you may still have to at least
>>>> list it in the manifest.
>>>>
>>>> For example, the nvidia-driver package has a proprietary license, is not
>>>> redistributable, but we must still list it in the manifest.
>>>>
>>>> I'll update the commit log accordingly. Thanks! ;-)
>>>
>>> I suggest listing the three possible cases:
>>>
>>>  * FOO_GEN_LEGAL_INFO = NO: save nothing
>>>  * FOO_GEN_LEGAL_INFO = YES, FOO_REDISTRIBUTE = NO: list only
>>>  * FOO_GEN_LEGAL_INFO = YES, FOO_REDISTRIBUTE = NO: list + save source
>>
>>  I hate that we have all these combinations. That was actually my first thought
>> when I saw this patch: oh no, yet another variation point. But I don't see a way
>> to simplify it. So OK.
> 
> The alternative would be:
> 
>   - get rid of LIBFOO_REDISTRIBUTE
>   - add LIBFOO_LEGAL_INFO = {IGNORE,LIST,FULL} (or whatever name/values).
> 
> Thomas, Peter and Luca were not very happy with such a tristate, and in
> retrospect, neither am I...

 Neither am I.

> 
>>  One remark though: I think the pre- and post-hooks should still run even if
>> _GEN_LEGAL_INFO = NO.
> 
> Not so sure... Such hooks are made to save extra stuff into legal-info,
> or to prepare the package for legal-info. So, if the package is excluded
> for legal-info, there is no reason to run those hooks to start with, is
> there?

 First of all, both _GEN_LEGAL_INFO and _LEGAL_INFO_HOOKS are package-specific
so the package knows what it's doing.

 The reason to run hooks is that you may still want to do *something* in the
legal info for excluded packages. I can't give a concrete example, but I'm
thinking along the lines of e.g. doing some check and erroring out, or still
adding some custom information to legal info. You know, what the hooks are meant
for in the first place :-) The point is, this option disables the normal
legal-info, but that doesn't mean that there would be no legal-info at all.


 Regards,
 Arnout
Yann E. MORIN Oct. 15, 2016, 8:13 p.m. UTC | #11
Arnout, All,

On 2016-10-15 20:06 +0200, Arnout Vandecappelle spake thusly:
> On 15-10-16 19:37, Yann E. MORIN wrote:
> > On 2016-10-15 19:22 +0200, Arnout Vandecappelle spake thusly:
> >> On 15-10-16 17:40, Luca Ceresoli wrote:
[--SNIP--]
> >>> I suggest listing the three possible cases:
> >>>  * FOO_GEN_LEGAL_INFO = NO: save nothing
> >>>  * FOO_GEN_LEGAL_INFO = YES, FOO_REDISTRIBUTE = NO: list only
> >>>  * FOO_GEN_LEGAL_INFO = YES, FOO_REDISTRIBUTE = NO: list + save source
> >>  I hate that we have all these combinations. That was actually my first thought
> >> when I saw this patch: oh no, yet another variation point. But I don't see a way
> >> to simplify it. So OK.
> > The alternative would be:
> >   - get rid of LIBFOO_REDISTRIBUTE
> >   - add LIBFOO_LEGAL_INFO = {IGNORE,LIST,FULL} (or whatever name/values).
> > 
> > Thomas, Peter and Luca were not very happy with such a tristate, and in
> > retrospect, neither am I...
>  Neither am I.

Eh! ;-)

> >>  One remark though: I think the pre- and post-hooks should still run even if
> >> _GEN_LEGAL_INFO = NO.
> > Not so sure... Such hooks are made to save extra stuff into legal-info,
> > or to prepare the package for legal-info. So, if the package is excluded
> > for legal-info, there is no reason to run those hooks to start with, is
> > there?
>  First of all, both _GEN_LEGAL_INFO and _LEGAL_INFO_HOOKS are package-specific
> so the package knows what it's doing.
> 
>  The reason to run hooks is that you may still want to do *something* in the
> legal info for excluded packages. I can't give a concrete example, but I'm
> thinking along the lines of e.g. doing some check and erroring out, or still
> adding some custom information to legal info. You know, what the hooks are meant
> for in the first place :-) The point is, this option disables the normal
> legal-info, but that doesn't mean that there would be no legal-info at all.

I would argue that, if a packager elected to have its package completely
ignored by the legal-info infra, we should just abide by this wish and
just completely ignore it. Altogether.

Let's see what others think... ;-)

Regards,
Yann E. MORIN.
Luca Ceresoli Oct. 17, 2016, 8:22 a.m. UTC | #12
Hi Yann, Arnout,

On 15/10/2016 22:13, Yann E. MORIN wrote:
[...]
>>>>  One remark though: I think the pre- and post-hooks should still run even if
>>>> _GEN_LEGAL_INFO = NO.
>>> Not so sure... Such hooks are made to save extra stuff into legal-info,
>>> or to prepare the package for legal-info. So, if the package is excluded
>>> for legal-info, there is no reason to run those hooks to start with, is
>>> there?
>>  First of all, both _GEN_LEGAL_INFO and _LEGAL_INFO_HOOKS are package-specific
>> so the package knows what it's doing.
>>
>>  The reason to run hooks is that you may still want to do *something* in the
>> legal info for excluded packages. I can't give a concrete example, but I'm
>> thinking along the lines of e.g. doing some check and erroring out, or still
>> adding some custom information to legal info. You know, what the hooks are meant
>> for in the first place :-) The point is, this option disables the normal
>> legal-info, but that doesn't mean that there would be no legal-info at all.
> 
> I would argue that, if a packager elected to have its package completely
> ignored by the legal-info infra, we should just abide by this wish and
> just completely ignore it. Altogether.
> 
> Let's see what others think... ;-)

I think Arnout is right. The hooks would allow to implement any weird
behavior that the infra is not (and should not even be) flexible enough
to do. Of course this would be doable with a user-provided script, but
then the script should also detect whether the given package is enabled
or not, while the hooks do it for free.

As far as the code is concerned, it should be only a matter of moving
the if/endif a few lines below/above, so it shouldn't add complexity.
diff mbox

Patch

diff --git a/docs/manual/adding-packages-generic.txt b/docs/manual/adding-packages-generic.txt
index 51408e8..0dccfb4 100644
--- a/docs/manual/adding-packages-generic.txt
+++ b/docs/manual/adding-packages-generic.txt
@@ -443,6 +443,19 @@  information is (assuming the package name is +libfoo+) :
   non-opensource packages: Buildroot will not save the source code for this
   package when collecting the +legal-info+.
 
+* +LIBFOO_GEN_LEGAL_INFO+ can be set to +YES+ (default) or +NO+ to indicate
+  that this package should be included or not in the output of the
+  +legal-info+.  If set to +NO+, that package will be completely excluded
+  from the output of +legal-info+: it will not be listed in the manifest,
+  the license files and the sources are not saved (the legal-info related
+  variables are all ignored: +LIBFOO_LICENSE+, +LIBFOO_LICENSE_FILES+,
+  +LIBFOO_ACTUAL_SOURCE_TARBALL+, +LIBFOO_ACTUAL_SOURCE_SITE+,
+  +LIBFOO_REDISTRIBUTE+).
++
+.Note
+You probably do not want to set it to +NO+ for a package bundled in Buildroot.
+  It is meant for non-public, confidential, company-proprietary packages.
+
 * +LIBFOO_FLAT_STACKSIZE+ defines the stack size of an application built into
   the FLAT binary format. The application stack size on the NOMMU architecture
   processors can't be enlarged at run time. The default stack size for the
diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index 12ae86f..165000c 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -502,6 +502,14 @@  endif
 
 $(2)_REDISTRIBUTE		?= YES
 
+ifndef $(2)_GEN_LEGAL_INFO
+ ifdef $(3)_GEN_LEGAL_INFO
+  $(2)_GEN_LEGAL_INFO = $$($(3)_GEN_LEGAL_INFO)
+ endif
+endif
+
+$(2)_GEN_LEGAL_INFO			?= YES
+
 $(2)_REDIST_SOURCES_DIR = $$(REDIST_SOURCES_DIR_$$(call UPPERCASE,$(4)))/$$($(2)_RAW_BASE_NAME)
 
 # When a target package is a toolchain dependency set this variable to
@@ -782,8 +790,10 @@  endif
 
 # We need to extract and patch a package to be able to retrieve its
 # license files (if any) and the list of patches applied to it (if
-# any).
+# any). But not if we want to ignore that package completely.
+ifeq ($$($(2)_GEN_LEGAL_INFO),YES)
 $(1)-legal-info: $(1)-patch
+endif
 
 # We only save the sources of packages we want to redistribute, that are
 # non-overriden (local or true override).
@@ -796,6 +806,8 @@  endif
 
 # legal-info: produce legally relevant info.
 $(1)-legal-info:
+ifeq ($$($(2)_GEN_LEGAL_INFO),YES)
+
 # Packages without a source are assumed to be part of Buildroot, skip them.
 	$$(foreach hook,$$($(2)_PRE_LEGAL_INFO_HOOKS),$$(call $$(hook))$$(sep))
 ifneq ($$(call qstrip,$$($(2)_SOURCE)),)
@@ -843,6 +855,8 @@  endif # other packages
 endif # ifneq ($$(call qstrip,$$($(2)_SOURCE)),)
 	$$(foreach hook,$$($(2)_POST_LEGAL_INFO_HOOKS),$$(call $$(hook))$$(sep))
 
+endif # $(2)_GEN_LEGAL_INFO == YES
+
 # add package to the general list of targets if requested by the buildroot
 # configuration
 ifeq ($$($$($(2)_KCONFIG_VAR)),y)