[pmg-devel] [PATCH api 1/2] pmgversion: sort packages
Thomas Lamprecht
t.lamprecht at proxmox.com
Tue Mar 19 08:04:07 CET 2019
Similar adaptions as PVE got, initally list the most important
packages, pmg-api and pmg-gui, then the kernels sorted by real
version order, then the rest of intresting packages in alphabetical
order.
Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
PMG/API2/APT.pm | 37 ++++++++++++++++++++++++-------------
1 file changed, 24 insertions(+), 13 deletions(-)
diff --git a/PMG/API2/APT.pm b/PMG/API2/APT.pm
index 7c894a4..300f734 100644
--- a/PMG/API2/APT.pm
+++ b/PMG/API2/APT.pm
@@ -498,27 +498,38 @@ __PACKAGE__->register_method({
my $policy = $cache->policy;
my $pkgrecords = $cache->packages();
- # try to use a resonable ordering (most important things first)
- my @list = qw(proxmox-mailgateway pmg-api pmg-gui proxmox-spamassassin proxmox-widget-toolkit);
+ # order most important things first
+ my @list = qw(proxmox-mailgateway pmg-api pmg-gui);
- foreach my $pkgname (keys %$cache) {
- if ($pkgname =~ m/pve-kernel-/) {
- my $p = $cache->{$pkgname};
- push @list, $pkgname if $p && $p->{CurrentState} eq 'Installed';
- }
- }
+ my $aptver = $AptPkg::System::_system->versioning();
+ my $byver = sub { $aptver->compare($cache->{$b}->{CurrentVer}->{VerStr}, $cache->{$a}->{CurrentVer}->{VerStr}) };
+ push @list, sort $byver grep { /^pve-kernel-/ && $cache->{$_}->{CurrentState} eq 'Installed' } keys %$cache;
+ my @opt_pack = qw(
+ libpve-apiclient-perl
+ zfsutils-linux
+ );
- my @opt_pack = ('zfsutils-linux', 'libpve-apiclient-perl');
+ my @pkgs = qw(
+ libarchive-perl
+ libpve-common-perl
+ libpve-http-server-perl
+ libxdgmime-perl
+ lvm2
+ pmg-docs
+ proxmox-spamassassin
+ proxmox-widget-toolkit
+ pve-firmware
+ pve-xtermjs
+ vncterm
+ );
- push @list, qw(libpve-http-server-perl lvm2 pve-firmware libpve-common-perl vncterm pmg-docs pve-xtermjs libarchive-perl libxdgmime-perl );
-
- @list = (@list, @opt_pack);
- my $pkglist = [];
+ push @list, (sort @pkgs, @opt_pack);
my (undef, undef, $kernel_release) = POSIX::uname();
my $pmgver = PMG::pmgcfg::version_text();
+ my $pkglist = [];
foreach my $pkgname (@list) {
my $p = $cache->{$pkgname};
my $info = $pkgrecords->lookup($pkgname);
--
2.20.1
More information about the pmg-devel
mailing list