# yum-lib.pl # Functions for installing packages with yum $yum_config = $config{'yum_config'} || "/etc/yum.conf"; # update_system_install([package], [&in]) # Install some package with yum sub update_system_install { local $update = $_[0] || $in{'update'}; local $in = $_[1]; local $enable; if ($in->{'enablerepo'}) { $enable = "enablerepo=".quotemeta($in->{'enablerepo'}); } local (@rv, @newpacks); print "",&text('yum_install', "yum $enable -y install $update"),"
\n"; print "
";
&additional_log('exec', undef, "yum $enable -y install $update");
local $qm = join(" ", map { quotemeta($_) } split(/\s+/, $update));
&open_execute_command(CMD, "yum $enable -y install $qm 2>&1 ) {
s/\r|\n//g;
if (/^\[(update|install|deps):\s+(\S+)\s+/) {
push(@rv, $2);
}
elsif (/^(Installed|Dependency Installed|Updated|Dependency Updated):\s+(.*)/) {
local @pkgs = split(/\s+/, $2);
foreach my $p (@pkgs) {
if ($p !~ /:/ && $p =~ /^(\S+)\.(\S+)$/ &&
$p =~ /[^0-9\.\-\_i]/) {
push(@rv, $1);
}
}
}
if (!/ETA/ && !/\%\s+done\s+\d+\/\d+\s*$/) {
print &html_escape($_."\n");
}
}
close(CMD);
print "\n";
if ($?) {
print "$text{'yum_failed'}\n"; return ( ); } else { print "$text{'yum_ok'}
\n"; return &unique(@rv); } } # show_update_system_opts() # Returns HTML for enabling a repository, if any are disabled sub show_update_system_opts { local @pinfo = &package_info("yum"); if (&compare_versions($pinfo[4], "2.1.10") > 0) { local $conf = &get_yum_config(); local @ena; foreach my $r (@$conf) { if ($r->{'values'}->{'enabled'} eq '0') { push(@ena, $r->{'name'}); } } if (@ena) { return $text{'yum_enable'}." ". &ui_select("enablerepo", "", [ [ "", $text{'yum_none'} ], map { [ $_ ] } @ena ]); } } return undef; } # update_system_form() # Shows a form for updating all packages on the system sub update_system_form { print &ui_subheading($text{'yum_form'}); print "
\n"; } # update_system_resolve(name) # Converts a standard package name like apache, sendmail or squid into # the name used by YUM. sub update_system_resolve { local ($name) = @_; return $name eq "apache" ? "httpd" : $name eq "dhcpd" ? "dhcp" : $name eq "mysql" ? "mysql mysql-server mysql-devel" : $name eq "openssh" ? "openssh openssh-server" : $name eq "postgresql" ? "postgresql postgresql-libs postgresql-server" : $name eq "openldap" ? "openldap-servers openldap-clients" : $name; } # update_system_available() # Returns a list of package names and versions that are available from YUM sub update_system_available { local @rv; local %done; &open_execute_command(PKG, "yum list", 1, 1); while(