all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH manager] pveversion: show upgradable package version in verbose output
@ 2024-04-18  7:44 Alexander Zeidler
  2024-04-18  8:31 ` Stefan Sterz
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Zeidler @ 2024-04-18  7:44 UTC (permalink / raw)
  To: pve-devel

when the state is "Installed", including not correctly installed, but
not for (residual) "ConfigFiles".

The information
* can be inaccurate for offline nodes or when using POM.
* is included in pveversion so it can also be used on public channels
  like the forum. The current System Report includes pveversion -v

 # pveversion -v
 proxmox-ve: 8.1.0 (running kernel: 6.5.13-5-pve)
 pve-manager: 8.1.6 (running version: 8.1.6/b7e8e914a1db70cc) [available: 8.1.10]
 ...
 vncterm: 1.8.0
 zfsutils-linux: 2.2.3-pve1 [available: 2.2.3-pve2]

Signed-off-by: Alexander Zeidler <a.zeidler@proxmox.com>
---
 bin/pveversion | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/bin/pveversion b/bin/pveversion
index 591f63e7..b98e1096 100755
--- a/bin/pveversion
+++ b/bin/pveversion
@@ -21,19 +21,29 @@ sub print_status {
 	print "$pkg: unknown package - internal error\n";
 	return;
     }
+
+    my $installed = $pkginfo->{CurrentState} eq 'Installed';
+    my $upgradable = $pkginfo->{OldVersion} && ($pkginfo->{OldVersion} ne $pkginfo->{Version});
+
     my $version = "not correctly installed";
-    if ($pkginfo->{OldVersion} && $pkginfo->{CurrentState} eq 'Installed') {
+    if ($installed && $pkginfo->{OldVersion}) {
 	$version = $pkginfo->{OldVersion};
     } elsif ($pkginfo->{CurrentState} eq 'ConfigFiles') {
 	$version = 'residual config';
     }
 
     if ($pkginfo->{RunningKernel}) {
-	print "$pkg: $version (running kernel: $pkginfo->{RunningKernel})\n";
+	print "$pkg: $version (running kernel: $pkginfo->{RunningKernel})";
     } elsif ($pkginfo->{ManagerVersion}) {
-	print "$pkg: $version (running version: $pkginfo->{ManagerVersion})\n";
+	print "$pkg: $version (running version: $pkginfo->{ManagerVersion})";
+    } else {
+	print "$pkg: $version";
+    }
+
+    if ($installed && $upgradable) {
+	print " [available: " . $pkginfo->{Version} . "]\n";
     } else {
-	print "$pkg: $version\n";
+	print "\n";
     }
 }
 
@@ -50,7 +60,7 @@ my $opt_verbose;
 if (!GetOptions ('verbose' => \$opt_verbose)) {
     print_usage ();
     exit (-1);
-} 
+}
 
 if (scalar (@ARGV) != 0) {
     print_usage ();
@@ -76,7 +86,7 @@ __END__
 
 =head1 NAME
 
-pveversion - Proxmox  VE version info
+pveversion - Proxmox VE version info
 
 =head1 SYNOPSIS
 
-- 
2.39.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [pve-devel] [PATCH manager] pveversion: show upgradable package version in verbose output
  2024-04-18  7:44 [pve-devel] [PATCH manager] pveversion: show upgradable package version in verbose output Alexander Zeidler
@ 2024-04-18  8:31 ` Stefan Sterz
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Sterz @ 2024-04-18  8:31 UTC (permalink / raw)
  To: Proxmox VE development discussion

On Thu Apr 18, 2024 at 9:44 AM CEST, Alexander Zeidler wrote:
> when the state is "Installed", including not correctly installed, but
> not for (residual) "ConfigFiles".
>
> The information
> * can be inaccurate for offline nodes or when using POM.
> * is included in pveversion so it can also be used on public channels
>   like the forum. The current System Report includes pveversion -v
>
>  # pveversion -v
>  proxmox-ve: 8.1.0 (running kernel: 6.5.13-5-pve)
>  pve-manager: 8.1.6 (running version: 8.1.6/b7e8e914a1db70cc) [available: 8.1.10]
>  ...
>  vncterm: 1.8.0
>  zfsutils-linux: 2.2.3-pve1 [available: 2.2.3-pve2]
>
> Signed-off-by: Alexander Zeidler <a.zeidler@proxmox.com>
> ---
>  bin/pveversion | 22 ++++++++++++++++------
>  1 file changed, 16 insertions(+), 6 deletions(-)
>
> diff --git a/bin/pveversion b/bin/pveversion
> index 591f63e7..b98e1096 100755
> --- a/bin/pveversion
> +++ b/bin/pveversion
> @@ -21,19 +21,29 @@ sub print_status {
>  	print "$pkg: unknown package - internal error\n";
>  	return;
>      }
> +
> +    my $installed = $pkginfo->{CurrentState} eq 'Installed';
> +    my $upgradable = $pkginfo->{OldVersion} && ($pkginfo->{OldVersion} ne $pkginfo->{Version});
> +
>      my $version = "not correctly installed";
> -    if ($pkginfo->{OldVersion} && $pkginfo->{CurrentState} eq 'Installed') {
> +    if ($installed && $pkginfo->{OldVersion}) {
>  	$version = $pkginfo->{OldVersion};
>      } elsif ($pkginfo->{CurrentState} eq 'ConfigFiles') {
>  	$version = 'residual config';
>      }
>
>      if ($pkginfo->{RunningKernel}) {
> -	print "$pkg: $version (running kernel: $pkginfo->{RunningKernel})\n";
> +	print "$pkg: $version (running kernel: $pkginfo->{RunningKernel})";
>      } elsif ($pkginfo->{ManagerVersion}) {
> -	print "$pkg: $version (running version: $pkginfo->{ManagerVersion})\n";
> +	print "$pkg: $version (running version: $pkginfo->{ManagerVersion})";
> +    } else {
> +	print "$pkg: $version";
> +    }
> +
> +    if ($installed && $upgradable) {
> +	print " [available: " . $pkginfo->{Version} . "]\n";

nit: i think we generally prefer string interpolation over
concatenation, as in the code above. so simply:

print " [available: $pkginfo->{Version} ]\n";

should work.

>      } else {
> -	print "$pkg: $version\n";
> +	print "\n";
>      }
>  }
>

the changes below just remove superfluous whitespace, this might be
better handled separatelly as these changes have nothing to do with the
functionality added above.

> @@ -50,7 +60,7 @@ my $opt_verbose;
>  if (!GetOptions ('verbose' => \$opt_verbose)) {
>      print_usage ();
>      exit (-1);
> -}
> +}
>
>  if (scalar (@ARGV) != 0) {
>      print_usage ();
> @@ -76,7 +86,7 @@ __END__
>
>  =head1 NAME
>
> -pveversion - Proxmox  VE version info
> +pveversion - Proxmox VE version info
>
>  =head1 SYNOPSIS
>



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-18  8:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-18  7:44 [pve-devel] [PATCH manager] pveversion: show upgradable package version in verbose output Alexander Zeidler
2024-04-18  8:31 ` Stefan Sterz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal