Skip to contentSkip to conversation

package_rpm: correctly handle LICENSE_${PN}

PATCH In review Ross Burton 2 participants 3 messages Jan 22, 2018 – Jan 23, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package_rpm: correctly handle LICENSE_${PN}

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 ]

---
 meta/classes/package_rpm.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/classes/package_rpm.bbclass +2 -2
index b08608c8466..3cbbd1eb537 100644
@@ -382,6 +382,7 @@ python write_specfile () {
 
         # Gather special src/first package data
         if srcname == splitname:
+            srclicense     = splitlicense
             srcrdepends    = splitrdepends
             srcrrecommends = splitrrecommends
             srcrsuggests   = splitrsuggests
@@ -421,8 +422,7 @@ python write_specfile () {
             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:
Signature · 1 line
2.11.0
#1 lore raw

meta/classes/package_rpm.bbclass python write_specfile () {

Quoted 19 lines · Ross Burton

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 ]

---
 meta/classes/package_rpm.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/classes/package_rpm.bbclass +0 -0
index b08608c8466..3cbbd1eb537 100644
@@ -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.

meta/classes/package_rpm.bbclass python write_specfile () { · line 384

Quoted 3 lines
meta/classes/package_rpm.bbclass +0 -0
         # 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.)

meta/classes/package_rpm.bbclass python write_specfile () { · line 388

Quoted 4 lines
meta/classes/package_rpm.bbclass +1 -0
+            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.)

meta/classes/package_rpm.bbclass python write_specfile () {

Quoted 1 line
meta/classes/package_rpm.bbclass +0 -0
@@ -421,8 +422,7 @@ python write_specfile () {

This hunk is absolutely correct in all cases.

Quoted 10 lines
meta/classes/package_rpm.bbclass +1 -2
             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:
#2 lore raw
Quoted 4 lines · Mark Hatle

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

I agree that's not a realistic alternative. I'll send a V2 with the warning added.

Thanks,
Ross