[PATCH createaport] License: Include the license file in the doc subpackage if the license requires it
Export this patch
---
createaport/aport.py | 13 ++++++++++---
createaport/license.py | 20 +++++++++++++++++++-
2 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/createaport/aport.py b/createaport/aport.py
index c69e4be..175fa6e 100644
--- a/createaport/aport.py
+++ b/createaport/aport.py
@@ -1,3 +1,4 @@
+from createaport.license import needs_license_file
class Aport:
def __init__(self):
self.pkgname = None
@@ -15,6 +16,7 @@ class Aport:
self.depends = []
self.makedepends = []
self.checkdepends = []
+ self.subpackages = set()
self.buildsystem = None
self.subdir = None
@@ -28,16 +30,19 @@ class Aport:
for warning in self.warnings:
apkbuild += '# WARNING: ' + warning + '\n'
+ if needs_license_file(self.license):
+ self.subpackages.add('$pkgname-doc')
+
for key in ['pkgname', 'pyname', 'pkgver', 'pkgrel', 'commit', 'pkgdesc', 'url', 'arch', 'license', 'source',
- 'depends', 'makedepends', 'checkdepends', 'builddir']:
- if getattr(self, key) is None or getattr(self, key) == []:
+ 'depends', 'makedepends', 'checkdepends', 'subpackages', 'builddir']:
+ if getattr(self, key) is None or getattr(self, key) == [] or getattr(self, key) == set():
continue
if key in prefix:
line = f'_{key}='
else:
line = key + '='
value = getattr(self, key)
- if isinstance(value, list):
+ if isinstance(value, list) or isinstance(value, set):
line += '"' + ' '.join(value) + '"\n'
else:
if key in quote:
@@ -98,6 +103,8 @@ class Aport:
apkbuild += '\tmake -j1 DESTDIR="$pkgdir" install\n'
else:
apkbuild += '\t# Cannot autogenerate "' + str(self.buildsystem) + '" buildsystem yet\n'
+ if needs_license_file(self.license):
+ apkbuild += '\tinstall -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE\n'
apkbuild += '}\n\n'
return apkbuild
diff --git a/createaport/license.py b/createaport/license.py
index c105216..31b36f0 100644
--- a/createaport/license.py
+++ b/createaport/license.py
@@ -448,7 +448,25 @@ licenses = [
"xpp",
"zlib-acknowledgement"
]
-
+def needs_license_file(license):
+ """Return true if the license requires distribution of license, or is non-spdx"""
+ # There are undoubtably more. These are the ones which appear in Alpine.
+ needs_licenses = [
+ # TODO: Apache-2.0 requires copying NOTICE file
+ "BSD-2-Clause",
+ "BSD-3-Clause",
+ "curl",
+ "FDK-AAC",
+ "Info-ZIP",
+ "ISC",
+ "PostgreSQL",
+ "PSF-2.0",
+ "Sendmail",
+ "Sendmail-8.23",
+ "MIT",
+ "X11",
+ ]
+ return license in needs_licenses or license not in licenses
def spdxify_license(aport, input):
for l in licenses:
--
2.43.0