From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755892AbcIRB7s (ORCPT ); Sat, 17 Sep 2016 21:59:48 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:50370 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755176AbcIRB7d (ORCPT ); Sat, 17 Sep 2016 21:59:33 -0400 Date: Sun, 18 Sep 2016 02:59:31 +0100 From: Ben Hutchings To: linux-kernel@vger.kernel.org, linux-firmware@kernel.org Message-ID: <20160918015931.GE10601@decadent.org.uk> References: <1474163887.2621.97.camel@decadent.org.uk> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="7CZp05NP8/gJM8Cl" Content-Disposition: inline In-Reply-To: <1474163887.2621.97.camel@decadent.org.uk> User-Agent: Mutt/1.5.23 (2014-03-12) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: ben@decadent.org.uk Subject: [PATCH linux-firmware 01/12] Add a metadata consistency check script X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on shadbolt.decadent.org.uk) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --7CZp05NP8/gJM8Cl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 --- 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 =3D /lib/firmware =20 all: =20 +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 =3D re.match(r'(?:File|Link|Source):\s*(\S*)', line) + if match: + yield match.group(1) + continue + match =3D 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 =3D list(list_whence()) + known_files =3D set(name for name in whence_list if not name.endswith(= '/')) | \ + set(['check_whence.py', 'configure', 'Makefile', + 'README', 'WHENCE']) + known_prefixes =3D set(name for name in whence_list if name.endswith('= /')) + git_files =3D 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__ =3D=3D '__main__': + main() --7CZp05NP8/gJM8Cl Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIVAwUBV931A+e/yOyVhhEJAQpNmg/+MdmMvIwsQbzELRamtEH1TfIQGJBdZK4F v+tfFvQFvMHSWg7r4EHo95/xoeiqhxDzKJ9tt6L+uXyFRPJsTq1vU36FMSpZAksX OHTFbw2S14Ga9Vmk0gz7WCXUUxz9XOopfbLediqQvOmv/d823R3zzf/9Xc6bzyVo 7tJP+uyuOJTryqY+g+NqbN6VRxCGl195WDKeoDBY7z+KyOOncnclAAovcDp/URgG gPW18gm3WlnWrKyO6ZbqdeJ+eYDW+Qg/6f314b9zFDCeca1m7WBg/uVzdlPB3nVR Ob/5DsaZyund4TYsAhdWihhyGONSXrK6wCvsnfbrAzwWtLD0pwtx6cFGpQiLqBta tAmvJcoYpzOvPkmral72Rw9SLN1Gk6ldL1lKb070wQ1ft3XxQuVpENdfB5C8T3jo glhelpAAtqv4l3XYF5i5f2iW3J3p8PnQxeOnxqX90ek1efTZKHJZjIz9ylVajEY/ 0lItUmU4IUJGfE/toLm15hrPIfKrCY3oK7EsZr1646kYGNHtldQemRxfS1PfNw9m Yv2/Ph12ip7O09pa+fsJb9lsmzEGhD/lP9+kufR8R0xv9+JmCtX2eVtX7xJzLp9R uxUYh9MT8hMs8qEKTzGMF3pcynEtBH/dvQclIuy9FxHIxwr76sLY6qA49lSR+LL6 g5YDPTSHpv4= =Tr5k -----END PGP SIGNATURE----- --7CZp05NP8/gJM8Cl--