@@ -180,6 +180,28 @@ def clmysql_process(self, repofile_name, repofile_data):
180180 else :
181181 api .current_logger ().debug ("No repos from CloudLinux repofile {} enabled, ignoring" .format (repofile_name ))
182182
183+ def _make_upgrade_mariadb_url (self , mariadb_url , source_major , target_major ):
184+ """
185+ Maria URLs look like this:
186+ baseurl = https://archive.mariadb.org/mariadb-10.3/yum/centos/7/x86_64
187+ baseurl = https://archive.mariadb.org/mariadb-10.7/yum/centos7-ppc64/
188+ baseurl = https://distrohub.kyiv.ua/mariadb/yum/11.8/rhel/$releasever/$basearch
189+ baseurl = https://mariadb.gb.ssimn.org/yum/12.0/centos/$releasever/$basearch
190+ baseurl = https://mariadb.gb.ssimn.org/yum/12.0/almalinux8-amd64/$releasever/$basearch
191+ We want to replace the parts of the url to make them work with target os version.
192+ """
193+
194+ # Replace the first occurrence of source_major with target_major after 'yum'
195+ url_parts = mariadb_url .split ("yum" , 1 )
196+ if len (url_parts ) == 2 :
197+ # Replace only the first digit (source_major) after 'yum'
198+ url_parts [1 ] = url_parts [1 ].replace (str (source_major ), str (target_major ), 1 )
199+ return "yum" .join (url_parts )
200+ else :
201+ # TODO: fix in https://cloudlinux.atlassian.net/browse/CLOS-3490
202+ api .current_logger ().warning ("Unsupported repository URL={}, skipping" .format (mariadb_url ))
203+ return
204+
183205 def mariadb_process (self , repofile_name , repofile_data ):
184206 """
185207 Process upstream MariaDB options.
@@ -191,22 +213,9 @@ def mariadb_process(self, repofile_name, repofile_data):
191213 source_major = get_source_major_version ()
192214
193215 for source_repo in repofile_data .data :
194- # Maria URLs look like this:
195- # baseurl = https://archive.mariadb.org/mariadb-10.3/yum/centos/7/x86_64
196- # baseurl = https://archive.mariadb.org/mariadb-10.7/yum/centos7-ppc64/
197- # We want to replace the source_major in OS name after /yum/ with target_major
198216 target_repo = copy .deepcopy (source_repo )
199217 target_repo .repoid = "{}-{}" .format (target_repo .repoid , target_major )
200- # Replace the first occurrence of source_major with target_major after 'yum'
201- url_parts = target_repo .baseurl .split ("yum" , 1 )
202- if len (url_parts ) == 2 :
203- # Replace only the first digit (source_major) after 'yum'
204- url_parts [1 ] = url_parts [1 ].replace (str (source_major ), str (target_major ), 1 )
205- target_repo .baseurl = "yum" .join (url_parts )
206- else :
207- # TODO: fix in https://cloudlinux.atlassian.net/browse/CLOS-3490
208- api .current_logger ().warning ("Unsupported repository URL={}, skipping" .format (target_repo .baseurl ))
209- return
218+ target_repo .baseurl = self ._make_upgrade_mariadb_url (source_repo .baseurl , source_major , target_major )
210219
211220 if target_repo .enabled :
212221 api .current_logger ().debug ("Generating custom MariaDB repo: {}" .format (target_repo .repoid ))
0 commit comments