diff --git a/pleskdistup/common/src/leapp_configs.py b/pleskdistup/common/src/leapp_configs.py index 511416c..0182668 100644 --- a/pleskdistup/common/src/leapp_configs.py +++ b/pleskdistup/common/src/leapp_configs.py @@ -48,13 +48,13 @@ def _do_replacement( def _do_id_replacement(id: typing.Optional[str]) -> typing.Optional[str]: return _do_replacement(id, [ - lambda to_change: "alma-" + to_change, + lambda to_change: "alma-" + to_change if not to_change.startswith("alma-") else to_change, ]) def _do_name_replacement(name: typing.Optional[str]) -> typing.Optional[str]: return _do_replacement(name, [ - lambda to_change: "Alma " + to_change, + lambda to_change: "Alma " + to_change if not to_change.startswith("Alma ") else to_change, lambda to_change: to_change.replace("Enterprise Linux 7", "Enterprise Linux 8"), lambda to_change: to_change.replace("EPEL-7", "EPEL-8"), lambda to_change: to_change.replace("$releasever", "8"), diff --git a/pleskdistup/common/tests/leapp_configs_tests.py b/pleskdistup/common/tests/leapp_configs_tests.py index 1f602ec..43247cb 100644 --- a/pleskdistup/common/tests/leapp_configs_tests.py +++ b/pleskdistup/common/tests/leapp_configs_tests.py @@ -478,6 +478,26 @@ def test_rackspace_mapping(self): self._perform_test({"mariadb.repo": mariadb_like_repos}, expected_mariadb_repos, expected_mariadb_mapping) + def test_avoid_duplicated_prefixes(self): + prefixed_repo = """[alma-repo1] +name=Alma repo1 +baseurl=http://repo1/rpm-CentOS-7 +enabled=1 +gpgcheck=0 +""" + + expected_leapp_repos = """[alma-repo1] +name=Alma repo1 +baseurl=http://repo1/rpm-RedHat-el8 +enabled=1 +gpgcheck=0 +""" + + expected_leapp_mapping = """alma-repo1,alma-repo1,alma-repo1,all,all,x86_64,rpm,ga,ga +""" + + self._perform_test({"prefixed.repo": prefixed_repo}, expected_leapp_repos, expected_leapp_mapping) + class SetPackageRepositoryTests(unittest.TestCase): INITIAL_JSON = {