[LON-CAPA-cvs] cvs: doc /install/linux install.pl

raeburn raeburn at source.lon-capa.org
Fri Nov 27 13:51:10 EST 2026


raeburn		Fri Nov 27 18:51:10 2026 EDT

  Modified files:              
    /doc/install/linux	install.pl 
  Log:
  - Use DBD::MariaDB instead of DBD::MySQL for Fedora 42 and newer, SLES 16,
    RHEL/Alma/Rocky/Oracle/CentOS-Stream 10 when creating connection to
    database using perl DBI.
  - Avoid deprecation warning when getting MySQL version by using path to 
    MariaDB client executable for distros using MariaDB 11.
  
  
Index: doc/install/linux/install.pl
diff -u doc/install/linux/install.pl:1.105 doc/install/linux/install.pl:1.106
--- doc/install/linux/install.pl:1.105	Fri Nov 27 17:43:59 2026
+++ doc/install/linux/install.pl	Fri Nov 27 18:51:10 2026
@@ -78,7 +78,7 @@
           &mt('Stopping execution.')."\n";
     exit;
 } else {
-    print LOG '$Id: install.pl,v 1.105 2026/11/27 17:43:59 raeburn Exp $'."\n";
+    print LOG '$Id: install.pl,v 1.106 2026/11/27 18:51:10 raeburn Exp $'."\n";
 }
 
 #
