# See if any security updates exist
$in{'mode'} ||= 'updates';
-@avail = &list_available(0);
+if ($in{'mode'} eq 'updates') {
+ @avail = &list_possible_updates(0);
+ }
+else {
+ @avail = &list_available(0);
+ }
($sec) = grep { $_->{'security'} } @avail;
# Show mode selector (all, updates only, updates and new)
update_title=Update Packages
update_pkg=Now updating $1 ..
+update_pkg2=Now installing $1 ..
update_done=Installed package $1 $2.
update_ok=Successfully installed $1 packages.
update_failed=No packages were installed. Check the messages above for the cause of the error.
{
my ($name, $system) = @_;
my @rv;
-my ($pkg) = grep { $_->{'update'} eq $name &&
- ($_->{'system'} eq $system || !$system) }
- sort { &compare_versions($b, $a) }
- &list_available(0);
+my $pkg;
+# First get from list of updates
+($pkg) = grep { $_->{'update'} eq $name &&
+ ($_->{'system'} eq $system || !$system) }
+ sort { &compare_versions($b, $a) }
+ &list_possible_updates(0);
+if (!$pkg) {
+ # Then try list of all available packages
+ ($pkg) = grep { $_->{'update'} eq $name &&
+ ($_->{'system'} eq $system || !$system) }
+ sort { &compare_versions($b, $a) }
+ &list_available(0);
+ }
if (!$pkg) {
print &text('update_efindpkg', $name),"<p>\n";
return ( );
'epoch' => $a->{'epoch'},
'oldepoch' => $c->{'epoch'},
'security' => $a->{'security'},
+ 'source' => $a->{'source'},
'desc' => $c->{'desc'} || $a->{'desc'} });
}
}
'epoch' => $a->{'epoch'},
'oldepoch' => $c->{'epoch'},
'security' => $a->{'security'},
+ 'source' => $a->{'source'},
'desc' => $c->{'desc'} || $a->{'desc'},
'severity' => 0 });
}
}
else {
# Do it
+ $msg = $in{'mode'} eq 'new' ? 'update_pkg2' : 'update_pkg';
foreach my $ps (@pkgs) {
($p, $s) = split(/\//, $ps);
next if ($donedep{$p});
- print &text('update_pkg', "<tt>$p</tt>"),"<br>\n";
+ print &text($msg, "<tt>$p</tt>"),"<br>\n";
print "<ul>\n";
@pgot = &package_install($p, $s);
foreach $g (@pgot) {
}
# See what needs doing
-@current = &list_current(1);
-@avail = &list_available(0);
-foreach $c (sort { $a->{'name'} cmp $b->{'name'} } @current) {
- ($a) = grep { $_->{'name'} eq $c->{'name'} &&
- $_->{'system'} eq $c->{'system'} } @avail;
- if ($a->{'version'} && &compare_versions($a, $c) > 0) {
- # An update is available
- push(@todo, { 'name' => $c->{'name'},
- 'update' => $a->{'update'},
- 'oldversion' => $c->{'version'},
- 'version' => $a->{'version'},
- 'level' => $a->{'security'} ? 1 : 2 });
- }
+@todo = &list_possible_updates();
+foreach $a (@todo) {
+ $a->{'level'} = $a->{'security'} ? 1 : 2;
}
# Install packages that are needed
&ReadParse();
# Get the package
-@avail = &list_available(0);
+@avail = $in{'mode'} eq 'updates' ? &list_possible_updates(0)
+ : &list_available(0);
($a) = grep { $_->{'name'} eq $in{'name'} &&
$_->{'system'} eq $in{'system'} } @avail;
@current = &list_current(0);
}
# Source, if available
-print &ui_table_row($text{'view_source'}, ucfirst($a->{'source'}));
+if ($a->{'source'}) {
+ print &ui_table_row($text{'view_source'}, ucfirst($a->{'source'}));
+ }
# Change log, if possible
if ($a) {
return @rv;
}
+# update_system_updates()
+# Returns a list of available package updates
+sub update_system_updates
+{
+if (&has_command("apt-show-versions")) {
+ # This awesome command can give us all updates in one hit
+ local @rv;
+ &open_execute_command(PKGS,
+ "LANG='' LC_ALL='' apt-show-versions", 1, 1);
+ while(<PKGS>) {
+ if (/^(\S+)\/(\S+)\s+upgradeable\s+from\s+(\S+)\s+to\s+(\S+)/) {
+ local $pkg = { 'name' => $1,
+ 'source' => $2,
+ 'version' => $4 };
+ if ($pkg->{'version'} =~ s/^(\S+)://) {
+ $pkg->{'epoch'} = $1;
+ }
+ push(@rv, $pkg);
+ }
+ }
+ close(PKGS);
+ return @rv;
+ }
+else {
+ # Need to manually compose by calling dpkg and apt-cache showpkg ..
+ local %packages;
+ local $n = &list_packages();
+ local %currentmap;
+ for(my $i=0; $i<$n; $i++) {
+ local $pkg = { 'name' => $packages{$i,'name'},
+ 'oldversion' => $packages{$i,'version'},
+ 'desc' => $packages{$i,'desc'},
+ 'oldepoch' => $packages{$i,'epoch'} };
+ $currentmap{$pkg->{'name'}} ||= $pkg;
+ }
+ local @rv;
+ local @names = keys %currentmap;
+ while(scalar(@names)) {
+ local @somenames;
+ if (scalar(@names) > 100) {
+ # Do 100 at a time
+ @somenames = @names[0..99];
+ @names = @names[100..$#names];
+ }
+ else {
+ # Do the rest
+ @somenames = @names;
+ @names = ( );
+ }
+ &open_execute_command(PKGS,
+ "LANG='' LC_ALL='' apt-cache showpkg ".
+ join(" ", @somenames), 1, 1);
+ local $pkg = undef;
+ while(<PKGS>) {
+ s/\r|\n//g;
+ if (/^\s*Package:\s*(\S+)/) {
+ $pkg = $currentmap{$1};
+ }
+ elsif (/^Versions:\s*$/ && $pkg && !$pkg->{'version'}) {
+ # Newest version is on next line
+ local $ver = <PKGS>;
+ $ver =~ s/\s.*\r?\n//;
+ local $epoch;
+ if ($ver =~ s/^(\d+)://) {
+ $epoch = $1;
+ }
+ $pkg->{'version'} = $ver;
+ $pkg->{'epoch'} = $epoch;
+ push(@rv, $pkg);
+ }
+ }
+ close(PKGS);
+ }
+ return @rv;
+ }
+}
'arch' => $2,
'version' => $3,
'source' => $4 };
- $pkg->{'version'} = $1;
if ($pkg->{'version'} =~ s/^(\S+)://) {
$pkg->{'epoch'} = $1;
}