From: Robin Roevens <robin.roevens@disroot.org>
To: development@lists.ipfire.org
Subject: [PATCH v2 08/10] pakfire: Replace status duplicate code
Date: Thu, 28 Jul 2022 13:21:34 +0200 [thread overview]
Message-ID: <20220728112136.30218-9-robin.roevens@disroot.org> (raw)
In-Reply-To: <20220728112136.30218-1-robin.roevens@disroot.org>
[-- Attachment #1: Type: text/plain, Size: 5049 bytes --]
- Make use of renewed status function in pakfire.cgi removing duplicate
code
Signed-off-by: Robin Roevens <robin.roevens(a)disroot.org>
---
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 = 'default'; # Default user interface with command processing
my $PM_LOGREAD = 'logread'; # Log messages viewer (ignores all commands)
my $pagemode = $PM_DEFAULT;
+# Get Pakfire status
+my %pakfire_status = &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 = (
'running' => &_is_pakfire_busy() || "0",
'running_since' => &General::age("$Pakfire::lockfile") || "0s",
- 'reboot' => (-e "/var/run/need_reboot") || "0",
+ 'reboot' => ("$pakfire_status{'RebootRequired'}" eq "yes") || "0",
'failure' => $failure || "0"
);
@@ -366,32 +369,26 @@ $selected{"TREE"}{"testing"} = "";
$selected{"TREE"}{"unstable"} = "";
$selected{"TREE"}{$pakfiresettings{"TREE"}} = "selected";
-my $core_release = `cat /opt/pakfire/db/core/mine 2>/dev/null`;
-chomp($core_release);
-my $core_update_age = &General::age("/opt/pakfire/db/core/mine");
-my $corelist_update_age = &General::age("/opt/pakfire/db/lists/core-list.db");
-my $server_update_age = &General::age("/opt/pakfire/db/lists/server-list.db");
-my $packages_update_age = &General::age("/opt/pakfire/db/lists/packages_list.db");
-
&Header::openbox("100%", "center", "Pakfire");
print <<END;
<table id="pfmain">
END
-if ( -e "/var/run/need_reboot") {
+if ("$pakfire_status{'RebootRequired'}" eq "yes") {
print "\t\t<tr><td colspan='2'><a href='/cgi-bin/shutdown.cgi'>$Lang::tr{'needreboot'}!</a></td></tr>\n";
}
+
print <<END;
<tr><td class="heading">$Lang::tr{'pakfire system state'}:</td>
<td class="heading">$Lang::tr{'available updates'}:</td></tr>
- <tr><td><strong>$Lang::tr{'pakfire core update level'}: $core_release</strong>
+ <tr><td><strong>$Lang::tr{'pakfire core update level'}: $pakfire_status{'Release'}</strong>
<hr>
<div class="pflist">
- $Lang::tr{'pakfire last update'} $core_update_age $Lang::tr{'pakfire ago'}<br>
- $Lang::tr{'pakfire last serverlist update'} $server_update_age $Lang::tr{'pakfire ago'}<br>
- $Lang::tr{'pakfire last core list update'} $corelist_update_age $Lang::tr{'pakfire ago'}<br>
- $Lang::tr{'pakfire last package update'} $packages_update_age $Lang::tr{'pakfire ago'}
+ $Lang::tr{'pakfire last update'} $pakfire_status{'LastUpdate'} $Lang::tr{'pakfire ago'}<br>
+ $Lang::tr{'pakfire last serverlist update'} $pakfire_status{'LastServerListUpdate'} $Lang::tr{'pakfire ago'}<br>
+ $Lang::tr{'pakfire last core list update'} $pakfire_status{'LastCoreListUpdate'} $Lang::tr{'pakfire ago'}<br>
+ $Lang::tr{'pakfire last package update'} $pakfire_status{'LastPakListUpdate'} $Lang::tr{'pakfire ago'}
</div>
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='update' />
@@ -403,14 +400,15 @@ print <<END;
<select name="UPDPAKS" class="pflist" size="5" disabled>
END
- my %coredb = &Pakfire::coredbinfo();
- if (defined $coredb{'AvailableRelease'}) {
- print "<option value=\"core\">$Lang::tr{'core update'} -- $coredb{'CoreVersion'} -- $Lang::tr{'release'}: $coredb{'Release'} -> $coredb{'AvailableRelease'}</option>\n";
+ if ("$pakfire_status{'CoreUpdateAvailable'}" eq "yes") {
+ print "<option value=\"core\">$Lang::tr{'core update'} -- $pakfire_status{'CoreVersion'} -- $Lang::tr{'release'}: $pakfire_status{'Release'} -> $pakfire_status{'AvailableRelease'}</option>\n";
}
- my %upgradelist = &Pakfire::dblist("upgrade");
- foreach my $pak (sort keys %upgradelist) {
- print "<option value=\"$pak\">$Lang::tr{'pak update'}: $pak -- $Lang::tr{'version'}: $upgradelist{$pak}{'ProgVersion'} -> $upgradelist{$pak}{'AvailableProgVersion'} -- $Lang::tr{'release'}: $upgradelist{$pak}{'Release'} -> $upgradelist{$pak}{'AvailableRelease'}</option>\n";
+ if ($pakfire_status{'PakUpdatesAvailable'} > 0) {
+ my %upgradelist = &Pakfire::dblist("upgrade");
+ foreach my $pak (sort keys %upgradelist) {
+ print "<option value=\"$pak\">$Lang::tr{'pak update'}: $pak -- $Lang::tr{'version'}: $upgradelist{$pak}{'ProgVersion'} -> $upgradelist{$pak}{'AvailableProgVersion'} -- $Lang::tr{'release'}: $upgradelist{$pak}{'Release'} -> $upgradelist{$pak}{'AvailableRelease'}</option>\n";
+ }
}
print <<END;
--
2.36.1
--
Dit bericht is gescanned op virussen en andere gevaarlijke
inhoud door MailScanner en lijkt schoon te zijn.
next prev parent reply other threads:[~2022-07-28 11:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-28 11:21 [PATCH v2 00/10] pakfire: remove dup. code + seperate ui/logic Robin Roevens
2022-07-28 11:21 ` [PATCH v2 01/10] pakfire: Refactor dblist seperating UI and logic Robin Roevens
2022-07-28 11:21 ` [PATCH v2 02/10] pakfire: Translate WUI header/footer text Robin Roevens
2022-07-28 11:21 ` [PATCH v2 03/10] pakfire: Replace duplicate code with dblist functioncall Robin Roevens
2022-07-28 11:21 ` [PATCH v2 04/10] pakfire: Replace dbgetlist duplicate code Robin Roevens
2022-07-28 11:21 ` [PATCH v2 05/10] pakfire: Optimize upgradecore function Robin Roevens
2022-07-28 11:21 ` [PATCH v2 06/10] pakfire: Add list upgrade functionality Robin Roevens
2022-07-28 11:21 ` [PATCH v2 07/10] pakfire: Refactor status seperating UI and logic Robin Roevens
2022-07-28 11:21 ` Robin Roevens [this message]
2022-07-28 11:21 ` [PATCH v2 09/10] pakfire: Add getmetadata function Robin Roevens
2022-07-28 11:21 ` [PATCH v2 10/10] pakfire: Replace getmetadata duplicate code Robin Roevens
2022-07-28 13:51 ` [PATCH v2 00/10] pakfire: remove dup. code + seperate ui/logic Peter Müller
2022-07-29 20:11 ` Robin Roevens
2022-07-28 19:43 ` Michael Tremer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220728112136.30218-9-robin.roevens@disroot.org \
--to=robin.roevens@disroot.org \
--cc=development@lists.ipfire.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox