[firmware-nonfree] 05/24: check_upstream.py: Split license check into multiple functions
debian-kernel at lists.debian.org
debian-kernel at lists.debian.org
Sun Oct 18 13:49:55 UTC 2015
This is an automated email from the git hooks/post-receive script.
benh pushed a commit to branch master
in repository firmware-nonfree.
commit d599c6ca3fc04c6a7539b7c9e2cbade63ddea51b
Author: Ben Hutchings <ben at decadent.org.uk>
Date: Fri Oct 16 19:23:19 2015 +0100
check_upstream.py: Split license check into multiple functions
---
debian/bin/check_upstream.py | 73 +++++++++++++++++++++++++-------------------
1 file changed, 41 insertions(+), 32 deletions(-)
diff --git a/debian/bin/check_upstream.py b/debian/bin/check_upstream.py
index 7489a71..a3b2d44 100755
--- a/debian/bin/check_upstream.py
+++ b/debian/bin/check_upstream.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
import errno, filecmp, fnmatch, glob, os.path, re, sys
+from enum import Enum
rules_defs = dict((match.group(1), match.group(2))
for line in open('debian/rules.defs')
for match in [re.match(r'(\w+)\s*:=\s*(.*)\n', line)])
@@ -9,6 +10,41 @@ sys.path.append('/usr/share/linux-support-%s/lib/python' %
from debian_linux.firmware import FirmwareWhence
from debian_linux.config import ConfigParser, SchemaItemList
+class DistState(Enum):
+ undistributable = 1
+ non_free = 2
+ free = 3
+
+def is_source_available(section):
+ for file_info in section.files.values():
+ if not (file_info.source or file_info.binary.endswith('.cis')):
+ return False
+ return True
+
+def check_section(section):
+ if re.search(r'^BSD\b'
+ r'|^GPLv2 or OpenIB\.org BSD\b'
+ r'|\bPermission\s+is\s+hereby\s+granted\s+for\s+the\s+'
+ r'distribution\s+of\s+this\s+firmware\s+(?:data|image)\b'
+ r'(?!\s+as\s+part\s+of)'
+ r'|\bRedistribution\s+and\s+use\s+in(?:\s+source\s+and)?'
+ r'\s+binary\s+forms\b'
+ r'|\bPermission\s+is\s+hereby\s+granted\b[^.]+\sto'
+ r'\s+deal\s+in\s+the\s+Software\s+without'
+ r'\s+restriction\b'
+ r'|\bredistributable\s+in\s+binary\s+form\b',
+ section.licence):
+ return (DistState.free if is_source_available(section)
+ else DistState.non_free)
+ elif re.match(r'^(?:D|Red)istributable\b', section.licence):
+ return DistState.non_free
+ elif re.match(r'^GPL(?:v2|\+)?\b', section.licence):
+ return (DistState.free if is_source_available(section)
+ else DistState.undistributable)
+ else:
+ # Unrecognised and probably undistributable
+ return DistState.undistributable
+
def main(source_dir):
config = ConfigParser({
'base': {'packages': SchemaItemList()},
@@ -19,38 +55,11 @@ def main(source_dir):
exclusions = config['upstream',]['exclude']
for section in FirmwareWhence(open(os.path.join(source_dir, 'WHENCE'))):
- if re.search(r'^BSD\b'
- r'|^GPLv2 or OpenIB\.org BSD\b'
- r'|\bPermission\s+is\s+hereby\s+granted\s+for\s+the\s+'
- r'distribution\s+of\s+this\s+firmware\s+(?:data|image)\b'
- r'(?!\s+as\s+part\s+of)'
- r'|\bRedistribution\s+and\s+use\s+in(?:\s+source\s+and)?'
- r'\s+binary\s+forms\b'
- r'|\bPermission\s+is\s+hereby\s+granted\b[^.]+\sto'
- r'\s+deal\s+in\s+the\s+Software\s+without'
- r'\s+restriction\b'
- r'|\bredistributable\s+in\s+binary\s+form\b',
- section.licence):
- # Suitable for main if source is available; non-free otherwise
- maybe_free = True
- pass
- elif re.match(r'^(?:D|Red)istributable\b', section.licence):
- # Only suitable for non-free
- maybe_free = False
- pass
- elif re.match(r'^GPL(?:v2|\+)?\b', section.licence):
- # Suitable for main if source is available; not distributable
- # otherwise
- continue
- else:
- # Probably not distributable
- continue
- for file_info in section.files.values():
- if (not (maybe_free and
- (file_info.source or file_info.binary.endswith('.cis')))
- and not any(fnmatch.fnmatch(file_info.binary, exclusion)
- for exclusion in exclusions)):
- update_file(source_dir, dest_dirs, file_info.binary)
+ if check_section(section) == DistState.non_free:
+ for file_info in section.files.values():
+ if not any(fnmatch.fnmatch(file_info.binary, exclusion)
+ for exclusion in exclusions):
+ update_file(source_dir, dest_dirs, file_info.binary)
def update_file(source_dir, dest_dirs, filename):
source_file = os.path.join(source_dir, filename)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/kernel/firmware-nonfree.git
More information about the Kernel-svn-changes
mailing list