Bug 1386639 - "%license FILENAME" in %expand breaks the build
Summary: "%license FILENAME" in %expand breaks the build
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: rpm
Version: 24
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Packaging Maintenance Team
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-10-19 11:00 UTC by Thierry Vignaud
Modified: 2016-12-16 09:19 UTC (History)
12 users (show)

Fixed In Version:
Clone Of: 1200761
Environment:
Last Closed: 2016-12-16 09:19:02 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
test spec file showing the bug (1.14 KB, text/plain)
2016-10-19 11:00 UTC, Thierry Vignaud
no flags Details
switching to %doc workarounds the issue (1.14 KB, text/plain)
2016-10-19 11:01 UTC, Thierry Vignaud
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Mageia 16818 0 None None None 2016-10-28 18:26:18 UTC

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


Note You need to log in before you can comment on or make changes to this bug.