Bug 1386639

Summary: "%license FILENAME" in %expand breaks the build
Product: [Fedora] Fedora Reporter: Thierry Vignaud <thierry.vignaud>
Component: rpmAssignee: Packaging Maintenance Team <packaging-team-maint>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 24CC: extras-qa, ffesti, jzeleny, kardos.lubos, lkardos, ngompa13, novyjindrich, packaging-team-maint, pknirsch, pmatilai, thierry.vignaud, tradej
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1200761 Environment:
Last Closed: 2016-12-16 09:19:02 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
test spec file showing the bug
none
switching to %doc workarounds the issue none

Description Thierry Vignaud 2016-10-19 11:00:21 UTC
Created attachment 1212106 [details]
test spec file showing the bug

+++ This bug was initially created as a clone of Bug #1200761 +++

Description of problem:
This problem occurs if "%license is used within an %expand. If %expand contains a line "%license FILENAME", the "%license" tag is expanded to the contents of the package's License field as specified in the SPEC, instead of being understood as a %files directive.

Version-Release number of selected component (if applicable):
rpm-4.13.0-0.rc1.27.fc24.x86_64

How reproducible:
Always

Steps to Reproduce:
1. put %expand some_text in the SPEC, where some_text contains at least one line containing "%license FILENAME" (as in attached spec)
2. build

Actual results:
Rpmbuild outputs errors:
    File must begin with "/": GPL
    File must begin with "/": LICENSE_1_0.txt

Expected results:
Package compiles, FILENAME is marked as license file.

Additional info:
Building the attached spec file reproduces the bug as described. Problem occurs in F21-F25 (actually it happens since %license was introduced for file list).

--- Additional comment from Florian Festi on 2015-03-27 06:16:00 EDT ---

Thanks for reporting and providing the reproducer! There is some special code to hide the %license macro within the %files section. This code is missing from the part that parses the file manifest (which happens later in the build process).

Fixed upstream as 5d4d5e40c5a2634960385731743dc891ce9f1253

--- Additional comment from Tomas Radej on 2015-03-30 04:16:32 EDT ---

Thank you very much.

One more question, if I may - is there a convenient way to track when this fix makes it into the Fedora repositories? I'll need to disable the workaround that I am currently using in my package (using %%license in list-of-files). Thanks.

--- Additional comment from Florian Festi on 2015-03-30 11:38:50 EDT ---

By default this will be added to the next RPM release witch will hide rawhide in the F23 development cycle and will be announced loudly. 

Feel free to reopen the bug and demand a backport to (a) specific Fedora release(s) if this is important enough for you.

--- Additional comment from Thierry Vignaud on 2016-10-19 06:51:15 EDT ---

This is also broken if one uses %expand
See eg: https://bugs.mageia.org/show_bug.cgi?id=16818

Example is to change line 117 of http://svnweb.mageia.org/packages/cauldron/boost/current/SPECS/boost.spec?revision=1014876&view=markup#96
from:
%%doc LICENSE_1_0.txt
to:
%%license LICENSE_1_0.txt

This breaks as badly.

IMHO the overlapping name with the tag license was hazardous...

Comment 1 Thierry Vignaud 2016-10-19 11:01:35 UTC
Created attachment 1212107 [details]
switching to %doc workarounds the issue

Comment 2 Thierry Vignaud 2016-10-19 11:02:10 UTC
This bug was first reported there:
https://bugs.mageia.org/show_bug.cgi?id=16818

Comment 3 Panu Matilainen 2016-12-16 09:19:02 UTC
All you need is enough escapes to avoid it actually getting expanded inside %expand() because in the spec preamble %license is a macro referring to the contents of the license tag whereas inside %files %license is a spec directive/file attribute, not a macro. This gets the job done (dont ask):

%%%%license LICENSE_1_0.txt