aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-03-26 10:52:33 -0600
committerMelody Horn <melody@boringcactus.com>2021-03-26 10:52:33 -0600
commitc50cbacfd87bf8ac9923fa63f8c818dbf6b2ede6 (patch)
treea613b028056ee58a932167019c6c14cf6472e643
parent47a9e408ff40a51a253bcae0a8e4e39ce2ea1cbc (diff)
downloadnoRMS-canon.tar.gz
noRMS-canon.zip
become faster & more accurate on APKHEADcanon
-rw-r--r--noRMS-apk.py26
1 files changed, 16 insertions, 10 deletions
diff --git a/noRMS-apk.py b/noRMS-apk.py
index a3039c3..b05456a 100644
--- a/noRMS-apk.py
+++ b/noRMS-apk.py
@@ -17,7 +17,7 @@ args = parser.parse_args()
verbose = args.verbose
-PACKAGE = re.compile(r'^(?P<name_and_version>\S+) (?P<arch>\S+) \{(?P<origin>[^}]+)\} \((?P<licenses>[^)]+)\) \[installed\]$')
+PACKAGE = re.compile(r'^(?P<name>\S+)-[\d\w\._]+-r\d+ \S+ \{(?P<origin>[^}]+)\} \([^)]+\) \[installed\]$')
# from https://directory.fsf.org/wiki/GNU:
# `new Set([].map.call(document.querySelectorAll('table tr td:nth-child(3)'), x => new URL(x.innerText).host))`
@@ -49,25 +49,31 @@ origins = dict()
all_packages = subprocess.check_output(['apk', 'list', '--installed'], text=True)
for package in all_packages.splitlines():
match = PACKAGE.match(package)
- name_and_version, arch, origin, licenses = match['name_and_version'], match['arch'], match['origin'], match['licenses']
+ if match is None:
+ print('oops!', package)
+ name, origin = match['name'], match['origin']
if origin not in origins:
origins[origin] = []
- origins[origin].append(name_and_version)
+ origins[origin].append(name)
+
+info_output = subprocess.check_output(['apk', 'info', '-wv', *origins.keys()], text=True)
+package_webpage_map = dict(x.split(': ', 1) for x in info_output.splitlines())
rms_count = 0
-origin_keys = list(origins.keys())
-info_output = subprocess.check_output(['apk', 'info', '-w', *origin_keys], text=True)
-info_pieces = info_output.split('\n\n')
-for origin, info in zip(origin_keys, info_pieces):
- webpage = info.splitlines()[1]
+for origin in origins:
+ webpage = package_webpage_map[origin]
parsed_url = urllib.parse.urlparse(webpage)
host = parsed_url.netloc
if verbose >= 1:
print('origin:', origin, 'host:', host, 'webpage:', webpage)
if host in GNU_DOMAINS:
- package_text = ', '.join(origins[origin])
- print(f'error: {origin} ({package_text}) is GNU software (website is {webpage})')
+ subpackages = [x for x in origins[origin] if x != origin]
+ if len(subpackages) == 0:
+ package_text = ''
+ else:
+ package_text = ' (& ' + ', '.join(sorted(subpackages)) + ')'
+ print(f'error: {origin}{package_text} is GNU software (website is {webpage})')
rms_count += 1
print()