pakfire: Refactor dblist seperating UI and logic

- Removed UI code from dblist function and refactor it making it return
  a hash representing the pak db for easier handling of this data.
- Moved core update check in dblist to new seperate dbcoreinfo function
  making it return a hash with current and possibly available core
  version info.
- Update existing calls to dblist
- Bring UI parts previously in dblist to pakfire program itself,
  pakfire.cgi and index.cgi with a few small enhancements:
  - Translations for 'Core-Update', 'Release', 'Update' and 'Version'
  - Add currently installed version numbers to installed paks list in
    pakfire.cgi
  - Add 'Installed: yes/no' to pakfire list output so people not using
    colors have this information too. (Partly fixes Bug #12868)
  - Add update available details to pakfire list output if package has
    updates available.

Signed-off-by: Robin Roevens <robin.roevens@disroot.org>
This commit is contained in:
Robin Roevens
2022-07-28 13:21:27 +02:00
committed by Peter Müller
parent f201005f46
commit 0bd5b13195
8 changed files with 206 additions and 111 deletions

View File

@@ -403,7 +403,16 @@ print <<END;
<select name="UPDPAKS" class="pflist" size="5" disabled>
END
&Pakfire::dblist("upgrade", "forweb");
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";
}
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;
</select>
<input type='hidden' name='ACTION' value='upgrade' />
@@ -419,7 +428,11 @@ END
<select name="INSPAKS" class="pflist" size="10" multiple>
END
&Pakfire::dblist("notinstalled", "forweb");
my %notinstalledlist = &Pakfire::dblist("notinstalled");
foreach my $pak (sort keys %notinstalledlist) {
print "<option value=\"$pak\">$pak-$notinstalledlist{$pak}{'ProgVersion'}-$notinstalledlist{$pak}{'Release'}</option>\n";
}
print <<END;
</select>
<input type='hidden' name='ACTION' value='install' />
@@ -431,7 +444,11 @@ END
<select name="DELPAKS" class="pflist" size="10" multiple>
END
&Pakfire::dblist("installed", "forweb");
my %installedlist = &Pakfire::dblist("installed");
foreach my $pak (sort keys %installedlist) {
print "<option value=\"$pak\">$pak-$installedlist{$pak}{'ProgVersion'}-$installedlist{$pak}{'Release'}</option>\n";
}
print <<END;
</select>
<input type='hidden' name='ACTION' value='remove' />