From 27fb2f63684944a6ed5a7e5356471968bb2b282d Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Wed, 3 Aug 2022 14:24:48 -0500 Subject: [PATCH 1/4] check_whence: reformat using python black Signed-off-by: Mario Limonciello --- check_whence.py | 85 +++++++++++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 35 deletions(-) diff --git a/check_whence.py b/check_whence.py index d45d90f8..bf14aed6 100755 --- a/check_whence.py +++ b/check_whence.py @@ -3,48 +3,53 @@ import os, re, sys from io import open + def list_whence(): - with open('WHENCE', encoding='utf-8') as whence: + with open("WHENCE", encoding="utf-8") as whence: for line in whence: match = re.match(r'(?:File|Source):\s*"(.*)"', line) if match: yield match.group(1) continue - match = re.match(r'(?:File|Source):\s*(\S*)', line) + match = re.match(r"(?:File|Source):\s*(\S*)", line) if match: yield match.group(1) continue - match = re.match(r'Licen[cs]e: (?:.*\bSee (.*) for details\.?|(\S*))\n', - line) + match = re.match( + r"Licen[cs]e: (?:.*\bSee (.*) for details\.?|(\S*))\n", line + ) if match: if match.group(1): - for name in re.split(r', | and ', match.group(1)): + for name in re.split(r", | and ", match.group(1)): yield name continue if match.group(2): # Just one word - may or may not be a filename - if not re.search(r'unknown|distributable', match.group(2), - re.IGNORECASE): + if not re.search( + r"unknown|distributable", match.group(2), re.IGNORECASE + ): yield match.group(2) continue + def list_whence_files(): - with open('WHENCE', encoding='utf-8') as whence: + with open("WHENCE", encoding="utf-8") as whence: for line in whence: - match = re.match(r'File:\s*(.*)', line) + match = re.match(r"File:\s*(.*)", line) if match: - yield match.group(1).replace("\ ", " ").replace("\"", "") + yield match.group(1).replace("\ ", " ").replace('"', "") continue + def list_links_list(): - with open('WHENCE', encoding='utf-8') as whence: + with open("WHENCE", encoding="utf-8") as whence: for line in whence: - match = re.match(r'Link:\s*(.*)', line) + match = re.match(r"Link:\s*(.*)", line) if match: linkname, target = match.group(1).split("->") - linkname = linkname.strip().replace("\ ", " ").replace("\"", "") - target = target.strip().replace("\ ", " ").replace("\"", "") + linkname = linkname.strip().replace("\ ", " ").replace('"', "") + target = target.strip().replace("\ ", " ").replace('"', "") # Link target is relative to the link target = os.path.join(os.path.dirname(linkname), target) @@ -53,42 +58,49 @@ def list_links_list(): yield (linkname, target) continue + def list_git(): - with os.popen('git ls-files') as git_files: + with os.popen("git ls-files") as git_files: for line in git_files: - yield line.rstrip('\n') + yield line.rstrip("\n") + def main(): ret = 0 whence_list = list(list_whence()) whence_files = list(list_whence_files()) links_list = list(list_links_list()) - known_files = set(name for name in whence_list if not name.endswith('/')) | \ - set(['check_whence.py', 'configure', 'Makefile', - 'README', 'copy-firmware.sh', 'WHENCE']) - known_prefixes = set(name for name in whence_list if name.endswith('/')) + known_files = set(name for name in whence_list if not name.endswith("/")) | set( + [ + "check_whence.py", + "configure", + "Makefile", + "README", + "copy-firmware.sh", + "WHENCE", + ] + ) + known_prefixes = set(name for name in whence_list if name.endswith("/")) git_files = set(list_git()) - for name in set(name for name in whence_files if name.endswith('/')): - sys.stderr.write('E: %s listed in WHENCE as File, but is directory\n' % - name) + for name in set(name for name in whence_files if name.endswith("/")): + sys.stderr.write("E: %s listed in WHENCE as File, but is directory\n" % name) ret = 1 for name in set(fw for fw in whence_files if whence_files.count(fw) > 1): - sys.stderr.write('E: %s listed in WHENCE twice\n' % name) + sys.stderr.write("E: %s listed in WHENCE twice\n" % name) ret = 1 for name in set(link for link in whence_files if os.path.islink(link)): - sys.stderr.write('E: %s listed in WHENCE as File, but is a symlink\n' % - name) + sys.stderr.write("E: %s listed in WHENCE as File, but is a symlink\n" % name) ret = 1 for name in set(link[0] for link in links_list if os.path.islink(link[0])): - sys.stderr.write('E: %s listed in WHENCE as Link, is in tree\n' % name) + sys.stderr.write("E: %s listed in WHENCE as Link, is in tree\n" % name) ret = 1 for name in sorted(list(known_files - git_files)): - sys.stderr.write('E: %s listed in WHENCE does not exist\n' % name) + sys.stderr.write("E: %s listed in WHENCE does not exist\n" % name) ret = 1 # A link can point to another link, or to a file... @@ -99,20 +111,22 @@ def main(): dirname = target while True: dirname = os.path.dirname(dirname) - if dirname == '': + if dirname == "": break valid_targets.add(dirname) for name, target in sorted(links_list): if target not in valid_targets: - sys.stderr.write('E: target %s of link %s in WHENCE' - ' does not exist\n' % (target, name)) + sys.stderr.write( + "E: target %s of link %s in WHENCE" " does not exist\n" % (target, name) + ) ret = 1 for name in sorted(list(git_files - known_files)): # Ignore subdirectory changelogs and GPG detached signatures - if (name.endswith('/ChangeLog') or - (name.endswith('.asc') and name[:-4] in known_files)): + if name.endswith("/ChangeLog") or ( + name.endswith(".asc") and name[:-4] in known_files + ): continue # Ignore unknown files in known directories @@ -120,9 +134,10 @@ def main(): if name.startswith(prefix): break else: - sys.stderr.write('E: %s not listed in WHENCE\n' % name) + sys.stderr.write("E: %s not listed in WHENCE\n" % name) ret = 1 return ret -if __name__ == '__main__': + +if __name__ == "__main__": sys.exit(main()) From c442a5002c8311dc512a844e6c0335270db1e5f3 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Tue, 29 Aug 2023 17:00:06 -0500 Subject: [PATCH 2/4] Add pre-commit hooks and codespell template Signed-off-by: Mario Limonciello --- .codespell.cfg | 4 ++++ .gitignore | 1 + .pre-commit-config.yaml | 26 ++++++++++++++++++++++++++ check_whence.py | 3 +++ 4 files changed, 34 insertions(+) create mode 100644 .codespell.cfg create mode 100644 .gitignore create mode 100644 .pre-commit-config.yaml diff --git a/.codespell.cfg b/.codespell.cfg new file mode 100644 index 00000000..52e86fc1 --- /dev/null +++ b/.codespell.cfg @@ -0,0 +1,4 @@ +[codespell] +builtin = clear,informal,en-GB_to_en-US +skip = .git,carl9170fw,licence +ignore-words-list = fils diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..fcf54f43 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +debian/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..63609924 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,26 @@ +default_stages: [commit] +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.0.1 + hooks: + - id: check-executables-have-shebangs + - id: forbid-new-submodules + - id: check-yaml + - id: check-symlinks + - id: destroyed-symlinks +- repo: https://github.com/ambv/black + rev: 22.6.0 + hooks: + - id: black +- repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.33.0 + hooks: + - id: markdownlint + args: ['--fix'] +- repo: local + hooks: + - id: check-whence + name: Check whence + files: 'WHENCE' + language: script + entry: ./check_whence.py diff --git a/check_whence.py b/check_whence.py index bf14aed6..4199b903 100755 --- a/check_whence.py +++ b/check_whence.py @@ -72,6 +72,9 @@ def main(): links_list = list(list_links_list()) known_files = set(name for name in whence_list if not name.endswith("/")) | set( [ + ".gitignore", + ".codespell.cfg", + ".pre-commit-config.yaml", "check_whence.py", "configure", "Makefile", From 5e2367f8ea5e91d68d564d721c57e8aa0d5c7d9e Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Tue, 15 Aug 2023 12:52:13 -0500 Subject: [PATCH 3/4] Wire up pre-commit to `make check` This will let `make check` cover more things than just `WHENCE`. Signed-off-by: Mario Limonciello --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 50a4c29b..75039ccb 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,11 @@ FIRMWAREDIR = /lib/firmware all: check: - @./check_whence.py + @if ! which pre-commit >/dev/null; then \ + echo "Install pre-commit to check files"; \ + exit 1; \ + fi + @pre-commit run --all-files install: install -d $(DESTDIR)$(FIRMWAREDIR) From 408eb34a782bae08f48eac22f5d76026ae725146 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Tue, 15 Aug 2023 12:33:17 -0500 Subject: [PATCH 4/4] Rewrite README in markdown This will make it render more nicely if linux-firmware.git moves to Gitlab or a fork of it is hosted in Gitlab. Signed-off-by: Mario Limonciello --- README | 43 ---------------------------------------- README.md | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ check_whence.py | 2 +- 3 files changed, 53 insertions(+), 44 deletions(-) delete mode 100644 README create mode 100644 README.md diff --git a/README b/README deleted file mode 100644 index 77ff0106..00000000 --- a/README +++ /dev/null @@ -1,43 +0,0 @@ - - Linux firmware - ============== - - - - git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git - -This repository contains all these firmware images which have been -extracted from older drivers, as well various new firmware images which -we were never permitted to include in a GPL'd work, but which we _have_ -been permitted to redistribute under separate cover. - -To submit firmware to this repository, please send either a git binary -diff or preferably a git pull request to: - linux-firmware@kernel.org -and also cc: to related mailing lists. - -If your commit adds new firmware, it must update the WHENCE file to -clearly state the license under which the firmware is available, and -that it is redistributable. Being redistributable includes ensuring -the firmware license provided includes an implicit or explicit -patent grant to end users to ensure full functionality of device -operation with the firmware. If the license is long and involved, it's -permitted to include it in a separate file and refer to it from the -WHENCE file ('See LICENSE.foo for details.'). -And if it were possible, a changelog of the firmware itself. - -Run 'make check' to check that WHENCE is consistent with the -repository contents. - -Ideally, your commit should contain a Signed-Off-By: from someone -authoritative on the licensing of the firmware in question (i.e. from -within the company that owns the code). - - -WARNING: -======= - -Don't send any "CONFIDENTIALITY STATEMENT" in your e-mail, patch or -request. Otherwise your firmware _will never be accepted_. - -Maintainers are really busy, so don't expect a prompt reply. diff --git a/README.md b/README.md new file mode 100644 index 00000000..3c73b324 --- /dev/null +++ b/README.md @@ -0,0 +1,52 @@ + +# Linux firmware + +This repository contains all these firmware images which have been +extracted from older drivers, as well various new firmware images which +we were never permitted to include in a GPL'd work, but which we _have_ +been permitted to redistribute under separate cover. + +The upstream repository is located at . + +## Submitting firmware + +To submit firmware to this repository, please do one of the following: + +* open a MR [upstream](https://gitlab.com/kernel-firmware/linux-firmware) +* send a git binary diff to `linux-firmware@kernel.org` +* send a git pull request to: `linux-firmware@kernel.org` + +## Quality + +If your commit adds new firmware, it must update the `WHENCE` file to +clearly state the license under which the firmware is available, and +that it is redistributable. Being redistributable includes ensuring +the firmware license provided includes an implicit or explicit +patent grant to end users to ensure full functionality of device +operation with the firmware. If the license is long and involved, it's +permitted to include it in a separate file and refer to it from the +`WHENCE` file (IE _'See `LICENSE.foo` for details.'_). +And if it were possible, a changelog of the firmware itself. + +To maintain consistent quality on the repository, please run the following +before submitting a patch: + +```shell +make check +``` + +If you don't have pre-commit installed, you can install it with: + +```shell +pip install pre-commit +``` + +Your commit **must** contain a `Signed-Off-By:` from someone authoritative on +the licensing of the firmware in question (i.e. from within the company +that owns the code). + +## Warnings + +1. Don't send any `CONFIDENTIALITY STATEMENT` in your e-mail, patch or +request. Otherwise your firmware _will never be accepted_. +2. Maintainers are really busy, so don't expect a prompt reply. diff --git a/check_whence.py b/check_whence.py index 4199b903..884e8d0c 100755 --- a/check_whence.py +++ b/check_whence.py @@ -78,7 +78,7 @@ def main(): "check_whence.py", "configure", "Makefile", - "README", + "README.md", "copy-firmware.sh", "WHENCE", ]