3131OLD_CLMYSQL_VERSIONS  =  ["5.0" , "5.1" ]
3232OLD_MYSQL_UPSTREAM_VERSIONS_CL7  =  ["5.7" , "5.6" , "5.5" ]
3333OLD_MYSQL_UPSTREAM_VERSIONS_CL8  =  ["5.7" , "5.6" ]  # adjust as needed for CL8 
34+ OLD_MARIADB_UPSTREAM_VERSIONS_CL8  =  ["10.3" , "10.4" ]  # MariaDB versions to block for CL8 source 
3435
3536
3637def  build_install_list (prefix ):
@@ -180,6 +181,32 @@ def clmysql_process(self, repofile_name, repofile_data):
180181        else :
181182            api .current_logger ().debug ("No repos from CloudLinux repofile {} enabled, ignoring" .format (repofile_name ))
182183
184+     def  _make_upgrade_mariadb_url (self , mariadb_url , source_major , target_major ):
185+         """ 
186+         Maria URLs look like this: 
187+           baseurl = https://archive.mariadb.org/mariadb-10.3/yum/centos/7/x86_64 
188+           baseurl = https://archive.mariadb.org/mariadb-10.7/yum/centos7-ppc64/ 
189+           baseurl = https://distrohub.kyiv.ua/mariadb/yum/11.8/rhel/$releasever/$basearch 
190+           baseurl = https://mariadb.gb.ssimn.org/yum/12.0/centos/$releasever/$basearch 
191+           baseurl = https://mariadb.gb.ssimn.org/yum/12.0/almalinux8-amd64/$releasever/$basearch 
192+         We want to replace the parts of the url to make them work with target os version. 
193+         """ 
194+ 
195+         # Replace the first occurrence of source_major with target_major after 'yum' 
196+         url_parts  =  mariadb_url .split ("yum" , 1 )
197+         if  len (url_parts ) ==  2 :
198+             # Replace major version in "/centos/7/" and /12.0/almalinux9-amd64/, 
199+             # but do not replace it in /mariadb-10.7/yum/ 
200+             url_parts [1 ] =  url_parts [1 ].replace ("/{}/" .format (source_major ), "/{}/" .format (target_major ))
201+             url_parts [1 ] =  url_parts [1 ].replace ("{}-" .format (source_major ), "{}-" .format (target_major ))
202+             # Replace $releasever because upstream repos expect major version 
203+             # and cloudlinux provides major.minor as $releasever 
204+             url_parts [1 ] =  url_parts [1 ].replace ('$releasever' , str (target_major ))
205+             return  "yum" .join (url_parts )
206+         else :
207+             api .current_logger ().warning ("Unsupported repository URL={}, skipping" .format (mariadb_url ))
208+             return 
209+ 
183210    def  mariadb_process (self , repofile_name , repofile_data ):
184211        """ 
185212        Process upstream MariaDB options. 
@@ -191,24 +218,36 @@ def mariadb_process(self, repofile_name, repofile_data):
191218        source_major  =  get_source_major_version ()
192219
193220        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 
198221            target_repo  =  copy .deepcopy (source_repo )
199222            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 
223+             target_repo .baseurl  =  self ._make_upgrade_mariadb_url (source_repo .baseurl , source_major , target_major )
210224
211225            if  target_repo .enabled :
226+                 # MariaDB 10.4 is not compatible with Leapp upgrade 
227+                 if  str (source_major ) ==  "8"  and  any (ver  in  target_repo .baseurl  for  ver  in  OLD_MARIADB_UPSTREAM_VERSIONS_CL8 ):
228+                     reporting .create_report (
229+                         [
230+                             reporting .Title ("MariaDB version is not compatible with Leapp upgrade" ),
231+                             reporting .Summary (
232+                                 "MariaDB is installed on this system but its version is not compatible with Leapp upgrade process. " 
233+                                 "The upgrade is blocked to prevent system instability. " 
234+                                 "This situation cannot be automatically resolved by Leapp. " 
235+                                 "Problematic repository: {0}" .format (target_repo .repoid )
236+                             ),
237+                             reporting .Severity (reporting .Severity .MEDIUM ),
238+                             reporting .Groups ([reporting .Groups .REPOSITORY ]),
239+                             reporting .Groups ([reporting .Groups .INHIBITOR ]),
240+                             reporting .Remediation (
241+                                 hint = (
242+                                     "Upgrade to a more recent MariaDB version, or " 
243+                                     "uninstall the MariaDB packages and disable the repository. " 
244+                                     "Note that you will also need to update any bindings (e.g., PHP or Python) " 
245+                                     "that are dependent on this MariaDB version." 
246+                                 )
247+                             ),
248+                         ]
249+                     )
250+                 
212251                api .current_logger ().debug ("Generating custom MariaDB repo: {}" .format (target_repo .repoid ))
213252                self .custom_repo_msgs .append (
214253                    CustomTargetRepository (
0 commit comments