Revert "Fix to support installing missing Perl modules using package manager"

This reverts commit 9bce05f48a.
This commit is contained in:
Ilia Ross
2025-12-14 19:53:42 +02:00
parent ebefe283fd
commit f55515fdb0
4 changed files with 16 additions and 80 deletions

View File

@@ -317,70 +317,17 @@ else {
print &ui_buttons_end() if ($started_buttons_row);
# Check if the optional perl modules are installed
my @needs;
my %pkgmap = (
'DBI' => [ 'perl-DBI', 'libdbi-perl' ],
'DBD::mysql' => [ 'perl-DBD-MySQL', 'libdbd-mysql-perl' ],
'DBD::MariaDB' => [ 'perl-DBD-MariaDB', 'libdbd-mariadb-perl' ],
);
my ($mysql_ver, $mysql_variant) = &get_remote_mysql_variant();
my $want_driver = $mysql_variant eq 'mariadb'
? 'DBD::MariaDB'
: 'DBD::mysql';
my @mods_to_check = ('DBI', $want_driver);
for my $mod (@mods_to_check) {
next if (!exists $pkgmap{$mod});
eval "require $mod; 1" or push @needs, $mod;
}
if (@needs) {
my $return = "../$module_name/";
my $returndesc = $text{'index_return'};
# If CPAN module is available, use it
if (&foreign_available("cpan")) {
my $needs_q = &urlize(join(" ", @needs));
print &ui_alert_box(
&text(@needs == 2
? 'index_nomods'
: 'index_nomod',
@needs,
"../cpan/download.cgi?source=3&cpan=".
"$needs_q&mode=2&return=/$module_name/".
"&returndesc=".
&urlize($returndesc)),
'warn');
}
# If no CPAN, try system packages via software module
elsif (foreign_available("software")) {
&foreign_require("software");
my $return = "../$module_name/";
my $returndesc = $text{'index_title'};
# Resolve one package per missing module, for this OS
my @want_pkgs;
for my $mod (@needs) {
for my $cand (@{ $pkgmap{$mod} }) {
my ($pkg, $flags) =
&software::update_system_resolve(
$cand);
if ($pkg) {
push @want_pkgs, $cand;
last;
}
}
}
if (@want_pkgs) {
my $desc = &text(@want_pkgs > 1
? 'index_nomods2'
: 'index_nomod2', @needs);
my $link = &software::missing_install_link(
join(' ', @want_pkgs),
$desc,
$return,
$returndesc);
print &ui_alert_box($link, 'warn');
}
if (foreign_available("cpan")) {
eval "use DBI";
push(@needs, "DBI") if ($@);
$nodbi++ if ($@);
eval "use DBD::mysql";
push(@needs, "DBD::mysql") if ($@);
if (@needs) {
$needs = &urlize(join(" ", @needs));
print &ui_alert_box(&text(@needs == 2 ? 'index_nomods' : 'index_nomod', @needs,
"../cpan/download.cgi?source=3&cpan=$needs&mode=2&return=/$module_name/&returndesc=".
&urlize($text{'index_return'})), 'warn');
}
}
}

View File

@@ -30,8 +30,6 @@ index_version=$2 version $1
index_version2=$3 version $1 on $2
index_nomod=The Perl module <tt>$1</tt> is not installed on your system, so Webmin will not be able to reliably access your MySQL database. <a href='$2'>Click here</a> to install it now.
index_nomods=The Perl modules <tt>$1</tt> and <tt>$2</tt> are not installed on your system, so Webmin will not be able to reliably access your MySQL database. <a href='$3'>Click here</a> to install them now.
index_nomod2=module <tt>$1</tt> is not available on your system for Webmin to reliably access your MySQL database but
index_nomods2=modules <tt>$1</tt> and <tt>$2</tt> are not available on your system for Webmin to reliably access your MySQL database but
index_mysqlver=The command <tt>$1</tt> returned :
index_eenvpass=The MySQL client program $1 does not accept passwords passed using the <tt>MYSQL_PWD</tt> environment variable. To ensure that Webmin is able to fully communicate with MySQL, this option should be turned off on the <a href='$2'>module configuration</a> page. Alternately, you can remove any password set in the <tt>root</tt> user's <tt>.my.cnf</tt> file.
index_ecnf=The MySQL config file $1 was not found on your system. Use the <a href='$2'>module configuration</a> page to set the correct path.

View File

@@ -397,7 +397,7 @@ csw_form=Upgrade Packages
csw_upgrade=Upgrade All Installed Packages
csw_updatedesc=Upgrading all installed packages with command $1 ..
missing_msg=The $1 can be automatically installed using package manager.
missing_msg=The $1 package can be automatically installed by Webmin using $2.
missing_now=Install Now
find_title=Search For Package

View File

@@ -254,24 +254,15 @@ sub missing_install_link
local ($name, $desc, $return, $returndesc) = @_;
return undef if (!defined(&update_system_resolve));
return undef if (!&foreign_check($module_name));
my @packages = split(/\s+/, $name);
my (@pkgs, @flags);
foreach my $p (@packages) {
my ($pkg, $flags) = &update_system_resolve($p);
push(@pkgs, $pkg);
push(@flags, $flags);
}
return undef if (!@pkgs);
@pkgs = &unique(@pkgs);
my $hidden_update = join("", map { &ui_hidden("update", $_) } @pkgs);
@flags = &unique(@flags);
local ($pkg, $flags) = &update_system_resolve($name);
return undef if (!$pkg);
local ($cpkg) = caller();
local $caller = eval '$'.$cpkg.'::module_name';
return &ui_form_start("@{[&get_webprefix()]}/$module_name/install_pack.cgi", "get").
&text('missing_msg', $desc, $text{$update_system."_name"})."\n".
&ui_hidden("source", 3).
$hidden_update.
&ui_hidden("flags", join(" ", @flags)).
&ui_hidden("update", $pkg).
&ui_hidden("flags", $flags).
&ui_hidden("return", $return).
&ui_hidden("returndesc", $returndesc).
&ui_hidden("caller", $caller).