From: Ben Hutchings <ben@decadent.org.uk>
To: linux-kernel@vger.kernel.org, linux-firmware@kernel.org
Subject: [PATCH linux-firmware 01/12] Add a metadata consistency check script
Date: Sun, 18 Sep 2016 02:59:31 +0100 [thread overview]
Message-ID: <20160918015931.GE10601@decadent.org.uk> (raw)
In-Reply-To: <1474163887.2621.97.camel@decadent.org.uk>
[-- Attachment #1: Type: text/plain, Size: 3035 bytes --]
The script compares the files listed in WHENCE (or otherwise expected)
and the files known to git, and reports all differences as errors.
Add a 'check' rule to the Makefile that runs this.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
Makefile | 3 +++
check_whence.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+)
create mode 100755 check_whence.py
diff --git a/Makefile b/Makefile
index 1b1aa2836c97..d1163b871096 100644
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,9 @@ FIRMWAREDIR = /lib/firmware
all:
+check:
+ ./check_whence.py
+
install:
mkdir -p $(DESTDIR)$(FIRMWAREDIR)
cp -r * $(DESTDIR)$(FIRMWAREDIR)
diff --git a/check_whence.py b/check_whence.py
new file mode 100755
index 000000000000..f83fb197aa57
--- /dev/null
+++ b/check_whence.py
@@ -0,0 +1,56 @@
+#!/usr/bin/python
+
+import os, re, sys
+
+def list_whence():
+ with open('WHENCE') as whence:
+ for line in whence:
+ match = re.match(r'(?:File|Link|Source):\s*(\S*)', line)
+ if match:
+ yield match.group(1)
+ continue
+ 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)):
+ 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):
+ yield match.group(2)
+ continue
+
+def list_git():
+ with os.popen('git ls-files') as git_files:
+ for line in git_files:
+ yield line.rstrip('\n')
+
+def main():
+ whence_list = list(list_whence())
+ known_files = set(name for name in whence_list if not name.endswith('/')) | \
+ set(['check_whence.py', 'configure', 'Makefile',
+ 'README', 'WHENCE'])
+ known_prefixes = set(name for name in whence_list if name.endswith('/'))
+ git_files = set(list_git())
+
+ for name in sorted(list(known_files - git_files)):
+ sys.stderr.write('E: %s listed in WHENCE does not exist\n' % name)
+
+ 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)):
+ continue
+
+ # Ignore unknown files in known directories
+ for prefix in known_prefixes:
+ if name.startswith(prefix):
+ break
+ else:
+ sys.stderr.write('E: %s not listed in WHENCE\n' % name)
+
+if __name__ == '__main__':
+ main()
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 811 bytes --]
next prev parent reply other threads:[~2016-09-18 1:59 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-18 1:58 [PATCH linux-firmware 00/12] Fix metadata for linux-firmware Ben Hutchings
2016-09-18 1:59 ` Ben Hutchings [this message]
2016-09-18 2:00 ` [PATCH linux-firmware 02/12] WHENCE: Correct filename of LICENCE.moxa Ben Hutchings
2016-09-18 2:01 ` [PATCH linux-firmware 03/12] Add copy of GPL v2 and references to the GPL-2 and GPL-3 files Ben Hutchings
2016-09-18 2:01 ` [PATCH linux-firmware 04/12] WHENCE: Specify source directories for cis, isci, and usbdux firmware Ben Hutchings
2016-09-18 2:01 ` [PATCH linux-firmware 05/12] WHENCE: Remove references to source for emi62 firmware Ben Hutchings
2016-09-18 2:02 ` [PATCH linux-firmware 06/12] WHENCE: Remove references to two nvidia firmware files that were never added Ben Hutchings
2016-09-18 6:31 ` Alexandre Courbot
2016-09-18 2:02 ` [PATCH linux-firmware 07/12] Remove unused 'LICENCE.mwl8335' Ben Hutchings
2016-09-18 2:02 ` [PATCH linux-firmware 08/12] WHENCE: Adjust some licence file references to satisfy check_whence.py Ben Hutchings
2016-09-18 2:03 ` [PATCH linux-firmware 09/12] WHENCE: Fix metadata for snd-soc-skl firmware Ben Hutchings
2016-09-19 3:44 ` Vinod Koul
2016-09-18 2:03 ` [PATCH linux-firmware 10/12] WHENCE: List new radeon CI and SI smc firmware Ben Hutchings
2016-09-18 2:08 ` Ben Hutchings
2016-09-19 13:45 ` Deucher, Alexander
2016-09-18 2:04 ` [PATCH linux-firmware 11/12] WHENCE: Add reference to 'qca/NOTICE.txt' Ben Hutchings
2016-09-18 2:04 ` [PATCH linux-firmware 12/12] README: Say that files must be listed in WHENCE, and how to check it Ben Hutchings
2016-09-20 16:48 ` [PATCH linux-firmware 00/12] Fix metadata for linux-firmware Kyle McMartin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160918015931.GE10601@decadent.org.uk \
--to=ben@decadent.org.uk \
--cc=linux-firmware@kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox