From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH 9/9] pakfire: Redesign update output and workflow Date: Wed, 09 Mar 2022 23:56:55 +0100 Message-ID: <20220309225655.4472-10-robin.roevens@disroot.org> In-Reply-To: <20220309225655.4472-1-robin.roevens@disroot.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3428868027801989798==" List-Id: --===============3428868027801989798== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable - Revamped 'pakfire update' more in the style of 'pakfire install' for a more consistent look and feel. - Add core update details to output - Add new dependencies to install to output - First collect all upgrade info, then perform core update together with available package updates and after user confirmation (without -y). Signed-off-by: Robin Roevens --- src/pakfire/pakfire | 79 +++++++++++++++++++++++++++++---------------- 1 file changed, 51 insertions(+), 28 deletions(-) diff --git a/src/pakfire/pakfire b/src/pakfire/pakfire index 9935481a5..0a144c517 100644 --- a/src/pakfire/pakfire +++ b/src/pakfire/pakfire @@ -258,51 +258,76 @@ &Pakfire::getcoredb("$force"); =20 } elsif ("$ARGV[0]" eq "upgrade") { - my $use_color =3D ""; - my $reset_color =3D ""; - - if ("$Pakfire::enable_colors" eq "1") { - $reset_color =3D "$Pakfire::color{'normal'}"; - $use_color =3D "$Pakfire::color{'lightpurple'}"; - } - &Pakfire::message("CORE INFO: Checking for Core updates..."); - ### Make sure that the core db is not outdated.=20 &Pakfire::getcoredb("noforce"); - my %coredb =3D &Pakfire::coredbinfo(); =20 - if (defined $coredb{'AvailableRelease'}) { - &Pakfire::upgradecore(); - } else { - &Pakfire::message("CORE WARN: No new Core upgrades available. You are on = release ".$coredb{'Release'}); - } + my %coredb =3D &Pakfire::coredbinfo(); + &Pakfire::message("CORE WARN: No new Core upgrades available. You are on r= elease ".$coredb{'Release'}) unless (defined $coredb{'AvailableRelease'}); =20 &Pakfire::message("PAKFIRE INFO: Checking for package updates..."); ### Make sure that the package list is not outdated.=20 &Pakfire::dbgetlist("noforce"); =09 my @deps =3D (); - if (my %upgradepaks =3D &Pakfire::dblist("upgrade")) { - # Resolve the dependencies of the to be upgraded packages - @deps =3D &Pakfire::resolvedeps_recursive(keys %upgradepaks); + my %upgradepaks =3D &Pakfire::dblist("upgrade"); =20 - foreach $pak (sort keys %upgradepaks) { - print "${use_color}Update: $pak\nVersion: $upgradepaks{$pak}{'ProgVersio= n'} -> $upgradepaks{$pak}{'AvailableProgVersion'}\n"; - print "Release: $upgradepaks{$pak}{'Release'} -> $upgradepaks{$pak}{'Ava= ilableRelease'}${reset_color}\n"; - } + # Resolve the dependencies of the to be upgraded packages + @deps =3D &Pakfire::resolvedeps_recursive(keys %upgradepaks) if (%upgradep= aks); + &Pakfire::message("PAKFIRE WARN: No new package upgrades available.") unle= ss (@deps); + + if (defined $coredb{'AvailableRelease'} || %upgradepaks) { + &Pakfire::message(""); &Pakfire::message(""); - &Pakfire::message("PAKFIRE UPGR: We are going to install all packages lis= ted above."); + &Pakfire::message("PAKFIRE INFO: Upgrade summary:"); + &Pakfire::message(""); + + if (defined $coredb{'AvailableRelease'}) { + &Pakfire::message("CORE INFO: Core-Update $coredb{'CoreVersion'} to inst= all:"); + &Pakfire::message("CORE UPGR: Release: $coredb{'Release'} -> $coredb{'A= vailableRelease'}"); + &Pakfire::message(""); + } + + if (@deps) { + &Pakfire::message("PAKFIRE INFO: New dependencies to install:"); + my $totalsize =3D 0; + foreach $pak (@deps) { + unless (defined $upgradepaks{$pak} || &Pakfire::isinstalled($pak) =3D= =3D 0) { + my $size =3D &Pakfire::getsize("$pak"); + $totalsize +=3D $size; + $size =3D &Pakfire::beautifysize($size); + &Pakfire::message("PAKFIRE INFO: $pak \t - $size"); + } + } + $totalsize =3D &Pakfire::beautifysize($totalsize); + &Pakfire::message(""); + &Pakfire::message("PAKFIRE INFO: Total size: \t ~ $totalsize"); + &Pakfire::message(""); + } + + if (%upgradepaks) { + &Pakfire::message("PAKFIRE INFO: Packages to upgrade:"); + foreach $pak (sort keys %upgradepaks) { + &Pakfire::message("PAKFIRE UPGR: $pak\t$upgradepaks{$pak}{'ProgVersion= '}-$upgradepaks{$pak}{'Release'} -> $upgradepaks{$pak}{'AvailableProgVersion'= }-$upgradepaks{$pak}{'AvailableRelease'}"); + } + &Pakfire::message(""); + } + if ($interactive) { - &Pakfire::message("PAKFIRE INFO: Is this okay? [y/N]"); + &Pakfire::message("PAKFIRE INFO: Is this okay? [y/N]"); my $ret =3D ; chomp($ret); &Pakfire::logger("PAKFIRE INFO: Answer: $ret"); if ( $ret ne "y" ) { - &Pakfire::message("PAKFIRE ERROR: Installation aborted."); - exit 1; + &Pakfire::message("PAKFIRE ERROR: Installation aborted."); + exit 1; } } + + # Perform core update + if (defined $coredb{'AvailableRelease'}) { + &Pakfire::upgradecore(); + } =09 # Download packages foreach $pak (sort keys %upgradepaks) { @@ -323,8 +348,6 @@ foreach $pak (sort keys %upgradepaks) { &Pakfire::upgradepak("$pak"); } - } else { - &Pakfire::message("PAKFIRE WARN: No new package upgrades available."); } =20 } elsif ("$ARGV[0]" eq "list") { --=20 2.34.1 --=20 Dit bericht is gescanned op virussen en andere gevaarlijke inhoud door MailScanner en lijkt schoon te zijn. --===============3428868027801989798==--