From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id iYNuBMAe+WcZzi8AWB0awg (envelope-from ) for ; Fri, 11 Apr 2025 09:53:04 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hq14CNWF; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id F36441E0C3; Fri, 11 Apr 2025 09:53:03 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham 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 9E2BC1E05C for ; Fri, 11 Apr 2025 09:53:02 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 17F413830B51 for ; Fri, 11 Apr 2025 13:53:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 17F413830B51 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hq14CNWF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id BA657385DDCB for ; Fri, 11 Apr 2025 13:52:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BA657385DDCB Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BA657385DDCB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1744379545; cv=none; b=URiHpdABtBikhryvijyxzUpe3MERXshS77ub6JR950uH0VlmwdXqSz5mWOi0qsnXhx0nr+qD/PDoChnFwQTREm+YQQdE04JmeVuz5/Cynmf/Jcjr52k9d7FuOSq4s5HowHfmoEwg/gQGtx/rRjnvJJCTU2/klVr91QaFX0v6MDs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1744379545; c=relaxed/simple; bh=MZ38lIKAAKqW5zfkvVzhRra9siJHVXUS+AatAnmhZZ0=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=KvL534CN4E5nFQqaI19Kl40jD+oge1zk2jDVapX/YSQwy7qJblX6KZhAZSL4VxY/DkvF0uW38AMxz1uxmqyIajUyRCvXzNi6DrFJbRR5BINu2Gg6T/4w8zGDh+eGLbr1wI8jL+GkK8g9Yvjb276XpG/8ht1OgQsQNrDgC/xc1U8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA657385DDCB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744379545; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xFxZtbfypFC1gAhI44L02FKrG1Eht2ht3KSslxj0gCs=; b=hq14CNWFpAIXXWRTvDUSVuc6t4ljAU/4IyPQMtRhbVkOCku/MlnylETR3gYZBWYhW84DnI c5M/IQ0hh/ov5RoCWtfnqmbsbLh7NT4pQDP2I3ebZd/1TW7q6Tq08TmHSXJWxFZH2UG0q4 56Z0WmaWAw4m1CNk8A824x4WBIxRKqY= Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-653-OkMM4BDKPEW11FcrTEwtVA-1; Fri, 11 Apr 2025 09:52:24 -0400 X-MC-Unique: OkMM4BDKPEW11FcrTEwtVA-1 X-Mimecast-MFC-AGG-ID: OkMM4BDKPEW11FcrTEwtVA_1744379543 Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-22647ff3cf5so17409205ad.0 for ; Fri, 11 Apr 2025 06:52:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744379543; x=1744984343; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xFxZtbfypFC1gAhI44L02FKrG1Eht2ht3KSslxj0gCs=; b=cT/njyysgDwbPc2JWjHz2c+1qTSxPXU6+2olW7htL215DE0sd+b3WxavWlApRYFoD3 loJrfIM3o4ThY0pqealemnrWoPgNYq4Sez/x0h52ZPAhO/e1lv9cKVIloxoUR3eUowUN 8ARe/n34f+yXhZzSNDvE5pLJMGCDbrvAj3YMRN6GGluv5feMn0nUMm6TCgvGNeYr6sx9 ZKWEy4kDURhDG52BiIrn4OrddgTOD4W9NemZFTFmc95YWmp+7YDlU2BpwBZ2iAnUVLj0 xWAJngD09dXPgo63pPrwM6XvYH5liuVD9mIHahDh1UXpG4aY1Sc8wOXkAhsLPZaMCvHU X3pQ== X-Forwarded-Encrypted: i=1; AJvYcCVSS9lwHMA25/OhMlvcz4MnVrqsXxfQSzc4+36iSr2CVgFCjKVXinLdQKq+xSVXWDd5WngFly16KREajA==@sourceware.org X-Gm-Message-State: AOJu0YyNCvVphWF56cuv3htcPPiEh/qijraVfUY3zOZ30w0uk+x5vQMu YQfxFUKuXRF6Hfr66JpCDdvUfHI1QFsVNA3jODszt1/lKZ+nzB7LGwycdzbJOvpVUSwhD+7+ZGV 3sdOvJ95KvJe3Xm/XVPDYdrN2ohCjFnkvd7ddg53SIeKBUZH5mOxwZa9yQHhyUJNV3Gk= X-Gm-Gg: ASbGncvI+qYkY0uPTSCDMBRryem8l7YQB7Dpc8Jk12fX3tDRO9OQpQbQ5YkVCg4QxLf 6AE40YQcdQ/XmsMqECB3AW389E36DZ2dA10zirbZPYsdue/sjfSQQFJbe71YHR6bSbHT78EnAA0 ZU7A3Jv8laJAsuzYdycXgwzU0kxLF/Fus7m9cxm12Xx8UvyMKAekzVhus5iTWt6oIJ4XTB4zsTq A8x0z+SCZWHUqtM81kqLVTrOXLKrAYgHOWodvwblDJqZY7D1KWDXSD/0cWiBlX0B8Njqw/ZENVc xuKs0heiYqITD+FBUcnNkrw= X-Received: by 2002:a17:903:3c6c:b0:224:78e:4ebe with SMTP id d9443c01a7336-22bea4f26e7mr40999295ad.33.1744379542868; Fri, 11 Apr 2025 06:52:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHzZLKsyOAqVUo0eILKnllbBJWHdZ6Vj2zw9VZ7S9/hTk2sDPhi2SnxTHrLaFhi7itZbPIWCg== X-Received: by 2002:a17:903:3c6c:b0:224:78e:4ebe with SMTP id d9443c01a7336-22bea4f26e7mr40998965ad.33.1744379542511; Fri, 11 Apr 2025 06:52:22 -0700 (PDT) Received: from ?IPV6:2804:14d:8084:9a69::1001? ([2804:14d:8084:9a69::1001]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22ac7c993a7sm48863085ad.146.2025.04.11.06.52.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Apr 2025 06:52:22 -0700 (PDT) Message-ID: <74ee87af-688f-4567-bc7d-042597b2c723@redhat.com> Date: Fri, 11 Apr 2025 10:52:19 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] gdb: fix bugs in gdb/copyright.py, make it use glob patterns To: Simon Marchi , gdb-patches@sourceware.org References: <20250409145002.30405-1-simon.marchi@efficios.com> <20250409145002.30405-2-simon.marchi@efficios.com> From: Guinevere Larsen In-Reply-To: <20250409145002.30405-2-simon.marchi@efficios.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: thO7u33USdbKqhstWlNFA2k1uHIU51xtSnJq003MGR8_1744379543 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 On 4/9/25 11:49 AM, Simon Marchi wrote: > 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. Is there any reason why you turned all globals into lists instead of tuples? From what I can see in the script (and my understanding of it), there's no reason why the arrays should be mutable, so using the immutable tuple type would be better IMO. With that fixed, I think this is a good change, Reviewed-By: Guinevere Larsen > > 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:])) -- Cheers, Guinevere Larsen She/Her/Hers