From e8e245c20b318ee4f950a65db4bbf3be7f64c3d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dirk=20M=C3=BCller?= Date: Mon, 27 Mar 2023 11:36:21 +0200 Subject: [PATCH] Better skipping of non-compressed archive extensions (like .tar.gz.asc) --- go_modules | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/go_modules b/go_modules index b71d346..7acb084 100755 --- a/go_modules +++ b/go_modules @@ -114,7 +114,9 @@ def archive_autodetect(): compression. Use the name of the .spec file as the stem for the archive to detect. Archive formats supported: + - .tar.bz2 - .tar.gz + - .tar.lz - .tar.xz - .tar.zstd """ @@ -129,17 +131,16 @@ def archive_autodetect(): archive = None spec_dir = spec.parent # typically the same as cwd # highest sorted archive under spec_dir - patterns = [ - f"{spec.stem}*.tar.*", - f"{spec.stem}*.obscpio", - f"_service:*:{spec.stem}*tar.*", - f"_service:*:{spec.stem}*obscpio", - ] + c_exts = ("gz", "xz", "zstd", "lz", "bz2") + patterns = ( + [f"{spec.stem}*.tar.{c_ext}" for c_ext in c_exts] + + [f"{spec.stem}*.obscpio"] + + [f"_service:*:{spec.stem}*tar.{c_ext}" for c_ext in c_exts] + + [f"_service:*:{spec.stem}*obscpio"] + ) for pattern in patterns: log.debug(f"Trying to find archive name with pattern {pattern}") - archive = next( - reversed(sorted(Path(spec_dir).glob(pattern))), None - ) + archive = next(reversed(sorted(Path(spec_dir).glob(pattern))), None) if archive: break