[OE-core] [PATCH] package_rpm: correctly handle LICENSE_${PN}

Mark Hatle mark.hatle at windriver.com
Mon Jan 22 16:32:53 UTC 2018


On 1/22/18 9:44 AM, Ross Burton wrote:
> RPM spec files don't distinguish between spec-level license and the primary
> package license, so always output the License for every package (defaulting to
> the recipe-wide license) and use LICENSE_${PN} if set for the primary package.
> 
> As the primary use of package_rpm is to generate built packages, this fixes the
> license fields in the generated packages.
> 
> [ YOCTO #12057 ]
> 
> Signed-off-by: Ross Burton <ross.burton at intel.com>
> ---
>  meta/classes/package_rpm.bbclass | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass
> index b08608c8466..3cbbd1eb537 100644
> --- a/meta/classes/package_rpm.bbclass
> +++ b/meta/classes/package_rpm.bbclass
> @@ -382,6 +382,7 @@ python write_specfile () {

For the specific problem reported, this is correct.  However, it has an
unintended side effect.  When the archiver is enabled (with SRPM support), it
uses the same function to generate the SRPM files.  This will result in the SRPM
not having the 'correct' "source code" license, but instead will end up having
the license of the first package.

At a minimum, we should detect this case and warn someone..  I.e.

>  
>          # Gather special src/first package data
>          if srcname == splitname:

if d.getVarFlag('ARCHIVER_MODE', 'srpm') == '1' and \
   bb.data.inherits_class('archiver', d) and \
   srclicense != splitlicense:
	bb.warn("The SRPM produced may not have the correct overall source license in
the LICENSE tag.  This is due to the LICENSE for the primary package and SRPM
conflicting.)

> +            srclicense     = splitlicense
>              srcrdepends    = splitrdepends
>              srcrrecommends = splitrrecommends
>              srcrsuggests   = splitrsuggests

An alternative (i -really- do not like) is to name the overall first entry as
something like:

${PN}-archiver (or src, srpm, ... etc ...)

Then in the later section add ${PN} as the first %package.  I do suspect this
will break some people's validation scripting though.  So there does not appear
to be a clear answer how to deal with this.  (The behavior unfortunately does
not appear to be allowed in upstream RPM.)

> @@ -421,8 +422,7 @@ python write_specfile () {

This hunk is absolutely correct in all cases.

>              spec_preamble_bottom.append('Release: %s' % splitrelease)
>          if srcepoch != splitepoch:
>              spec_preamble_bottom.append('Epoch: %s' % splitepoch)
> -        if srclicense != splitlicense:
> -            spec_preamble_bottom.append('License: %s' % splitlicense)
> +        spec_preamble_bottom.append('License: %s' % splitlicense)
>          spec_preamble_bottom.append('Group: %s' % splitsection)
>  
>          if srccustomtagschunk != splitcustomtagschunk:
> 




More information about the Openembedded-core mailing list