From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v2 06/10] pakfire: Add list upgrade functionality Date: Thu, 28 Jul 2022 13:21:32 +0200 Message-ID: <20220728112136.30218-7-robin.roevens@disroot.org> In-Reply-To: <20220728112136.30218-1-robin.roevens@disroot.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1251006792473112399==" List-Id: --===============1251006792473112399== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable - 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 --- 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 [options] "); &Pakfire::message(" - Contacts the servers for new = lists of paks."); &Pakfire::message(" - Installs the latest version = of all paks."); - &Pakfire::message(" - Outputs a short list with all a= vailable paks."); + &Pakfire::message(" [installed/notinstalled/upgrade] = - Outputs a list with all, installed, available or upgradeable paks."); &Pakfire::message(" - Outputs a summary about avail= able 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 @@ =20 } elsif ("$ARGV[0]" eq "list") { my $count; + my $coreupdate =3D 0; my $use_color =3D ""; my $reset_color =3D ""; my $filter =3D "all"; =20 - if ("$ARGV[1]" =3D~ /installed|notinstalled/) { + shift if ("$ARGV[1]" =3D~ "^-");=20 + + if ("$ARGV[1]" =3D~ /installed|notinstalled|upgrade/) { $filter =3D "$ARGV[1]"; - } else { - &Pakfire::message("PAKFIRE WARN: Not a known option $ARGV[1]") if ($ARGV[= 1]);=20 + } elsif ($ARGV[1]) { + &Pakfire::message("PAKFIRE ERROR: Not a known option $ARGV[1]");=20 + exit 1; } =20 my $pak; @@ -347,6 +351,17 @@ $use_color =3D "$Pakfire::color{'lightgreen'}"; } =20 + # Check for available core upgrade first if list of upgrades is requested + if ("$filter" eq "upgrade") { + my %coredb =3D &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 =3D 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 $fi= lter."); + if (! $coreupdate) { + &Pakfire::message("PAKFIRE WARN: No packages where found using filter $f= ilter."); + exit 1; + } } } elsif ("$ARGV[0]" eq "resolvedeps") { foreach (@ARGV) { @@ -399,9 +417,9 @@ &Pakfire::usage; } =20 - &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. --=20 2.36.1 --=20 Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn. --===============1251006792473112399==--