Confirmation page for package updates

This commit is contained in:
Jamie Cameron
2009-10-02 14:47:50 -07:00
parent 65cd512ac1
commit f45911beb6
6 changed files with 109 additions and 29 deletions

View File

@@ -71,6 +71,7 @@ else {
"tunnel", "zones", "cluster-usermin", "dovecot", "syslog-ng",
"mailcap", "blue-theme", "ldap-client", "phpini", "filter",
"bacula-backup", "ldap-server", "exim", "tcpwrappers",
"package-updates",
);
}
@dirlist = ( "Webmin" );

View File

@@ -31,7 +31,9 @@ foreach $m ('all', 'updates', 'new', 'both',
push(@grid, $text{'index_mode'}, &ui_links_row(\@mlinks));
# Show all selector
if (&show_all_option()) {
$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};
@@ -46,13 +48,17 @@ if (&show_all_option()) {
}
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'}));
print &ui_form_start("index.cgi");
print &ui_hidden("all", &show_all_option() ? 1 : 0);
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();
@@ -128,7 +134,8 @@ foreach $p (sort { $a->{'name'} cmp $b->{'name'} } (@current, @avail)) {
'checked' => $need },
"<a href='view.cgi?all=$in{'all'}&mode=$in{'mode'}&name=".
&urlize($p->{'name'})."&system=".
&urlize($p->{'system'})."'>$p->{'name'}</a>",
&urlize($p->{'system'})."&search=".
&urlize($in{'search'})."'>$p->{'name'}</a>",
$p->{'desc'},
$msg,
$source ? ( $source ) : $anysource ? ( "") : ( ),

View File

@@ -71,6 +71,11 @@ update_tgzuntardone=.. done
update_tgzsetup=Running setup script ..
update_tgzsetupdone=.. upgrade complete
update_etgzsetup=.. upgrade failed! See the error message above for the reason why
update_rusure=Are you sure you wish to install the $1 packages listed below? This may include dependencies of packages that you selected.
update_oldver=Current version
update_newver=New version
update_confirm=Install Now
update_none=None
sched_title=Scheduled Update
sched_yes=Scheduled checking for updates is now active.

View File

@@ -2,8 +2,9 @@
# update system.
#
# XXX cron job to collect .. actually use webmin module collector
# XXX confirmation form, showing all dependencies
# XXX re-check after package update
# XXX test automatic notification
# XXX test on debian
BEGIN { push(@INC, ".."); };
eval "use WebminCore;";
@@ -475,6 +476,21 @@ unlink($current_all_cache_file);
return @rv;
}
# list_package_operations(package, system)
# Given a package, returns a list of all dependencies that will be installed
sub list_package_operations
{
my ($name, $system) = @_;
if (defined(&software::update_system_operations)) {
my @rv = &software::update_system_operations($name);
foreach my $p (@rv) {
$p->{'system'} = $system;
}
return @rv;
}
return ( );
}
# 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.
@@ -832,11 +848,13 @@ if ($pkg->{'system'} eq 'yum') {
return undef;
}
# Returns 1 if an option should be shown to list all packages. Only true for
# YUM and APT at the moment
# 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 $software::update_system eq 'apt' || $software::update_system eq 'yum';
return !&foreign_check("virtual-server") ? 2 :
$software::update_system eq 'apt' ||
$software::update_system eq 'yum' ? 1 : 0;
}
sub flush_package_caches

View File

@@ -29,29 +29,77 @@ else {
@pkgs || &error($text{'update_enone'});
&ui_print_unbuffered_header(undef, $text{'update_title'}, "");
foreach my $ps (@pkgs) {
($p, $s) = split(/\//, $ps);
print &text('update_pkg', "<tt>$p</tt>"),"<br>\n";
print "<ul>\n";
push(@got, &package_install($p, $s, $in{'all'}));
print "</ul><br>\n";
}
if (@got) {
print &text('update_ok', scalar(@got)),"<p>\n";
}
else {
print $text{'update_failed'},"<p>\n";
}
# Refresh collected package info
if (&foreign_check("virtual-server") && @got) {
&foreign_require("virtual-server", "virtual-server-lib.pl");
if (defined(&virtual_server::refresh_possible_packages)) {
&virtual_server::refresh_possible_packages(\@got);
# Work out what will be done, if possible
@ops = ( );
if (!$in{'confirm'}) {
foreach my $ps (@pkgs) {
($p, $s) = split(/\//, $ps);
push(@ops, &list_package_operations($p, $s));
}
}
&webmin_log("update", "packages", scalar(@got),
{ 'got' => \@got });
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) {
print &ui_hidden("u", $ps);
}
print &text('update_rusure', scalar(@ops)),"<p>\n";
print &ui_form_end([ [ "confirm", $text{'update_confirm'} ] ]);
# Show table of all depends
@current = $in{'all'} ? &list_all_current(1)
: &list_current(1);
print &ui_columns_start([ $text{'index_name'},
$text{'update_oldver'},
$text{'update_newver'},
$text{'index_desc'},
], 100);
foreach $p (@ops) {
($c) = grep { $_->{'name'} eq $p->{'name'} &&
$_->{'system'} eq $p->{'system'} } @current;
if (!$c && !@avail) {
# Only get available if needed
@avail = &list_available(0, $in{'all'});
}
($a) = grep { $_->{'name'} eq $p->{'name'} &&
$_->{'system'} eq $p->{'system'} } @avail;
print &ui_columns_row([
$p->{'name'},
$c ? $c->{'version'}
: "<i>$text{'update_none'}</i>",
$p->{'version'},
$c ? $c->{'desc'} :
$a ? $a->{'desc'} : '',
]);
}
print &ui_columns_end();
}
else {
# Do it
foreach my $ps (@pkgs) {
($p, $s) = split(/\//, $ps);
print &text('update_pkg', "<tt>$p</tt>"),"<br>\n";
print "<ul>\n";
push(@got, &package_install($p, $s, $in{'all'}));
print "</ul><br>\n";
}
if (@got) {
print &text('update_ok', scalar(@got)),"<p>\n";
}
else {
print $text{'update_failed'},"<p>\n";
}
# Refresh collected package info
# XXX call webmin
&webmin_log("update", "packages", scalar(@got),
{ 'got' => \@got });
}
&ui_print_footer($redir, $text{'index_return'});
}

View File

@@ -73,6 +73,7 @@ elsif ($a && !$c) {
}
print &ui_form_end(\@buts);
&ui_print_footer("index.cgi?all=$in{'all'}&mode=$in{'mode'}",
&ui_print_footer("index.cgi?all=$in{'all'}&mode=$in{'mode'}&search=".
&urlize($in{'search'}),
$text{'index_return'});