From 4d4028a1bc27834cff094fcd8301ad079438a728 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Fri, 26 Mar 2021 09:59:11 -0600 Subject: name after package manager, not OS --- noRMS-alpine.py | 78 --------------------------------------------------------- noRMS-apk.py | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 78 deletions(-) delete mode 100644 noRMS-alpine.py create mode 100644 noRMS-apk.py diff --git a/noRMS-alpine.py b/noRMS-alpine.py deleted file mode 100644 index 9d79b59..0000000 --- a/noRMS-alpine.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env python3 -import argparse -from pathlib import Path -import re -import subprocess -import sys -import urllib.parse - -parser = argparse.ArgumentParser( - description=""" - noRMS for Alpine. - Checks to see which installed packages are attached to RMS (i.e. the FSF and GNU). - """ -) -parser.add_argument('--verbose', '-v', help='Print more stuff', action='count', default=0) -args = parser.parse_args() - -verbose = args.verbose - -PACKAGE = re.compile(r'^(?P\S+) (?P\S+) \{(?P[^}]+)\} \((?P[^)]+)\) \[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))` -GNU_DOMAINS = set([ - "www.gnu.org", - "puszcza.gnu.org.ua", - "gcc.gnu.org", - "gcompris.net", - "gmplib.org", - # "www.gnome.org", # the GNOME foundation signed https://rms-open-letter.github.io/ so they're OK - "www.gnucash.org", - "gnunet.org", - "www.gnuhealth.org", - "www.list.org", - "www.midnight-commander.org", - "mediagoblin.org", - "www.multiprecision.org", - "www.mpfr.org", - "www.nano-editor.org", - "jemarch.net", - "www.r-project.org", - "savannah.gnu.org", - "www.texmacs.org", - "unifoundry.com" -]) - -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 origin not in origins: - origins[origin] = [] - origins[origin].append(name_and_version) - -rms_count = 0 - -for origin in origins: - info_webpage = subprocess.check_output(['apk', 'info', '-w', origin], text=True) - webpage = info_webpage.splitlines()[1] - 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})') - rms_count += 1 - -print() -print('Total RMS-affiliated packages found:', rms_count) - -if rms_count == 0: - print('Hell yeah!') - sys.exit(0) -else: - sys.exit(1) diff --git a/noRMS-apk.py b/noRMS-apk.py new file mode 100644 index 0000000..425b225 --- /dev/null +++ b/noRMS-apk.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python3 +import argparse +from pathlib import Path +import re +import subprocess +import sys +import urllib.parse + +parser = argparse.ArgumentParser( + description=""" + noRMS for APK-based systems (Alpine). + Checks to see which installed packages are attached to RMS (i.e. the FSF and GNU). + """ +) +parser.add_argument('--verbose', '-v', help='Print more stuff', action='count', default=0) +args = parser.parse_args() + +verbose = args.verbose + +PACKAGE = re.compile(r'^(?P\S+) (?P\S+) \{(?P[^}]+)\} \((?P[^)]+)\) \[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))` +GNU_DOMAINS = set([ + "www.gnu.org", + "puszcza.gnu.org.ua", + "gcc.gnu.org", + "gcompris.net", + "gmplib.org", + # "www.gnome.org", # the GNOME foundation signed https://rms-open-letter.github.io/ so they're OK + "www.gnucash.org", + "gnunet.org", + "www.gnuhealth.org", + "www.list.org", + "www.midnight-commander.org", + "mediagoblin.org", + "www.multiprecision.org", + "www.mpfr.org", + "www.nano-editor.org", + "jemarch.net", + "www.r-project.org", + "savannah.gnu.org", + "www.texmacs.org", + "unifoundry.com" +]) + +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 origin not in origins: + origins[origin] = [] + origins[origin].append(name_and_version) + +rms_count = 0 + +for origin in origins: + info_webpage = subprocess.check_output(['apk', 'info', '-w', origin], text=True) + webpage = info_webpage.splitlines()[1] + 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})') + rms_count += 1 + +print() +print('Total RMS-affiliated packages found:', rms_count) + +if rms_count == 0: + print('Hell yeah!') + sys.exit(0) +else: + sys.exit(1) -- cgit v1.2.3