diff options
Diffstat (limited to '.local')
| -rwxr-xr-x | .local/bin/zypper-wassup | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/.local/bin/zypper-wassup b/.local/bin/zypper-wassup index 10e4826..6486367 100755 --- a/.local/bin/zypper-wassup +++ b/.local/bin/zypper-wassup @@ -19,6 +19,15 @@ ZYPPER_PATTERN = re.compile( re.MULTILINE ) +# Using http://ftp.rpm.org/max-rpm/ch-rpm-file-format.html to make a +# few assumptions, e.g. versions can't contain hyphens. +SOURCERPM_PATTERN = re.compile( + r'\.'.join(( + '-'.join(('(?P<name>.+)', '(?P<version>[^-]+)', '(?P<release>[^-]+)')), + '(?:no)?src', + 'rpm' +))) + def execute(command): return run(command, check=True, text=True, capture_output=True).stdout @@ -34,25 +43,15 @@ def zypper_list_updates(): def source_package_name(package): - # Using http://ftp.rpm.org/max-rpm/ch-rpm-file-format.html to make - # a few assumptions, e.g. versions can't contain hyphens. - pattern = r'\.'.join(( - '-'.join(('(?P<name>.+)', '(?P<version>[^-]+)', '(?P<release>[^-]+)')), - r'(?:no)?src', - r'rpm' - )) - match = re.fullmatch(pattern, package) - if match is None: - print(pattern) - print(package) + if (match := SOURCERPM_PATTERN.fullmatch(package)) is None: + raise Exception(f'{package} does not match "{SOURCERPM_PATTERN}".') + return match.group('name') def sort_by_source_package(packages): sorted_packages = defaultdict(list) - print() - for p in packages: source_pkgs = execute( ('rpm', '--query', '--queryformat', r'%{SOURCERPM}\n', p.package) |
