diff --git a/spec_cleaner/rpmregexp.py b/spec_cleaner/rpmregexp.py index f7f36dcf..89562a17 100644 --- a/spec_cleaner/rpmregexp.py +++ b/spec_cleaner/rpmregexp.py @@ -91,6 +91,10 @@ class Regexp(object): # Special bracketed deps dection re_brackety_requires = re.compile(r'(pkgconfig|cmake|perl|tex|rubygem)\(') re_version_separator = re.compile(r'(\S+)((\s*[<>=\s]+)(\S+))*') + # packageand(pkg1:pkg2) + re_packageand = re.compile(r'^packageand\(\s*(\S+)\s*:\s*(\S+)\s*\)\s*$') + # otherproviders(foo) + re_otherproviders = re.compile(r'^otherproviders\(\s*(\S+)\s*\)\s*$') # rpmdescription re_authors = re.compile(r'^\s*Author(s)?:\s*') diff --git a/spec_cleaner/rpmrequirestoken.py b/spec_cleaner/rpmrequirestoken.py index 93c45c8e..120bf4e3 100644 --- a/spec_cleaner/rpmrequirestoken.py +++ b/spec_cleaner/rpmrequirestoken.py @@ -1,14 +1,15 @@ from typing import Optional from .rpmexception import RpmException +from .rpmregexp import Regexp class RpmRequiresToken(object): """ Class containing information about the dependency token. - Can be used to specify all the values present on the line. - Later on we use this to do various conversions. + Process dependencies like Requires, Recommends, Suggests, Supplements, Enhances, Conflicts. Can be used to specify + all the values present on the line. Later on we use this to do various conversions. This class uses the following format and naming: @@ -44,7 +45,7 @@ def _format_operator(operator: str) -> str: @staticmethod def _format_name(name: str) -> str: """ - Make sure the name looks sane. + Make sure the name looks sane and make various replacements. Args: name: A string representing the name used in the dependency token. @@ -55,10 +56,16 @@ def _format_name(name: str) -> str: # we just rename pkgconfig names to one unified one working everywhere if name == 'pkgconfig(pkg-config)' or name == 'pkg-config': name = 'pkgconfig' - # if there is otherproviders codeblock just ommit it - if name.startswith('otherproviders('): - name = name.rstrip(')') - name = name.replace('otherproviders(', '') + + # omit legacy 'otherproviders' codeblock + match = Regexp.re_otherproviders.match(name) + if match: + name = match.group(1) + + # replace 'packageand(pkgA:pkgB)' with '(pkgA and pkgB)' - new in RPM 4.13 + match = Regexp.re_packageand.match(name) + if match: + name = f'({match.group(1)} and {match.group(2)})' return name def __str__(self) -> str: diff --git a/tests/in/packageand.spec b/tests/in/packageand.spec new file mode 100644 index 00000000..05bed929 --- /dev/null +++ b/tests/in/packageand.spec @@ -0,0 +1,10 @@ +Requires: packageand(packA:packB) +Recommends: packageand(packC:packD) +Suggests: packageand(packE:packF) +Supplements: packageand(packG:packH) +Enhances: packageand(packI:packJ) +Conflicts: packageand(packK:packL) +Supplements: packageand(nginx:moodle) +Supplements: packageand(pam_xyz:pam-32bit) +Supplements: packageand(libpulse0:libxine1) +Supplements: packageand(MozillaFirefox:branding-openSUSE) diff --git a/tests/out-minimal/packageand.spec b/tests/out-minimal/packageand.spec new file mode 100644 index 00000000..a63c0523 --- /dev/null +++ b/tests/out-minimal/packageand.spec @@ -0,0 +1,12 @@ +Requires: (packA and packB) +Recommends: (packC and packD) +Suggests: (packE and packF) +Enhances: (packI and packJ) +Supplements: (MozillaFirefox and branding-openSUSE) +Supplements: (libpulse0 and libxine1) +Supplements: (nginx and moodle) +Supplements: (packG and packH) +Supplements: (pam_xyz and pam-32bit) +Conflicts: (packK and packL) + +%changelog diff --git a/tests/out/packageand.spec b/tests/out/packageand.spec new file mode 100644 index 00000000..a63c0523 --- /dev/null +++ b/tests/out/packageand.spec @@ -0,0 +1,12 @@ +Requires: (packA and packB) +Recommends: (packC and packD) +Suggests: (packE and packF) +Enhances: (packI and packJ) +Supplements: (MozillaFirefox and branding-openSUSE) +Supplements: (libpulse0 and libxine1) +Supplements: (nginx and moodle) +Supplements: (packG and packH) +Supplements: (pam_xyz and pam-32bit) +Conflicts: (packK and packL) + +%changelog