From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4H/WI0mJ9mf8Ai0AWB0awg (envelope-from ) for ; Wed, 09 Apr 2025 10:50:49 -0400 Received: by simark.ca (Postfix, from userid 112) id 8E92D1E0C3; Wed, 9 Apr 2025 10:50:49 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 8D1F91E05C for ; Wed, 9 Apr 2025 10:50:48 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3CC75384A415 for ; Wed, 9 Apr 2025 14:50:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3CC75384A415 Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 3E3F2385141F for ; Wed, 9 Apr 2025 14:50:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3E3F2385141F Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3E3F2385141F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1744210206; cv=none; b=TxYhZIri8v6SZ5M4NJE+16GUE/7p9y4a0qKc7wYBRTT3XVYFkZ6rsSO3udxybpf5TYSJs1q6kZbEH3wYL6aW3bYPv8RR9imzQNfujlp0jnsyhHeR/6NQLbDOQ/y0ojR6o7+CWCHS5Sx0ZH9Sq3kUH/rpYJz4osBJOE6Oyy82uSU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1744210206; c=relaxed/simple; bh=DR914xWa4itAFJJIiQ6TO3/5iIt8JYkX6RqwG9PaUJA=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=LmwVOBbKHC/fy5bzzM0zpH778LsrorRMI8sslQLdx4jayMTR49t5ISOVkdSP3sSRSvKbuMjb5jJD/L7c5CY9Xj4a2sUv8FFKi8M7t37CovJhoKmtjnAPnC6fh7fGpIVCyPl8UV9EOHFeMO6YxG+pilno7JJjdXnrVIw4+c5vPW4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3E3F2385141F Received: by simark.ca (Postfix, from userid 112) id CFF791E114; Wed, 9 Apr 2025 10:50:05 -0400 (EDT) Received: from smarchi-efficios.internal.efficios.com (96-127-217-162.qc.cable.ebox.net [96.127.217.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id A8B9C1E0C2; Wed, 9 Apr 2025 10:50:03 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 2/2] gdb: fix bugs in gdb/copyright.py, make it use glob patterns Date: Wed, 9 Apr 2025 10:49:59 -0400 Message-ID: <20250409145002.30405-2-simon.marchi@efficios.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250409145002.30405-1-simon.marchi@efficios.com> References: <20250409145002.30405-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org gdb/copyright.py currently changes some files that it shouldn't: - despite having a `gnulib/import` entry in EXCLUDE_LIST, it does change the files under that directory - it is missing `sim/Makefile.in` Change the exclude list logic to use glob patterns. This makes it easier to specify exclusions of full directories or files by basename, while simplifying the code. Merge EXCLUDE_LIST and NOT_FSF_LIST, since there's no fundamental reason to keep them separate (they are treated identically). I kept the comment that explains that some files are excluded due to not being FSF-licensed. Merge EXCLUDE_ALL_LIST in EXCLUDE_LIST, converting the entries to glob patterns that match everywhere in the tree (e.g. `**/configure`). Tested by running the script on the parent commit of d01e823438c7 ("Update copyright dates to include 2025") and diff'ing the result with d01e823438c7. The only differences are: - the files that we don't want to modify (gnulib/import and sim/Makefile.in) - the files that need to be modified by hand Running the script on latest master produces no diff. Change-Id: I318dc3bff34e4b3a9b66ea305d0c3872f69cd072 --- gdb/copyright.py | 93 +++++++++++++++++++++--------------------------- 1 file changed, 40 insertions(+), 53 deletions(-) diff --git a/gdb/copyright.py b/gdb/copyright.py index 1c81358f1384..50902a8033d2 100755 --- a/gdb/copyright.py +++ b/gdb/copyright.py @@ -36,6 +36,7 @@ import argparse import locale import os import os.path +import pathlib import subprocess import sys from typing import Iterable @@ -68,19 +69,15 @@ def get_update_list(): .split("\0") ) + full_exclude_list = EXCLUDE_LIST + BY_HAND + def include_file(filename: str): - (dirname, basename) = os.path.split(filename) - dirbasename = os.path.basename(dirname) - return not ( - basename in EXCLUDE_ALL_LIST - or dirbasename in EXCLUDE_ALL_LIST - or dirname in EXCLUDE_LIST - or dirname in NOT_FSF_LIST - or dirname in BY_HAND - or filename in EXCLUDE_LIST - or filename in NOT_FSF_LIST - or filename in BY_HAND - ) + path = pathlib.Path(filename) + for pattern in full_exclude_list: + if path.full_match(pattern): + return False + + return True return filter(include_file, result) @@ -212,8 +209,14 @@ def main(argv: list[str]) -> int | None: # generated, non-FSF, or otherwise special (e.g. license text, # or test cases which must be sensitive to line numbering). # -# Filenames are relative to the root directory. -EXCLUDE_LIST = ( +# Entries are treated as glob patterns. +EXCLUDE_LIST = [ + "**/aclocal.m4", + "**/configure", + "**/COPYING.LIB", + "**/COPYING", + "**/fdl.texi", + "**/gpl.texi", "gdb/copying.c", "gdb/nat/glibc_thread_db.h", "gdb/CONTRIBUTE", @@ -221,45 +224,11 @@ EXCLUDE_LIST = ( "gdbsupport/unordered_dense.h", "gnulib/doc/gendocs_template", "gnulib/doc/gendocs_template_min", - "gnulib/import", + "gnulib/import/**", "gnulib/config.in", "gnulib/Makefile.in", -) - -# Files which should not be modified, either because they are -# generated, non-FSF, or otherwise special (e.g. license text, -# or test cases which must be sensitive to line numbering). -# -# Matches any file or directory name anywhere. Use with caution. -# This is mostly for files that can be found in multiple directories. -# Eg: We want all files named COPYING to be left untouched. - -EXCLUDE_ALL_LIST = ( - "COPYING", - "COPYING.LIB", - "configure", - "fdl.texi", - "gpl.texi", - "aclocal.m4", -) - -# The list of files to update by hand. -BY_HAND: list[str] = [ - # Nothing at the moment :-). -] - -# Files containing multiple copyright headers. This script is only -# fixing the first one it finds, so we need to finish the update -# by hand. -MULTIPLE_COPYRIGHT_HEADERS = ( - "gdb/doc/gdb.texinfo", - "gdb/doc/refcard.tex", - "gdb/syscalls/update-netbsd.sh", -) - -# The list of file which have a copyright, but not held by the FSF. -# Filenames are relative to the root directory. -NOT_FSF_LIST = ( + "sim/Makefile.in", + # The files below have a copyright, but not held by the FSF. "gdb/exc_request.defs", "gdb/gdbtk", "gdb/testsuite/gdb.gdbtk/", @@ -296,9 +265,27 @@ NOT_FSF_LIST = ( "sim/mips/sim-main.c", "sim/moxie/moxie-gdb.dts", # Not a single file in sim/ppc/ appears to be copyright FSF :-(. - "sim/ppc", + "sim/ppc/**", "sim/testsuite/mips/mips32-dsp2.s", -) +] + +# The list of files to update by hand. +# +# Entries are treated as glob patterns. +BY_HAND: list[str] = [ + # Nothing at the moment :-). +] + +# Files containing multiple copyright headers. This script is only +# fixing the first one it finds, so we need to finish the update +# by hand. +# +# Entries are treated as glob patterns. +MULTIPLE_COPYRIGHT_HEADERS = [ + "gdb/doc/gdb.texinfo", + "gdb/doc/refcard.tex", + "gdb/syscalls/update-netbsd.sh", +] if __name__ == "__main__": sys.exit(main(sys.argv[1:])) -- 2.49.0