Removed support for working on just Virtualmin packages

This commit is contained in:
Jamie Cameron
2009-10-08 22:50:09 -07:00
parent 3eaa309984
commit 585af4b745
18 changed files with 47 additions and 287 deletions

View File

@ -157,7 +157,7 @@ if ($level == 0) {
$msg = $text{'right_upok'};
}
if (&foreign_available("package-updates")) {
$msg = "<a href='package-updates/index.cgi?all=1&mode=updates'>$msg</a>";
$msg = "<a href='package-updates/index.cgi?mode=updates'>$msg</a>";
}
print "<td>$msg</td> </tr>\n";
}

View File

@ -11,10 +11,7 @@ if ($in{'clear'}) {
# See if any security updates exist
$in{'mode'} ||= 'updates';
if (!defined($in{'all'})) {
$in{'all'} = &foreign_available("virtual-server") ? 1 : 0;
}
@avail = &list_available(0, $in{'all'});
@avail = &list_available(0);
($sec) = grep { $_->{'security'} } @avail;
# Show mode selector (all, updates only, updates and new)
@ -33,42 +30,18 @@ foreach $m ('all', 'updates', 'new', 'both',
}
push(@grid, $text{'index_mode'}, &ui_links_row(\@mlinks));
# Show all selector
$showall = &show_all_option();
if ($showall == 1) {
# Can show all, or just virtualmin
$in{'all'} ||= 0;
foreach $a (0, 1) {
$amsg = $text{'index_all_'.$a};
if ($in{'all'} eq $a) {
push(@alinks, "<b>$amsg</b>");
}
else {
push(@alinks, "<a href='index.cgi?mode=".
&urlize($in{'mode'})."&all=$a&search=".
&urlize($in{'search'})."'>$amsg</a>");
}
}
push(@grid, $text{'index_allsel'}, &ui_links_row(\@alinks));
}
elsif ($showall == 2) {
# Always showing all
$in{'all'} = 2;
}
# Show search box
push(@grid, $text{'index_search'}, &ui_textbox("search", $in{'search'}, 30)." ".
&ui_submit($text{'index_searchok'})." ".
&ui_submit($text{'index_clear'}, 'clear'));
print &ui_form_start("index.cgi");
print &ui_hidden("all", $showall ? 1 : 0);
print &ui_hidden("mode", $in{'mode'});
print &ui_grid_table(\@grid, 2),"<p>\n";
print &ui_form_end();
# Work out what packages to show
@current = $in{'all'} ? &list_all_current(1) : &list_current(1);
@current = &list_current(1);
# Make lookup hashes
%current = map { $_->{'name'}."/".$_->{'system'}, $_ } @current;
@ -136,7 +109,7 @@ foreach $p (sort { $a->{'name'} cmp $b->{'name'} } (@current, @avail)) {
{ 'type' => 'checkbox', 'name' => 'u',
'value' => $p->{'update'}."/".$p->{'system'},
'checked' => $need },
"<a href='view.cgi?all=$in{'all'}&mode=$in{'mode'}&name=".
"<a href='view.cgi?mode=$in{'mode'}&name=".
&urlize($p->{'name'})."&system=".
&urlize($p->{'system'})."&search=".
&urlize($in{'search'})."'>$p->{'name'}</a>",
@ -160,7 +133,6 @@ print &ui_form_columns_table(
1,
undef,
[ [ "mode", $in{'mode'} ],
[ "all", $in{'all'} ],
[ "search", $in{'search'} ] ],
[ "", $text{'index_name'}, $text{'index_desc'}, $text{'index_status'},
$anysource ? ( $text{'index_source'} ) : ( ), ],
@ -176,7 +148,6 @@ print &ui_form_columns_table(
# Show scheduled report form
print "<hr>\n";
print &ui_form_start("save_sched.cgi");
print &ui_hidden("all", $in{'all'});
print &ui_hidden("mode", $in{'mode'});
print &ui_hidden("search", $in{'search'});
print &ui_table_start($text{'index_header'}, undef, 2);

View File

@ -1,5 +1,7 @@
# Functions for checking for updates to packages from YUM, APT or some other
# update system.
#
# XXX no need for virtualmin support
BEGIN { push(@INC, ".."); };
eval "use WebminCore;";
@ -9,18 +11,8 @@ eval "use WebminCore;";
&foreign_require("webmin", "webmin-lib.pl");
use Data::Dumper;
@update_packages = ( "apache", "postfix", "sendmail", "bind", "procmail",
"spamassassin", "logrotate", "webalizer", "mysql",
"postgresql", "proftpd", "clamav", "php4", "mailman",
"subversion", "python", "ruby", "irb", "rdoc", "rubygems",
"openssl", "perl", "php5", "webmin", "usermin",
"fcgid", "awstats", "dovecot", "postgrey",
"virtualmin-modules",
);
$available_cache_file = "$module_config_directory/available.cache";
$current_cache_file = "$module_config_directory/current.cache";
$current_all_cache_file = "$module_config_directory/current-all.cache";
$cron_cmd = "$module_config_directory/update.pl";
$yum_cache_file = "$module_config_directory/yumcache";
@ -28,48 +20,30 @@ $apt_cache_file = "$module_config_directory/aptcache";
$yum_changelog_cache_dir = "$module_config_directory/yumchangelog";
# list_current(nocache)
# Returns a list of packages and versions for Virtualmin-related packages
# managed by this module. Return keys are :
# Returns a list of packages and versions for installed software. Keys are :
# name - The local package name (ie. CSWapache2)
# update - Name used to refer to it by the updates system (ie. apache2)
# version - Version number
# epoch - Epoch part of the version
# desc - Human-readable description
# package - Original generic program, like apache
sub list_current
{
local ($nocache) = @_;
if ($nocache || &cache_expired($current_cache_file)) {
local $n = &software::list_packages();
local @rv;
foreach my $p (@update_packages) {
local @pkgs = split(/\s+/, &package_resolve($p));
foreach my $pn (@pkgs) {
my $updatepn = $pn;
$pn = &csw_to_pkgadd($pn);
for(my $i=0; $i<$n; $i++) {
next if ($software::packages{$i,'name'}
!~ /^$pn$/);
push(@rv, {
'update' =>
$updatepn eq $pn ?
$software::packages{$i,'name'} :
$updatepn,
'name' =>
$software::packages{$i,'name'},
'version' =>
$software::packages{$i,'version'},
'epoch' =>
$software::packages{$i,'epoch'},
'desc' =>
$software::packages{$i,'desc'},
'package' => $p,
'system' => $software::update_system,
'software' => 1,
});
&fix_pkgadd_version($rv[$#rv]);
}
}
for(my $i=0; $i<$n; $i++) {
push(@rv, { 'name' => $software::packages{$i,'name'},
'update' => $software::packages{$i,'name'},
'version' =>
$software::packages{$i,'version'},
'epoch' =>
$software::packages{$i,'epoch'},
'desc' =>
$software::packages{$i,'desc'},
'system' => $software::update_system,
});
&fix_pkgadd_version($rv[$#rv]);
}
# Filter out dupes and sort by name
@ -83,82 +57,19 @@ else {
}
}
# list_all_current(nocache)
# Returns a list of all installed packages, in the same format as list_current
sub list_all_current
{
local ($nocache) = @_;
local ($nocache) = @_;
if ($nocache || &cache_expired($current_all_cache_file)) {
local $n = &software::list_packages();
local @rv;
local %pkgmap;
foreach my $p (@update_packages) {
local @pkgs = split(/\s+/, &package_resolve($p));
foreach my $pn (@pkgs) {
$pkgmap{$pn} = $p;
}
}
for(my $i=0; $i<$n; $i++) {
push(@rv, { 'name' => $software::packages{$i,'name'},
'update' => $software::packages{$i,'name'},
'version' =>
$software::packages{$i,'version'},
'epoch' =>
$software::packages{$i,'epoch'},
'desc' =>
$software::packages{$i,'desc'},
'package' => $pkgmap{$software::packages{$i,'name'}},
'system' => $software::update_system,
});
&fix_pkgadd_version($rv[$#rv]);
}
# Filter out dupes and sort by name
@rv = &filter_duplicates(\@rv);
&write_cache_file($current_all_cache_file, \@rv);
return @rv;
}
else {
return &read_cache_file($current_all_cache_file);
}
}
# list_available(nocache, all)
# Returns the names and versions of packages available from the update
# system, that we are interested in.
# list_available(nocache)
# Returns the names and versions of packages available from the update system
sub list_available
{
local ($nocache, $all) = @_;
if ($nocache || &cache_expired($available_cache_file.int($all))) {
local ($nocache) = @_;
if ($nocache || &cache_expired($available_cache_file)) {
# Get from update system
local @rv;
local @avail = &packages_available();
if (!$all) {
# Limit to packages Virtualmin cares about
foreach my $p (@update_packages) {
local @pkgs = split(/\s+/, &package_resolve($p));
foreach my $pn (@pkgs) {
local @mavail = grep { $_->{'name'} =~ /^$pn$/ }
@avail;
foreach my $avail (@mavail) {
$avail->{'update'} = $avail->{'name'};
$avail->{'name'} =
&csw_to_pkgadd($avail->{'name'});
$avail->{'package'} = $p;
push(@rv, $avail);
}
}
}
}
else {
# All on system
foreach my $avail (@avail) {
$avail->{'update'} = $avail->{'name'};
$avail->{'name'} = &csw_to_pkgadd($avail->{'name'});
push(@rv, $avail);
}
foreach my $avail (@avail) {
$avail->{'update'} = $avail->{'name'};
$avail->{'name'} = &csw_to_pkgadd($avail->{'name'});
push(@rv, $avail);
}
# Set pinned versions
@ -169,13 +80,13 @@ if ($nocache || &cache_expired($available_cache_file.int($all))) {
if (!@rv) {
# Failed .. fall back to cache
@rv = &read_cache_file($available_cache_file.int($all));
@rv = &read_cache_file($available_cache_file);
}
&write_cache_file($available_cache_file.int($all), \@rv);
&write_cache_file($available_cache_file, \@rv);
return @rv;
}
else {
return &read_cache_file($available_cache_file.int($all));
return &read_cache_file($available_cache_file);
}
}
@ -246,40 +157,6 @@ local ($job) = grep { $_->{'user'} eq 'root' &&
return $job;
}
# package_resolve(name)
# Given a package code name from @update_packages, returns a string of the
# underlying packages that implement it. This may come from the update system
# if the OS has one (YUM or APT, or from Virtualmin's built-in list)
sub package_resolve
{
local ($name) = @_;
local $realos = $gconfig{'real_os_type'};
$realos =~ s/ /-/g;
local $realver = $gconfig{'real_os_version'};
$realver =~ s/ /-/g;
if (open(RESOLV, "$module_root_directory/resolve.$realos-$realver") ||
open(RESOLV, "$module_root_directory/resolve.$realos") ||
open(RESOLV, "$module_root_directory/resolve.$gconfig{'os_type'}-$gconfig{'os_version'}") ||
open(RESOLV, "$module_root_directory/resolve.$gconfig{'os_type'}")) {
local $rv;
while(<RESOLV>) {
if (/^(\S+)\s+(.*)/ && $1 eq $name) {
$rv = $2;
}
elsif (/^\*/) {
# All other packages have the same name as their code
$rv = $name;
}
}
close(RESOLV);
return $rv if ($rv);
}
if (defined(&software::update_system_resolve)) {
return &software::update_system_resolve($name);
}
return $name;
}
# packages_available()
# Returns a list of all available packages, as hash references with name and
# version keys. These come from the APT, YUM or CSW update system, if available.
@ -332,17 +209,17 @@ if (defined(&software::update_system_available)) {
return ( );
}
# package_install(package, [system], [check-all])
# package_install(package, [system])
# Install some package, either from an update system or from Webmin. Returns
# a list of updated package names.
sub package_install
{
local ($name, $system, $all) = @_;
local ($name, $system) = @_;
local @rv;
local ($pkg) = grep { $_->{'update'} eq $name &&
($_->{'system'} eq $system || !$system) }
sort { &compare_versions($b, $a) }
&list_available(0, $all);
&list_available(0);
if (!$pkg) {
print &text('update_efindpkg', $name),"<p>\n";
return ( );
@ -371,7 +248,6 @@ else {
}
# Flush installed cache
unlink($current_cache_file);
unlink($current_all_cache_file);
return @rv;
}
@ -391,18 +267,17 @@ if (defined(&software::update_system_operations)) {
return ( );
}
# list_possible_updates([nocache], [all])
# list_possible_updates([nocache])
# Returns a list of updates that are available. Each element in the array
# is a hash ref containing a name, version, description and severity flag.
# Intended for calling from themes. Nocache 0=cache everything, 1=flush all
# caches, 2=flush only current
sub list_possible_updates
{
local ($nocache, $all) = @_;
local ($nocache) = @_;
local @rv;
local @current = $all ? &list_all_current($nocache)
: &list_current($nocache);
local @avail = &list_available($nocache == 1, $all);
local @current = &list_current($nocache);
local @avail = &list_available($nocache == 1);
@avail = sort { &compare_versions($b, $a) } @avail;
local ($a, $c, $u);
foreach $c (sort { $a->{'name'} cmp $b->{'name'} } @current) {
@ -578,19 +453,9 @@ if ($pkg->{'system'} eq 'yum') {
return undef;
}
# Returns 1 if an option should be shown to list all packages, 2 if all
# packages is the only option, or 0 if only virtualmin.
sub show_all_option
{
return !&foreign_available("virtual-server") ? 2 :
$software::update_system eq 'apt' ||
$software::update_system eq 'yum' ? 1 : 0;
}
sub flush_package_caches
{
unlink($current_cache_file);
unlink($current_all_cache_file);
unlink($updates_cache_file);
unlink($available_cache_file);
unlink($available_cache_file.'0');

View File

@ -1,7 +0,0 @@
postgresql postgresql postgresql-server rh-postgresql rh-postgresql-server perl-DBD-Pg
mysql mysql mysql-server perl-DBD-MySQL
perl perl mod_perl perl-libwww-perl perl-Digest-HMAC perl-Digest-SHA1 perl-XML-Simple
openssl openssl perl-Net-SSLeay perl-Crypt-SSLeay
php5 php
fcgid mod_fcgid
virtualmin-modules wbm-.* wbt-.* usm-.* ust-.*

View File

@ -1 +0,0 @@
resolve.Redhat-Linux-Fedora-5

View File

@ -1,13 +0,0 @@
postfix postfix postfix-tls
bind bind9 bind9-doc
spamassassin spamassassin spamc
postgresql postgresql postgresql-.* libpg-perl libdbd-pg-perl
mysql mysql mysql-server.* mysql-client.* mysql-admin-common mysql-common libdbd-mysql-perl
openssl openssl libnet-ssleay-perl
php4 php4 php4-cgi libapache2-mod-php4
php5 php5 php5-cgi libapache2-mod-php5 php-pear
apache apache2
fcgid libapache2-mod-fcgid
virtualmin-modules webmin-.* usermin-.*
clamav clamav clamav-.*
dovecot dovecot.*

View File

@ -1,5 +0,0 @@
bind bind9
spamassassin p5-Mail-SpamAssassin
mysql mysql-client mysql-server p5-Class-DBI-mysql
postgresql postgresql-client postgresql-server postgresql-contrib p5-Class-DBI-Pg
*

View File

@ -1,5 +0,0 @@
mysql mysql DBD-mysql
postgresql postgresql DBD-Pg
php4 php
openssl openssl Net-SSLeay
*

View File

@ -1,11 +0,0 @@
apache apache-base
spamassassin spamassassin spamassassin-spamc spamassassin-spamd
mysql MySQL MySQL-client MySQL-common perl-DBD-mysql
postgresql postgresql postgresql-server perl-DBD-Pg
clamav clamav clamav-db clamd
php4 php4 php4-cgi ph4-cli
php5 php php-cgi php-cgi php-pear
ruby ruby ruby-RubyGems
perl perl apache-mod_perl
fcgid mod_fcgid
virtualmin-modules wbm-.* wbt-.* usm-.* ust-.*

View File

@ -1 +0,0 @@
resolve.freebsd

View File

@ -1,9 +0,0 @@
apache apache
postfix postfix
sendmail sendmail sendmail-cf
bind bind bind-utils
procmail procmail
logrotate logrotate
webalizer webalizer
mysql mysql mysql-client mysql-server
proftpd proftpd proftpd-inetd

View File

@ -1 +0,0 @@
resolve.freebsd

View File

@ -1,8 +0,0 @@
postgresql postgresql postgresql-server rh-postgresql rh-postgresql-server perl-DBD-Pg
mysql mysql mysql-server perl-DBD-MySQL
perl perl mod_perl perl-libwww-perl perl-Digest-HMAC perl-Digest-SHA1 perl-XML-Simple
openssl openssl perl-Net-SSLeay perl-Crypt-SSLeay
php4 php php-cli
php5 php5 php5-cli
fcgid mod_fcgid
virtualmin-modules wbm-.* wbt-.* usm-.* ust-.*

View File

@ -1,9 +0,0 @@
apache apache2
mysql mysql4
clamav clamav libclamav
subversion subversion ap2_subversion
ruby ruby rubygems
rdoc rubydoc
openssl openssl pm_netssleay pm_cryptssleay
perl perl pm_libwww pm_digesthmac pm_digestsha1 pm_xmlsimple
php5 php5 ap2_modphp5

View File

@ -57,6 +57,6 @@ else {
print "$msg<p>\n";
&webmin_log("sched", undef, $in{'sched_def'} ? 0 : 1);
&ui_print_footer("index.cgi?all=$in{'all'}&mode=$in{'mode'}&search=".
&ui_print_footer("index.cgi?mode=$in{'mode'}&search=".
&urlize($in{'search'}), $text{'index_return'});

View File

@ -3,7 +3,7 @@
require './package-updates-lib.pl';
&ReadParse();
$redir = "index.cgi?mode=".&urlize($in{'mode'})."&all=".&urlize($in{'all'}).
$redir = "index.cgi?mode=".&urlize($in{'mode'}).
"&search=".&urlize($in{'search'});
if ($in{'refresh'}) {
@ -44,7 +44,6 @@ else {
if (@ops) {
# Ask first
print &ui_form_start("update.cgi", "post");
print &ui_hidden("all", $in{'all'});
print &ui_hidden("mode", $in{'mode'});
print &ui_hidden("search", $in{'search'});
foreach $ps (@pkgs) {
@ -54,8 +53,7 @@ else {
print &ui_form_end([ [ "confirm", $text{'update_confirm'} ] ]);
# Show table of all depends
@current = $in{'all'} ? &list_all_current(1)
: &list_current(1);
@current = &list_current(1);
print &ui_columns_start([ $text{'index_name'},
$text{'update_oldver'},
$text{'update_newver'},
@ -66,7 +64,7 @@ else {
$_->{'system'} eq $p->{'system'} } @current;
if (!$c && !@avail) {
# Only get available if needed
@avail = &list_available(0, $in{'all'});
@avail = &list_available(0);
}
($a) = grep { $_->{'name'} eq $p->{'name'} &&
$_->{'system'} eq $p->{'system'} } @avail;
@ -87,7 +85,7 @@ else {
($p, $s) = split(/\//, $ps);
print &text('update_pkg', "<tt>$p</tt>"),"<br>\n";
print "<ul>\n";
push(@got, &package_install($p, $s, $in{'all'}));
push(@got, &package_install($p, $s));
print "</ul><br>\n";
}
if (@got) {
@ -98,7 +96,7 @@ else {
}
# Refresh collected package info
if (&foreign_checked("system-status")) {
if (&foreign_check("system-status")) {
&foreign_require("system-status");
&system_status::refresh_possible_packages(\@got);
}

View File

@ -6,10 +6,10 @@ require './package-updates-lib.pl';
&ReadParse();
# Get the package
@avail = &list_available(0, $in{'all'});
@avail = &list_available(0);
($a) = grep { $_->{'name'} eq $in{'name'} &&
$_->{'system'} eq $in{'system'} } @avail;
@current = $in{'all'} ? &list_all_current(0) : &list_current(0);
@current = &list_current(0);
($c) = grep { $_->{'name'} eq $in{'name'} &&
$_->{'system'} eq $in{'system'} } @current;
$p = $a || $c;
@ -18,7 +18,6 @@ print &ui_form_start("save_view.cgi");
print &ui_hidden("name", $p->{'name'});
print &ui_hidden("system", $p->{'system'});
print &ui_hidden("version", $p->{'version'});
print &ui_hidden("all", $in{'all'});
print &ui_hidden("mode", $in{'mode'});
print &ui_table_start($text{'view_header'}, undef, 2);
@ -73,7 +72,7 @@ elsif ($a && !$c) {
}
print &ui_form_end(\@buts);
&ui_print_footer("index.cgi?all=$in{'all'}&mode=$in{'mode'}&search=".
&ui_print_footer("index.cgi?mode=$in{'mode'}&search=".
&urlize($in{'search'}),
$text{'index_return'});

View File

@ -1,7 +1,4 @@
# Functions for collecting general system info
#
# XXX Collect from Cloudmin
# XXX Cloudmin should enable background collection
BEGIN { push(@INC, ".."); };
eval "use WebminCore;";
@ -100,7 +97,7 @@ my %pkgs = map { $_, 1 } @$pkgs;
my $info = &get_collected_info();
if ($info->{'poss'} && &foreign_installed("package-updates")) {
&foreign_require("package-updates");
my @poss = &package_updates::list_possible_updates(2, 1);
my @poss = &package_updates::list_possible_updates(2);
$info->{'poss'} = \@poss;
}
&save_collected_info($info);