@@ -596,7 +596,7 @@
 }
 
 sub check_required {
-    my ($instdir,$dsn) = @_;
+    my ($instdir,$dsnref) = @_;
     my ($distro,$packagecmd,$updatecmd,$installnow) = &get_distro();
     if ($distro eq '') {
         return;
@@ -642,7 +642,7 @@
     $mysqlon = &check_mysql_running($distro);
     if ($mysqlon) {
         ($mysqlsetup,$has_pass,$dbh,$mysql_has_wwwuser,$mysql_unix_socket,$need_mysql_native) =
-            &check_mysql_setup($instdir,$dsn,$distro);
+            &check_mysql_setup($instdir,$dsnref,$distro);
         if ($mysqlsetup eq 'needsrestart') {
             $mysqlrestart = '';
             if ($distro eq 'ubuntu') {
@@ -1694,10 +1694,15 @@
 }
 
 sub check_mysql_setup {
-    my ($instdir,$dsn,$distro) = @_;
+    my ($instdir,$dsnref,$distro) = @_;
     my ($mysqlsetup,$has_pass,$mysql_unix_socket,$mysql_has_wwwuser,$need_mysql_native);
-    my $dbh = DBI->connect($dsn,'root','',{'PrintError'=>0});
     my ($mysqlversion,$mysqlminorversion,$mysqlsubver,$mysqlname) = &get_mysql_version($distro);
+    if (($mysqlname =~ /^MariaDB/i) &&
+        ((($distro =~ /^fedora(\d+)$/) && ($1 > 41)) || (($distro =~ /^sles(\d+)$/) && ($1 > 15)) ||
+          ($distro =~ /^(?:rhes|alma|rocky|oracle|centos\-stream)(\d+)$/) && ($1 > 9))) {
+        $$dsnref = 'DBI:MariaDB:database=mysql';      
+    }
+    my $dbh = DBI->connect($$dsnref,'root','',{'PrintError'=>0});
     if (($mysqlname =~ /^MariaDB/i) && (($mysqlversion == 10 && $mysqlminorversion >= 4) || ($mysqlversion >= 11))) {
         if ($dbh) {
             my $sth = $dbh->prepare("SELECT Priv FROM mysql.global_priv WHERE (User = 'root' AND Host ='localhost')");
@@ -1758,7 +1763,7 @@
                 }
                 close(PIPE);
             }
-            $dbh = DBI->connect($dsn,'root','',{'PrintError'=>0});
+            $dbh = DBI->connect($$dsnref,'root','',{'PrintError'=>0});
             if ($dbh) {
                 $mysqlsetup = 'noroot';
                 $mysql_has_wwwuser = &check_mysql_wwwuser($dbh);
@@ -1777,7 +1782,7 @@
     if ($has_pass) {
         print &mt('You have already set a root password for the MySQL database.')."\n";
         my $currpass = &get_mysql_password(&mt('Please enter the password now'));
-        $dbh = DBI->connect($dsn,'root',$currpass,{'PrintError'=>0});
+        $dbh = DBI->connect($$dsnref,'root',$currpass,{'PrintError'=>0});
         if ($dbh) {
             $mysqlsetup = 'rootok';
             print_and_log(&mt('Password accepted.')."\n");
@@ -1789,7 +1794,7 @@
                 print_and_log(&mt('Perhaps the password was incorrect?')."\n");
                 print &mt('Try again?').' ';
                 $currpass = &get_mysql_password(&mt('Re-enter password now'));
-                $dbh = DBI->connect($dsn,'root',$currpass,{'PrintError'=>0});
+                $dbh = DBI->connect($$dsnref,'root',$currpass,{'PrintError'=>0});
                 if ($dbh) {
                     $mysqlsetup = 'rootok';
                     print_and_log(&mt('Password accepted.')."\n");
@@ -2127,7 +2132,7 @@
     $need_mysql_native,$recommended,$dbh,$has_pass,$mysql_unix_socket,$has_lcdb,$downloadstatus,
     $filetouse,$production,$testing,$apachefw,$uses_systemctl,$hostname,$hostip,
     $sslhostsfiles,$has_std,$has_int,$rewritenum,$nochgstd,$nochgint) =
-    &check_required($instdir,$dsn);
+    &check_required($instdir,\$dsn);
 if ($distro eq '') {
     print "\n".&mt('Linux distribution could not be verified as a supported distribution.')."\n".
           &mt('The following are supported: [_1].',
@@ -2199,7 +2204,7 @@
                      $mysqlrestart,$recommended,$dbh,$has_pass,$mysql_unix_socket,
                      $has_lcdb,$downloadstatus,$filetouse,$production,$testing,$apachefw,
                      $uses_systemctl,$hostname,$hostip,$sslhostsfiles,$has_std,$has_int,
-                     $rewritenum,$nochgstd,$nochgint) = &check_required($instdir,$dsn);
+                     $rewritenum,$nochgstd,$nochgint) = &check_required($instdir,\$dsn);
                 }
             } else {
                 print &mt('Failed to run command to install LONCAPA-prerequisites')."\n";
@@ -2903,7 +2908,12 @@
     my ($dbh,$has_pass,$mysql_unix_socket,$distro, at mysql_lc_commands) = @_;
     my ($mysqlversion,$mysqlminorversion,$mysqlsubver,$mysqlname) = &get_mysql_version($distro);
     my ($usescreate,$usesauth,$is_mariadb,$hasauthcol,$check_native_pw, at mysql_commands);
+    my $dsn = 'DBI:mysql:database=mysql';
     if ($mysqlname =~ /^MariaDB/i) {
+        if ((($distro =~ /^fedora(\d+)$/) && ($1 > 41)) || (($distro =~ /^sles(\d+)$/) && ($1 > 15)) ||
+            (($distro =~ /^(?:rhes|alma|rocky|oracle|centos\-stream)(\d+)$/) && ($1 > 9))) {
+            $dsn = 'DBI:MariaDB:database=mysql';      
+        }
         $is_mariadb = 1;
         if ((($mysqlversion == 10) && ($mysqlminorversion >= 4)) || ($mysqlversion >= 11)) {
             $usescreate = 1;
@@ -2954,7 +2964,7 @@
                 $need_mysql_native = &check_mysql_native_pw($dbh);
             }
             if ($need_mysql_native) {
-                my $result = &set_native_perm($distro,$dbh);
+                my $result = &set_native_perm($distro,$dsn,$dbh);
                 if ($result eq 'fail') {
                     print_and_log(&mt('Problem configuring MySQL.')."\n".
                                   &mt('Permissions not set.')."\n");
@@ -3011,7 +3021,7 @@
                 $need_mysql_native = &check_mysql_native_pw($dbh);
             }
             if ($need_mysql_native) {
-                my $result = &set_native_perm($distro,$dbh);
+                my $result = &set_native_perm($distro,$dsn,$dbh);
                 if ($result eq 'fail') {
                     print_and_log(&mt('Problem configuring MySQL.')."\n".
                                   &mt('Permissions not set.')."\n");
@@ -3061,10 +3071,10 @@
     my ($distro) = @_;
     my ($version,$minorversion,$subversion,$name);
     my $command = 'mysql';
-    if ($distro =~ /^sles(\d+)/) {
-        if ($1 >= 16) {
-            $command = '/usr/bin/mariadb';
-        }
+    if ((($distro =~ /^sles(\d+)$/) && ($1 > 15)) ||
+        (($distro =~ /^fedora(\d+)$/) && ($1 > 43)) ||
+        (($distro =~ /^debian(\d+)$/) && ($1 > 12))) {
+        $command = '/usr/bin/mariadb';
     }
     if (open(PIPE," $command -V |")) {
         my $info = <PIPE>;
@@ -3082,7 +3092,7 @@
 }
 
 sub set_native_perm {
-    my ($distro,$dbh) = @_;
+    my ($distro,$dsn,$dbh) = @_;
     my ($disconnected,$status);
     if (ref($dbh)) {
         if (!$dbh->disconnect) {
@@ -3108,7 +3118,6 @@
         $status = 'fail';
     }
     if ($disconnected) {
-        my $dsn = "DBI:mysql:database=mysql";
         my $currpass = &get_mysql_password(&mt('Please enter the password now'));
         $dbh = DBI->connect($dsn,'root','',{'PrintError'=>0});
         if ($DBI::err =~ /1045/) {




More information about the LON-CAPA-cvs mailing list