125 lines
3.7 KiB
Diff
125 lines
3.7 KiB
Diff
|
From 1dc9372821487ccace23ff1ae9cba6b30f02c91c Mon Sep 17 00:00:00 2001
|
||
|
From: Florian Festi <ffesti@redhat.com>
|
||
|
Date: Tue, 5 Jul 2022 16:34:08 +0200
|
||
|
Subject: [PATCH] Add SourceLicense tag to spec syntax
|
||
|
|
||
|
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
|
||
|
|
||
|
Note on the backport: The spec document on this branch is ancient and
|
||
|
doesn't even contain the License tag's description so this backport
|
||
|
leaves the documentation part out.
|
||
|
|
||
|
(backported from commit 9ed9d3fce34bc3c8121989e0cf263528e7e68756)
|
||
|
---
|
||
|
build/parsePreamble.c | 6 ++++++
|
||
|
lib/rpmtag.h | 3 +++
|
||
|
tests/data/SPECS/foo.spec | 1 +
|
||
|
tests/data/SPECS/hello.spec | 1 +
|
||
|
tests/rpmbuild.at | 11 +++++++++++
|
||
|
tests/rpmspec.at | 1 +
|
||
|
6 files changed, 23 insertions(+)
|
||
|
|
||
|
diff --git a/build/parsePreamble.c b/build/parsePreamble.c
|
||
|
index e7d6d8752..bd07ecdf0 100644
|
||
|
--- a/build/parsePreamble.c
|
||
|
+++ b/build/parsePreamble.c
|
||
|
@@ -831,6 +831,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;
|
||
|
@@ -1012,6 +1017,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")},
|
||
|
diff --git a/lib/rpmtag.h b/lib/rpmtag.h
|
||
|
index 7d1943835..1fd829118 100644
|
||
|
--- a/lib/rpmtag.h
|
||
|
+++ b/lib/rpmtag.h
|
||
|
@@ -375,6 +375,9 @@ typedef enum rpmTag_e {
|
||
|
RPMTAG_MODULARITYLABEL = 5096, /* s */
|
||
|
RPMTAG_PAYLOADDIGESTALT = 5097, /* s[] */
|
||
|
|
||
|
+ /* Backports */
|
||
|
+ RPMTAG_SOURCELICENSE = 5102, /* internal */
|
||
|
+
|
||
|
RPMTAG_FIRSTFREE_TAG /*!< internal */
|
||
|
} rpmTag;
|
||
|
|
||
|
diff --git a/tests/data/SPECS/foo.spec b/tests/data/SPECS/foo.spec
|
||
|
index 859e98142..9b1087094 100644
|
||
|
--- a/tests/data/SPECS/foo.spec
|
||
|
+++ b/tests/data/SPECS/foo.spec
|
||
|
@@ -8,6 +8,7 @@ Source: hello-2.0.tar.gz
|
||
|
Patch1: hello-1.0-modernize.patch
|
||
|
Group: Testing
|
||
|
License: GPLv2+
|
||
|
+SourceLicense: GPL, ASL 1.0
|
||
|
BuildArch: noarch
|
||
|
|
||
|
%description
|
||
|
diff --git a/tests/data/SPECS/hello.spec b/tests/data/SPECS/hello.spec
|
||
|
index 5bc9cfaf7..4b9053aca 100644
|
||
|
--- a/tests/data/SPECS/hello.spec
|
||
|
+++ b/tests/data/SPECS/hello.spec
|
||
|
@@ -4,6 +4,7 @@ Version: 1.0
|
||
|
Release: 1
|
||
|
Group: Utilities
|
||
|
License: GPL
|
||
|
+SourceLicense: GPL, ASL 1.0
|
||
|
Distribution: RPM test suite.
|
||
|
Vendor: Red Hat Software
|
||
|
Packager: Red Hat Software <bugs@redhat.com>
|
||
|
diff --git a/tests/rpmbuild.at b/tests/rpmbuild.at
|
||
|
index bff65303b..7680f1502 100644
|
||
|
--- a/tests/rpmbuild.at
|
||
|
+++ b/tests/rpmbuild.at
|
||
|
@@ -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 -ba autosetup])
|
||
|
diff --git a/tests/rpmspec.at b/tests/rpmspec.at
|
||
|
index 2b11201db..c898ee654 100644
|
||
|
--- a/tests/rpmspec.at
|
||
|
+++ b/tests/rpmspec.at
|
||
|
@@ -243,6 +243,7 @@ Source: hello-2.0.tar.gz
|
||
|
Patch1: hello-1.0-modernize.patch
|
||
|
Group: Testing
|
||
|
License: GPLv2+
|
||
|
+SourceLicense: GPL, ASL 1.0
|
||
|
BuildArch: noarch
|
||
|
|
||
|
%description
|
||
|
--
|
||
|
2.45.2
|
||
|
|