From 77a464969c77f7c2a4feb9ec2d2ec3814c2dcb4e Mon Sep 17 00:00:00 2001 From: Fiona Klute Date: Sun, 26 Apr 2026 17:33:29 +0200 Subject: [PATCH] support/scripts/pkg-stats: search only Config.in{, .host} for URL The previous Config.* glob also caught linux/Config.ext.in and package/php/Config.ext, as well as some backup files created by editors (e.g. Config.in~ after editing a Config.in file in Emacs), leading to wrong results depending on directory listing order. Also use "with" to automatically close the file when the block is left, even on error. Signed-off-by: Fiona Klute Signed-off-by: Arnout Vandecappelle --- support/scripts/pkg-stats | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats index 55aa63c861..efb85a7405 100755 --- a/support/scripts/pkg-stats +++ b/support/scripts/pkg-stats @@ -148,17 +148,17 @@ class Package: Fills in the .url field """ self.status['url'] = ("warning", "no Config.in") - for filename in os.listdir(self.pkgdir): - if fnmatch.fnmatch(filename, 'Config.*'): - fp = open(os.path.join(self.pkgdir, filename), "r") - for config_line in fp: - if URL_RE.match(config_line): - self.url = config_line.strip() - self.status['url'] = ("ok", "found") - fp.close() - return - self.status['url'] = ("error", "missing") - fp.close() + for filename in ('Config.in', 'Config.in.host'): + try: + with open(os.path.join(self.pkgdir, filename), "r") as fp: + for config_line in fp: + if URL_RE.match(config_line): + self.url = config_line.strip() + self.status['url'] = ("ok", "found") + return + self.status['url'] = ("error", "missing") + except FileNotFoundError: + continue @property def patch_count(self):