From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v2 08/10] pakfire: Replace status duplicate code Date: Thu, 28 Jul 2022 13:21:34 +0200 Message-ID: <20220728112136.30218-9-robin.roevens@disroot.org> In-Reply-To: <20220728112136.30218-1-robin.roevens@disroot.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0993566251383402795==" List-Id: --===============0993566251383402795== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable - Make use of renewed status function in pakfire.cgi removing duplicate code Signed-off-by: Robin Roevens --- html/cgi-bin/pakfire.cgi | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/html/cgi-bin/pakfire.cgi b/html/cgi-bin/pakfire.cgi index cb1272c63..42c603c61 100644 --- a/html/cgi-bin/pakfire.cgi +++ b/html/cgi-bin/pakfire.cgi @@ -43,6 +43,9 @@ my $PM_DEFAULT =3D 'default'; # Default user interface with= command processing my $PM_LOGREAD =3D 'logread'; # Log messages viewer (ignores all commands) my $pagemode =3D $PM_DEFAULT; =20 +# Get Pakfire status +my %pakfire_status =3D &Pakfire::status(); + # Load general settings &General::readhash("${General::swroot}/main/settings", \%mainsettings); &General::readhash("${General::swroot}/pakfire/settings", \%pakfiresettings); @@ -84,7 +87,7 @@ if($cgiparams{'ACTION'} eq 'json-getstatus') { my %status =3D ( 'running' =3D> &_is_pakfire_busy() || "0", 'running_since' =3D> &General::age("$Pakfire::lockfile") || "0s", - 'reboot' =3D> (-e "/var/run/need_reboot") || "0", + 'reboot' =3D> ("$pakfire_status{'RebootRequired'}" eq "yes") || "0", 'failure' =3D> $failure || "0" ); =20 @@ -366,32 +369,26 @@ $selected{"TREE"}{"testing"} =3D ""; $selected{"TREE"}{"unstable"} =3D ""; $selected{"TREE"}{$pakfiresettings{"TREE"}} =3D "selected"; =20 -my $core_release =3D `cat /opt/pakfire/db/core/mine 2>/dev/null`; -chomp($core_release); -my $core_update_age =3D &General::age("/opt/pakfire/db/core/mine"); -my $corelist_update_age =3D &General::age("/opt/pakfire/db/lists/core-list.d= b"); -my $server_update_age =3D &General::age("/opt/pakfire/db/lists/server-list.d= b"); -my $packages_update_age =3D &General::age("/opt/pakfire/db/lists/packages_li= st.db"); - &Header::openbox("100%", "center", "Pakfire"); =20 print < END -if ( -e "/var/run/need_reboot") { +if ("$pakfire_status{'RebootRequired'}" eq "yes") { print "\t\t$Lang::t= r{'needreboot'}!\n"; } + print <$Lang::tr{'pakfire system state'}: $Lang::tr{'available updates'}: =20 - $Lang::tr{'pakfire core update level'}: $core_release + $Lang::tr{'pakfire core update level'}: $pakfire_status{'R= elease'}
- $Lang::tr{'pakfire last update'} $core_update_age $Lang::tr{'pakfire ag= o'}
- $Lang::tr{'pakfire last serverlist update'} $server_update_age $Lang::t= r{'pakfire ago'}
- $Lang::tr{'pakfire last core list update'} $corelist_update_age $Lang::= tr{'pakfire ago'}
- $Lang::tr{'pakfire last package update'} $packages_update_age $Lang::tr= {'pakfire ago'} + $Lang::tr{'pakfire last update'} $pakfire_status{'LastUpdate'} $Lang::t= r{'pakfire ago'}
+ $Lang::tr{'pakfire last serverlist update'} $pakfire_status{'LastServer= ListUpdate'} $Lang::tr{'pakfire ago'}
+ $Lang::tr{'pakfire last core list update'} $pakfire_status{'LastCoreLis= tUpdate'} $Lang::tr{'pakfire ago'}
+ $Lang::tr{'pakfire last package update'} $pakfire_status{'LastPakListUp= date'} $Lang::tr{'pakfire ago'}
@@ -403,14 +400,15 @@ print < END =20 - my %coredb =3D &Pakfire::coredbinfo(); - if (defined $coredb{'AvailableRelease'}) { - print "\n"; + if ("$pakfire_status{'CoreUpdateAvailable'}" eq "yes") { + print "\n"; } =20 - my %upgradelist =3D &Pakfire::dblist("upgrade"); - foreach my $pak (sort keys %upgradelist) { - print "\n"; + if ($pakfire_status{'PakUpdatesAvailable'} > 0) { + my %upgradelist =3D &Pakfire::dblist("upgrade"); + foreach my $pak (sort keys %upgradelist) { + print "\n"; + } } =20 print <