Skip to content

Commit

Permalink
Add SourceLicense tag to spec syntax
Browse files Browse the repository at this point in the history
to set a separate license to the source RPM. This can be useful if the
sources have code under additional licenses that do not end up in the
binary packeges.

Resolves: #2079
  • Loading branch information
ffesti authored and dmnks committed Jul 14, 2022
1 parent 85d92ca commit 9ed9d3f
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions build/parsePreamble.c
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,11 @@ static rpmRC handlePreambleTag(rpmSpec spec, Package pkg, rpmTagVal tag,
if (addLangTag(spec, pkg->header, tag, field, lang))
goto exit;
break;
case RPMTAG_SOURCELICENSE:
if (addLangTag(spec, spec->sourcePackage->header,
RPMTAG_LICENSE, field, lang))
goto exit;
break;
case RPMTAG_BUILDROOT:
/* just silently ignore BuildRoot */
break;
Expand Down Expand Up @@ -1005,6 +1010,7 @@ static struct PreambleRec_s const preambleList[] = {
{RPMTAG_EPOCH, 0, 0, 1, LEN_AND_STR("epoch")},
{RPMTAG_SUMMARY, 1, 0, 1, LEN_AND_STR("summary")},
{RPMTAG_LICENSE, 0, 0, 1, LEN_AND_STR("license")},
{RPMTAG_SOURCELICENSE, 0, 0, 1, LEN_AND_STR("sourcelicense")},
{RPMTAG_DISTRIBUTION, 0, 0, 1, LEN_AND_STR("distribution")},
{RPMTAG_DISTURL, 0, 0, 1, LEN_AND_STR("disturl")},
{RPMTAG_VENDOR, 0, 0, 1, LEN_AND_STR("vendor")},
Expand Down
6 changes: 6 additions & 0 deletions docs/manual/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ Short (< 70 characters) summary of the package license. For example:
License: GPLv3
```

#### SourceLicense

If license of the sources differ from the main package the license tag
of the source package can be set with this. If not given the license
tag of the source and the main package are the same.

#### Group

Optional, short (< 70 characters) group of the package.
Expand Down
1 change: 1 addition & 0 deletions include/rpm/rpmtag.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ typedef enum rpmTag_e {
RPMTAG_SPEC = 5099, /* s */
RPMTAG_TRANSLATIONURL = 5100, /* s */
RPMTAG_UPSTREAMRELEASES = 5101, /* s */
RPMTAG_SOURCELICENSE = 5102, /* internal */

RPMTAG_FIRSTFREE_TAG /*!< internal */
} rpmTag;
Expand Down
1 change: 1 addition & 0 deletions tests/data/SPECS/hello.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Version: 1.0
Release: 1
Group: Utilities
License: GPL
SourceLicense: GPL, ASL 1.0
Distribution: RPM test suite.
URL: http://rpm.org
Source0: hello-1.0.tar.gz
Expand Down
11 changes: 11 additions & 0 deletions tests/rpmbuild.at
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ run rpmbuild \
[0],
[ignore],
[ignore])

AT_CHECK([

runroot rpm -qp --qf "%{license}\n" /build/SRPMS/hello-1.0-1.src.rpm
runroot rpm -qp --qf "%{license}\n" /build/RPMS/*/hello-1.0-1.*.rpm
],
[0],
[GPL, ASL 1.0
GPL
],
[])
AT_CLEANUP

AT_SETUP([rpmbuild -b steps])
Expand Down
1 change: 1 addition & 0 deletions tests/rpmspec.at
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ Version: 1.0
Release: 1
Group: Utilities
License: GPL
SourceLicense: GPL, ASL 1.0
Distribution: RPM test suite.
URL: http://rpm.org
Source0: hello-1.0.tar.gz
Expand Down

0 comments on commit 9ed9d3f

Please sign in to comment.