From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 817E13858D1E for ; Sun, 1 Jan 2023 11:29:24 +0000 (GMT) Received: by mail-pf1-x436.google.com with SMTP id e21so7536742pfl.1 for ; Sun, 01 Jan 2023 03:29:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=fH7PgjtzroYmnAQZ7zgQOnucGdpJOPI+vIySV4EeLos=; b=k2D3EAVlq/v6PYnzDJN0y8H7wiPsKCV4NlBbZpnhySpt6sEQRht882tnqvS8mgHRvL H8lIvLmlmA4nAckghm/J60nmSpL8g5KZiR0wAoVZ0EupLwpPxT3kwhUq2YUv8Kqk00Zj BDRxNeoy1g6UK0Wp72LQOXli/4N+Jn75Yk6TrkHLDHvsSMu0wOPtcTVoLb3jcS/C8MaW 6b6gRdUrF0gQtayL/AIXRTPHji/g/EAjcqR8lwx4krUhFnyMGXz4uCdmNgEZUqfNFGDO tRIq2gRUPBl+YufN3k/9+yGw9dGPtGpxLy/jUxSARNrFKKUdhaT+qMDd8daAQEbw+uKs Jtog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fH7PgjtzroYmnAQZ7zgQOnucGdpJOPI+vIySV4EeLos=; b=NXbZjH8utAX9N+pul1SZHUaUXh2gpt3VNheUmlYeypPztzuA5QsSmJqxVFgSG3zYxX WIUU7wly9rgNmclO9BKUTdeCRSoSDQMoXIq6UNAI9uVXZRJUr8Uk0YBeCmhB68nigKBI dYtu2VBFVB7YwXown36tHnqd4xsoItXv5UYv8DS9jFHbauDZVK0AokqDU32jFTE8BmCy x4Y6li8HeTF5TBbaExpxgNzoXYhma6vPH5rOfWszbkZ9+FVyivugC+HjK1nCCXHM77YL n7OxGXfHrkgfaxr0e8Sc7j0/HIAHMT79x+0c1Qt/Ya3cJxzx8YFJwil6WTkqPpB2+xox M0mg== X-Gm-Message-State: AFqh2koeiklFYcvwqO21b1wjw8G7TCxYrnTjUN4J14FtYP9qJNC5sVr1 ViPQ8k0GXMbdaj6fo9C+ZrlMkLvawkM= X-Google-Smtp-Source: AMrXdXu1U7UKg542vSr+nPJ7OW8eOPNXHX4XcReTdUdHfjw3sfpg0cipae7AXrVHPhlDrN/EkNWoOg== X-Received: by 2002:a62:1ec7:0:b0:56d:1e00:f078 with SMTP id e190-20020a621ec7000000b0056d1e00f078mr34285087pfe.32.1672572563133; Sun, 01 Jan 2023 03:29:23 -0800 (PST) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id x124-20020a623182000000b005779110635asm16663653pfx.51.2023.01.01.03.29.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Jan 2023 03:29:22 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 501E81142CDF; Sun, 1 Jan 2023 21:59:20 +1030 (ACDT) Date: Sun, 1 Jan 2023 21:59:20 +1030 From: Alan Modra To: binutils@sourceware.org Subject: Update etc/update-copyright.py Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3035.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This picks up some improvements from gcc/contrib. exceptions must derive from BaseException, port to python3, retain original file mode, fix name of script in examples. Adds libsframe to list of default dirs. I would have added gprofng too but there are some files claiming copyright by authors other than the Free Software Foundation. diff --git a/etc/update-copyright.py b/etc/update-copyright.py index f0036cae212..fcbf1045d1b 100755 --- a/etc/update-copyright.py +++ b/etc/update-copyright.py @@ -1,6 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -# Copyright (C) 2013-2022 Free Software Foundation, Inc. +# Copyright (C) 2013-2023 Free Software Foundation, Inc. # # This script is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -23,15 +23,15 @@ # output has been vetted. You can instead pass the names of individual # directories, including those that haven't been approved. So: # -# update-copyright.pl --this-year +# update-copyright.py --this-year # # is the command that would be used at the beginning of a year to update # all copyright notices (and possibly at other times to check whether # new files have been added with old years). On the other hand: # -# update-copyright.pl --this-year libjava +# update-copyright.py --this-year libiberty # -# would run the script on just libjava/. +# would run the script on just libiberty/. # # This script was copied from gcc's contrib/ and modified to suit # binutils. In contrast to the gcc script, this one will update @@ -60,7 +60,10 @@ class GenericFilter: def __init__ (self): self.skip_files = set() self.skip_dirs = set() - self.skip_extensions = set() + self.skip_extensions = set([ + '.png', + '.pyc', + ]) self.fossilised_files = set() self.own_files = set() @@ -238,7 +241,7 @@ class Copyright: def add_external_author (self, holder): self.holders[holder] = None - class BadYear(): + class BadYear (Exception): def __init__ (self, year): self.year = year @@ -315,7 +318,7 @@ class Copyright: # If it looks like the copyright is incomplete, add the next line. while not self.is_complete (match): try: - next_line = file.next() + next_line = file.readline() except StopIteration: break @@ -394,6 +397,15 @@ class Copyright: return (line != orig_line, line, next_line) + def guess_encoding (self, pathname): + for encoding in ('utf8', 'iso8859'): + try: + open(pathname, 'r', encoding=encoding).read() + return encoding + except UnicodeDecodeError: + pass + return None + def process_file (self, dir, filename, filter): pathname = os.path.join (dir, filename) if filename.endswith ('.tmp'): @@ -407,8 +419,11 @@ class Copyright: lines = [] changed = False line_filter = filter.get_line_filter (dir, filename) - with open (pathname, 'r') as file: + mode = None + encoding = self.guess_encoding(pathname) + with open (pathname, 'r', encoding=encoding) as file: prev = None + mode = os.fstat (file.fileno()).st_mode for line in file: while line: next_line = None @@ -432,9 +447,10 @@ class Copyright: # If something changed, write the new file out. if changed and self.errors.ok(): tmp_pathname = pathname + '.tmp' - with open (tmp_pathname, 'w') as file: + with open (tmp_pathname, 'w', encoding=encoding) as file: for line in lines: file.write (line) + os.fchmod (file.fileno(), mode) if self.use_quilt: subprocess.call (['quilt', 'add', pathname]) os.rename (tmp_pathname, pathname) @@ -442,7 +458,7 @@ class Copyright: def process_tree (self, tree, filter): for (dir, subdirs, filenames) in os.walk (tree): # Don't recurse through directories that should be skipped. - for i in xrange (len (subdirs) - 1, -1, -1): + for i in range (len (subdirs) - 1, -1, -1): if filter.skip_dir (dir, subdirs[i]): del subdirs[i] @@ -593,13 +609,18 @@ class BinutilsCmdLine (CmdLine): self.add_dir ('etc') self.add_dir ('gas') self.add_dir ('gdb') + self.add_dir ('gdbserver') + self.add_dir ('gdbsupport') self.add_dir ('gold') self.add_dir ('gprof') + self.add_dir ('gprofng') self.add_dir ('include') self.add_dir ('ld', LdFilter()) + self.add_dir ('libbacktrace') self.add_dir ('libctf') self.add_dir ('libdecnumber') self.add_dir ('libiberty') + self.add_dir ('libsframe') self.add_dir ('opcodes') self.add_dir ('readline') self.add_dir ('sim') @@ -616,6 +637,7 @@ class BinutilsCmdLine (CmdLine): 'ld', 'libctf', 'libiberty', + 'libsframe', 'opcodes', ] -- Alan Modra Australia Development Lab, IBM