summaryrefslogtreecommitdiffstats
path: root/debian/bin/check_upstream.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-30 16:45:07 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-30 16:45:07 +0000
commit0ec4a0912294e5ef354ea5074e0446eb364e05c5 (patch)
tree020b497d1954ba229263a78d0b150c97a5cc57e8 /debian/bin/check_upstream.py
parentMerging upstream version 20240709. (diff)
downloadfirmware-nonfree-0ec4a0912294e5ef354ea5074e0446eb364e05c5.tar.xz
firmware-nonfree-0ec4a0912294e5ef354ea5074e0446eb364e05c5.zip
Adding debian version 20240709-2.debian/20240709-2debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/bin/check_upstream.py')
-rwxr-xr-xdebian/bin/check_upstream.py57
1 files changed, 38 insertions, 19 deletions
diff --git a/debian/bin/check_upstream.py b/debian/bin/check_upstream.py
index e2931c4..d69ce75 100755
--- a/debian/bin/check_upstream.py
+++ b/debian/bin/check_upstream.py
@@ -11,7 +11,7 @@ rules_defs = dict((match.group(1), match.group(2))
sys.path.append('/usr/share/linux-support-%s/lib/python' %
rules_defs['KERNELVERSION'])
from debian_linux.firmware import FirmwareWhence
-from config import Config
+from config import Config, pattern_to_re
class DistState(Enum):
undistributable = 1
@@ -20,23 +20,30 @@ class DistState(Enum):
def is_source_available(section):
for file_info in section.files.values():
- if not (file_info.source or file_info.binary.endswith('.cis')):
+ if not (file_info.source
+ or file_info.binary.endswith('.txt')
+ 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):
+ if section.licence is None:
+ # Maybe undistributable
+ return DistState.undistributable
+ elif 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'
+ r'|\bgrants\s+permission\s+to\s+use\s+and\s+redistribute'
+ r'\s+these\s+firmware\s+files\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):
@@ -54,10 +61,16 @@ def main(source_dir='.'):
package in config['base',]['packages']]
with open("debian/copyright") as f:
exclusions = deb822.Deb822(f).get("Files-Excluded", '').strip().split()
- packaged_files = {}
+
+ package_file_res = []
for package in config['base',]['packages']:
- for filename in config['base', package]['files']:
- packaged_files[filename] = package
+ config_entry = config['base', package]
+ package_file_res.append(
+ ([pattern_to_re(pattern)
+ for pattern in config_entry['files']],
+ [pattern_to_re(pattern)
+ for pattern in config_entry.get('files-exclude', [])])
+ )
for section in FirmwareWhence(open(os.path.join(source_dir, 'WHENCE'))):
dist_state = check_section(section)
@@ -65,9 +78,15 @@ def main(source_dir='.'):
if dist_state == DistState.non_free:
if not any(fnmatch.fnmatch(file_info.binary, exclusion)
for exclusion in exclusions):
- if file_info.binary in packaged_files:
+ if any(
+ (any(inc_re.fullmatch(file_info.binary)
+ for inc_re in inc_res)
+ and not any(exc_re.fullmatch(file_info.binary)
+ for exc_re in exc_res))
+ for inc_res, exc_res in package_file_res
+ ):
update_file(source_dir, over_dirs, file_info.binary)
- elif os.path.isfile(filename):
+ elif os.path.isfile(file_info.binary):
print('I: %s is not included in any binary package' %
file_info.binary)
else: