- Added possibility to list available upgrades from commandline using 'pakfire list upgrade'. - Added exitcode to 'pakfire list' - Moved 'Pakfire has finished' log message inside END block to always log when pakfire exited. - Fix: allow [options] between 'list' and [installed/notinstalled/ upgrade] parameters (Partly fixes Bug #12868)
Signed-off-by: Robin Roevens robin.roevens@disroot.org --- src/pakfire/lib/functions.pl | 2 +- src/pakfire/pakfire | 30 ++++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/src/pakfire/lib/functions.pl b/src/pakfire/lib/functions.pl index 4f0515f62..d8b5c5a26 100644 --- a/src/pakfire/lib/functions.pl +++ b/src/pakfire/lib/functions.pl @@ -114,7 +114,7 @@ sub usage { &Pakfire::message("Usage: pakfire <install|remove> [options] <pak(s)>"); &Pakfire::message(" <update> - Contacts the servers for new lists of paks."); &Pakfire::message(" <upgrade> - Installs the latest version of all paks."); - &Pakfire::message(" <list> - Outputs a short list with all available paks."); + &Pakfire::message(" <list> [installed/notinstalled/upgrade] - Outputs a list with all, installed, available or upgradeable paks."); &Pakfire::message(" <status> - Outputs a summary about available core upgrades, updates and a required reboot"); &Pakfire::message(""); &Pakfire::message(" Global options:"); diff --git a/src/pakfire/pakfire b/src/pakfire/pakfire index 351d71216..766d91b81 100644 --- a/src/pakfire/pakfire +++ b/src/pakfire/pakfire @@ -329,14 +329,18 @@
} elsif ("$ARGV[0]" eq "list") { my $count; + my $coreupdate = 0; my $use_color = ""; my $reset_color = ""; my $filter = "all";
- if ("$ARGV[1]" =~ /installed|notinstalled/) { + shift if ("$ARGV[1]" =~ "^-"); + + if ("$ARGV[1]" =~ /installed|notinstalled|upgrade/) { $filter = "$ARGV[1]"; - } else { - &Pakfire::message("PAKFIRE WARN: Not a known option $ARGV[1]") if ($ARGV[1]); + } elsif ($ARGV[1]) { + &Pakfire::message("PAKFIRE ERROR: Not a known option $ARGV[1]"); + exit 1; }
my $pak; @@ -347,6 +351,17 @@ $use_color = "$Pakfire::color{'lightgreen'}"; }
+ # Check for available core upgrade first if list of upgrades is requested + if ("$filter" eq "upgrade") { + my %coredb = &Pakfire::coredbinfo(); + + if (defined $coredb{'AvailableRelease'}) { + print "${use_color}Core-Update $coredb{'CoreVersion'}\n"; + print "Release: $coredb{'Release'} -> $coredb{'AvailableRelease'}${reset_color}\n\n"; + $coreupdate = 1; + } + } + foreach $pak (sort keys %paklist) { if ("$Pakfire::enable_colors" eq "1") { if ("$paklist{$pak}{'Installed'}" eq "yes") { @@ -373,7 +388,10 @@ if ($count > 0) { print "$count packages total.\n"; } else { - &Pakfire::message("PAKFIRE WARN: No packages where found using filter $filter."); + if (! $coreupdate) { + &Pakfire::message("PAKFIRE WARN: No packages where found using filter $filter."); + exit 1; + } } } elsif ("$ARGV[0]" eq "resolvedeps") { foreach (@ARGV) { @@ -399,9 +417,9 @@ &Pakfire::usage; }
- &Pakfire::logger("PAKFIRE INFO: Pakfire has finished. Closing."); - END { + &Pakfire::logger("PAKFIRE INFO: Pakfire has finished. Closing."); + # Check if pakfire has been locked in this session. if ($locked) { # Remove lockfile.