Ticket #116 (closed defect: fixed)

Opened 6 years ago

Last modified 2 months ago

Add/Improve %license tag handling

Reported by: spot Assigned to: pmatilai
Priority: major Milestone:
Component: rpm Version: RPM Development
Keywords: Cc:


Currently, Fedora uses "%doc" to mark license texts, but this is not optimal for many reasons. Some licenses require that the text of the license always accompany the software, even in scenarios where --nodocs would otherwise make sense.

I propose that the %license tag be created to handle license texts.

With this tag, we would now have a way to differentiate the license text from other documentation. This is important, because in Fedora, we are currently duplicating common license texts in multiple locations, simply to ensure compliance. It would be ideal if RPM contained logic along these lines:

1. Package marks license text as %license:


2. Upon installation, rpm looks in %_licensedir (customizable, but as a default suggestion, /usr/share/licenses/) to see if any identical files (identical to %license) are already present on the system.

3a. If an identical copy is already found in %_licensedir, do not install the license text (COPYING), but create it in %_defaultdocdir as a hardlink to the copy in %_licensedir.

3b. If an identical copy is not found in %licensedir, copy the license text to %_defaultdocdir.

***** That scenario would permit Fedora to create a "common-licenses" package that would be part of a default installation, and minimize the license footprint.

Change History

07/07/10 21:48:39 changed by james

Note that I just did:


...with output here (the above code requires the latest HEAD atm.):


...doesn't seem like a huge win space wise, atm. ... but that might change with the recent Fedora change for license requirements.

07/08/10 14:15:26 changed by pzb

%license already exists in RPM (has for years). However it behaves more like %ghost than %doc, IIRC. This means you need to give the full path to the file, not a relative path. While it does not solve steps 2 and 3, it should help with the --nodocs problem.

07/08/10 14:16:25 changed by spot

RPMTAG_LICENSE exists, but I don't believe it is hooked into anything in the current codebase. Could be wrong.

07/09/10 10:42:17 changed by pmatilai

It "works", but is rather broken.

%license qualifier in %files list originates from the days when the License preamble-tag was known as Copyright, and now there's a namespace collision. So in order to use "%license /some/path" you need to escape with "%%license /some/path". But it doesn't get used for anything at all, never was. And it's cumbersome to use.

The problem for making %license behave similarly to %doc is that %doc is implemented in such a godforsakenly hacky way it's not extensible at all. Not saying it can't be done, just needs somebody to get around to rewrite the thing in a saner way (see also ticket #53 which is kinda related)

05/28/12 14:52:02 changed by pmatilai

  • owner changed from RpmTickets to pmatilai.
  • status changed from new to assigned.

A big pile of commits (to make the "special docs" mechanism a little less, erm, "special") later...

Just pushed something towards this direction to rpm.org master. No special install-time copying/relocation/hardlink magic at least so far, just making %license behave similarly to %doc but placing licenses to a separate directory structure and --nodocs will not affect their installation as they're only tagged as license files, not documentation. So you can now do eg

%license COPYING

%doc does what it always did, %license on non-absolute paths creates another "special" directory (/usr/share/licenses/%{name}-%{version} by default) where the licenses are copied. Simple and maybe a bit stupid, but then I'm not entirely convinced these really deserve any special install-time magic as they're not that big... and for space-constrained situations like live-images one can always just run hardlink on the entire licenses directory. OTOH hardlinking the tree automatically might be reasonable, I'll need to think about the "optimization" part a bit more.

05/29/12 14:16:06 changed by spot

The benefit from hardlinking is reflected by the fact that in the majority of cases (e.g. GPL/LGPL), COPYING is going to be identical, and while we need it to be present, we don't need 100+ identical copies of it.

I admit its not a huge size win, but I still think we should try to do it.

03/11/16 10:17:07 changed by FlorianFesti

  • status changed from assigned to closed.
  • resolution set to fixed.

There is a %license tag for quite a while now. Although the hardlink feature is still missing I am closing this for now. Having hardlinks on files outside of the package is quite tricky. May be going for symlinks can solve this.