Speed up policy checking on Debian
This commit is contained in:
parent
35968fb346
commit
d3178eedf5
@ -5,6 +5,9 @@ require './package-updates-lib.pl';
|
||||
&ui_print_header(undef, $module_info{'desc'}, "", undef, 1, 1);
|
||||
&error_setup($text{'index_err'});
|
||||
&ReadParse();
|
||||
if ($in{'clear'}) {
|
||||
$in{'search'} = '';
|
||||
}
|
||||
|
||||
# See if any security updates exist
|
||||
$in{'mode'} ||= 'updates';
|
||||
@ -55,7 +58,8 @@ elsif ($showall == 2) {
|
||||
|
||||
# Show search box
|
||||
push(@grid, $text{'index_search'}, &ui_textbox("search", $in{'search'}, 30)." ".
|
||||
&ui_submit($text{'index_searchok'}));
|
||||
&ui_submit($text{'index_searchok'})." ".
|
||||
&ui_submit($text{'index_clear'}, 'clear'));
|
||||
|
||||
print &ui_form_start("index.cgi");
|
||||
print &ui_hidden("all", $showall ? 1 : 0);
|
||||
@ -165,7 +169,8 @@ print &ui_form_columns_table(
|
||||
undef,
|
||||
0,
|
||||
undef,
|
||||
$text{'index_none_'.$in{'mode'}}
|
||||
$text{'index_none_'.$in{'mode'}},
|
||||
1
|
||||
);
|
||||
|
||||
# Show scheduled report form
|
||||
|
@ -44,6 +44,7 @@ index_none_new=No new packages for installation were found.
|
||||
index_count=Found $1 matching packages ..
|
||||
index_search=Find packages matching:
|
||||
index_searchok=Search
|
||||
index_clear=Show All
|
||||
|
||||
update_title=Update Packages
|
||||
update_pkg=Now updating $1 ..
|
||||
|
@ -1,4 +1,4 @@
|
||||
desc=Package Updates
|
||||
category=system
|
||||
depends=software cron mailboxes 1.420
|
||||
os_support=redhat-linux debian-linux mandrake-linux/10.2-* solaris freebsd
|
||||
os_support=redhat-linux debian-linux mandrake-linux/10.2-* solaris
|
||||
|
@ -5,6 +5,7 @@
|
||||
# XXX re-check after package update
|
||||
# XXX test automatic notification
|
||||
# XXX test on debian
|
||||
# XXX show what will be done
|
||||
|
||||
BEGIN { push(@INC, ".."); };
|
||||
eval "use WebminCore;";
|
||||
@ -212,7 +213,6 @@ if ($nocache || &cache_expired($available_cache_file.int($all))) {
|
||||
$avail->{'name'} =
|
||||
&csw_to_pkgadd($avail->{'name'});
|
||||
$avail->{'package'} = $p;
|
||||
&set_pinned_version($avail);
|
||||
push(@rv, $avail);
|
||||
}
|
||||
}
|
||||
@ -223,17 +223,12 @@ if ($nocache || &cache_expired($available_cache_file.int($all))) {
|
||||
foreach my $avail (@avail) {
|
||||
$avail->{'update'} = $avail->{'name'};
|
||||
$avail->{'name'} = &csw_to_pkgadd($avail->{'name'});
|
||||
&set_pinned_version($avail);
|
||||
push(@rv, $avail);
|
||||
}
|
||||
}
|
||||
|
||||
# Set descriptions if needed
|
||||
foreach my $avail (@rv) {
|
||||
if (&installation_candiate($avail)) {
|
||||
$avail->{'desc'} ||= &generate_description($avail);
|
||||
}
|
||||
}
|
||||
# Set pinned versions
|
||||
&set_pinned_versions(\@rv);
|
||||
|
||||
# Filter out dupes and sort by name
|
||||
@rv = &filter_duplicates(\@rv);
|
||||
@ -647,77 +642,6 @@ local ($p) = @_;
|
||||
return 1;
|
||||
}
|
||||
|
||||
# generate_description(package)
|
||||
# Fakes up a description for a Webmin/Usermin module/theme package
|
||||
sub generate_description
|
||||
{
|
||||
local ($p) = @_;
|
||||
local $name = $p->{'name'};
|
||||
if ($p->{'system'} eq 'yum') {
|
||||
# Use yum info to get the description, and cache it
|
||||
local %yumcache;
|
||||
&read_file_cached($yum_cache_file, \%yumcache);
|
||||
if ($yumcache{$p->{'name'}."-".$p->{'version'}}) {
|
||||
return $yumcache{$p->{'name'}."-".$p->{'version'}};
|
||||
}
|
||||
local ($desc, $started_desc);
|
||||
open(YUM, "yum info ".quotemeta($name)." |");
|
||||
while(<YUM>) {
|
||||
s/\r|\n//g;
|
||||
if (/^Description:\s*(.*)$/) {
|
||||
$desc = $1;
|
||||
$started_desc = 1;
|
||||
}
|
||||
elsif (/\S/ && $started_desc) {
|
||||
$desc .= " ".$_;
|
||||
}
|
||||
}
|
||||
close(YUM);
|
||||
$desc =~ s/^\s+//;
|
||||
$yumcache{$p->{'name'}."-".$p->{'version'}} = $desc;
|
||||
&write_file($yum_cache_file, \%yumcache);
|
||||
return $desc if ($desc =~ /\S/);
|
||||
}
|
||||
elsif ($p->{'system'} eq 'apt') {
|
||||
# Use APT to get description
|
||||
local %aptcache;
|
||||
&read_file_cached($apt_cache_file, \%aptcache);
|
||||
if ($aptcache{$p->{'name'}."-".$p->{'version'}}) {
|
||||
return $aptcache{$p->{'name'}."-".$p->{'version'}};
|
||||
}
|
||||
local ($desc, $started_desc);
|
||||
open(YUM, "apt-cache show ".quotemeta($name)." |");
|
||||
while(<YUM>) {
|
||||
s/\r|\n//g;
|
||||
if (/^Description:\s*(.*)$/) {
|
||||
$desc = $1;
|
||||
}
|
||||
}
|
||||
close(YUM);
|
||||
$aptcache{$p->{'name'}."-".$p->{'version'}} = $desc;
|
||||
&write_file($apt_cache_file, \%aptcache);
|
||||
return $desc if ($desc =~ /\S/);
|
||||
}
|
||||
|
||||
return # RPM names
|
||||
$name =~ /^wbm-virtualmin-/ ? "Virtualmin plugin" :
|
||||
$name =~ /^wbm-vm2-/ ? "Cloudmin plugin" :
|
||||
$name =~ /^wbm-/ ? "Webmin module" :
|
||||
$name =~ /^wbt-virtualmin-/ ? "Virtualmin theme" :
|
||||
$name =~ /^wbt-/ ? "Webmin theme" :
|
||||
$name =~ /^usm-/ ? "Usermin module" :
|
||||
$name =~ /^ust-/ ? "Usermin theme" :
|
||||
|
||||
# Debian names
|
||||
$name =~ /^webmin-virtualmin-/ ? "Virtualmin plugin or theme" :
|
||||
$name =~ /^webmin-vm2-/ ? "Cloudmin plugin" :
|
||||
$name =~ /^webmin-/ ? "Webmin module" :
|
||||
$name =~ /^usermin-virtualmin-/ ? "Usermin theme" :
|
||||
$name =~ /^usermin-/ ? "Usermin module" :
|
||||
|
||||
undef;
|
||||
}
|
||||
|
||||
# clear_repository_cache()
|
||||
# Clear any YUM or APT caches
|
||||
sub clear_repository_cache
|
||||
@ -730,71 +654,27 @@ elsif ($software::update_system eq "apt") {
|
||||
}
|
||||
}
|
||||
|
||||
# set_pinned_version(&package)
|
||||
# Given an APT package from the available, use apt-cache policy to check if it
|
||||
# should have the version number reduced to the pinned version.
|
||||
sub set_pinned_version
|
||||
# set_pinned_versions(&packages)
|
||||
# If on Debian, set available package versions based on APT pinning
|
||||
sub set_pinned_versions
|
||||
{
|
||||
local ($pkg) = @_;
|
||||
return 0 if ($pkg->{'system'} ne 'apt');
|
||||
local $rv = 0;
|
||||
local $qp = quotemeta($pkg->{'name'});
|
||||
local $out = &backquote_command("LANG='' LC_ALL='' apt-cache policy $qp 2>/dev/null");
|
||||
local $installed = $out =~ /Installed:\s+(\S+)/ ? $1 : undef;
|
||||
local $candidate = $out =~ /Candidate:\s+(\S+)/ ? $1 : undef;
|
||||
$candidate = "" if ($candidate eq "(none)");
|
||||
if ($installed && $candidate) {
|
||||
# An installation candidate is defined .. use it
|
||||
local $cepoch;
|
||||
if ($candidate =~ s/^(\d+)://) {
|
||||
$cepoch = $1;
|
||||
}
|
||||
if ($pkg->{'version'} ne $candidate) {
|
||||
$pkg->{'version'} = $candidate;
|
||||
$pkg->{'epoch'} = $cepoch;
|
||||
}
|
||||
$rv = 1;
|
||||
}
|
||||
if ($installed && $candidate &&
|
||||
$gconfig{'os_type'} eq 'debian-linux' && $gconfig{'os_version'} eq '4.0') {
|
||||
# Don't offer to upgrade to Lenny packages .. first work out which
|
||||
# versions apt-get knows about.
|
||||
local @lines = split(/\r?\n/, $out);
|
||||
local $found_versions;
|
||||
local @versions;
|
||||
for(my $i=0; $i<@lines; $i++) {
|
||||
if ($lines[$i] =~ /\s*Version\s+table:/i) {
|
||||
$found_versions = 1;
|
||||
next;
|
||||
}
|
||||
next if (!$found_versions);
|
||||
if ($lines[$i] =~ /^[ \*]+(\S+)/) {
|
||||
# Found a version number
|
||||
local $ver = $1;
|
||||
$i++;
|
||||
if ($lines[$i] =~ /^\s+(\d+)\s+(\S.*)$/) {
|
||||
push(@versions, { 'version' => $ver,
|
||||
'pri' => $1,
|
||||
'url' => $2 });
|
||||
my ($avail) = @_;
|
||||
my @davail = grep { $_->{'system'} eq 'apt' } @$avail;
|
||||
return 0 if (!@davail);
|
||||
my $out = &backquote_command("LANG='' LC_ALL='' apt-cache policy 2>/dev/null");
|
||||
my $rv;
|
||||
foreach my $l (split(/\r?\n/, $out)) {
|
||||
if ($l =~ /\s+(\S+)\s+\-\>\s+(\S+)/) {
|
||||
my ($name, $pin) = ($1, $2);
|
||||
my ($pkg) = grep { $_->{'name'} eq $name } @davail;
|
||||
if ($pkg) {
|
||||
$pkg->{'version'} = $pin;
|
||||
if ($pkg->{'version'} =~ s/^(\d+)://) {
|
||||
$pkg->{'epoch'} = $1;
|
||||
}
|
||||
$rv++;
|
||||
}
|
||||
}
|
||||
# If the latest version is from stable, don't use it
|
||||
@versions = sort { &compare_versions($b, $a) } @versions;
|
||||
local ($nv) = grep { $_->{'version'} eq $pkg->{'version'} ||
|
||||
$_->{'version'} eq $pkg->{'epoch'}.':'.
|
||||
$pkg->{'version'} } @versions;
|
||||
if ($nv && $nv->{'url'} =~ /stable/ && $nv->{'url'} !~ /virtualmin/) {
|
||||
shift(@versions);
|
||||
local $safever = @versions ? $versions[0]->{'version'}
|
||||
: $installed;
|
||||
local $sepoch;
|
||||
if ($safever =~ s/^(\d+)://) {
|
||||
$sepoch = $1;
|
||||
}
|
||||
$pkg->{'version'} = $safever;
|
||||
$pkg->{'epoch'} = $sepoch;
|
||||
}
|
||||
}
|
||||
return $rv;
|
||||
}
|
||||
|
@ -488,7 +488,7 @@ $rv .= &ui_columns_end();
|
||||
return $rv;
|
||||
}
|
||||
|
||||
=head2 ui_form_columns_table(cgi, &buttons, select-all, &otherlinks, &hiddens, &headings, width-percent, &data, &types, no-sort, title, empty-msg)
|
||||
=head2 ui_form_columns_table(cgi, &buttons, select-all, &otherlinks, &hiddens, &headings, width-percent, &data, &types, no-sort, title, empty-msg, form-no)
|
||||
|
||||
Similar to ui_columns_table, but wrapped in a form. Parameters are :
|
||||
|
||||
@ -510,7 +510,7 @@ sub ui_form_columns_table
|
||||
return &theme_ui_form_columns_table(@_)
|
||||
if (defined(&theme_ui_form_columns_table));
|
||||
my ($cgi, $buttons, $selectall, $others, $hiddens,
|
||||
$heads, $width, $data, $types, $nosort, $title, $emptymsg) = @_;
|
||||
$heads, $width, $data, $types, $nosort, $title, $emptymsg, $formno) = @_;
|
||||
my $rv;
|
||||
|
||||
# Build links
|
||||
@ -533,8 +533,8 @@ if (@$data) {
|
||||
}
|
||||
}
|
||||
if ($cbname) {
|
||||
unshift(@leftlinks, &select_all_link($cbname),
|
||||
&select_invert_link($cbname));
|
||||
unshift(@leftlinks, &select_all_link($cbname, $formno),
|
||||
&select_invert_link($cbname, $formno));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user