From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9])
	by lore.proxmox.com (Postfix) with ESMTPS id B8D101FF37F
	for <inbox@lore.proxmox.com>; Thu, 18 Apr 2024 10:31:54 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 8B0B3170E2;
	Thu, 18 Apr 2024 10:31:53 +0200 (CEST)
Mime-Version: 1.0
Date: Thu, 18 Apr 2024 10:31:36 +0200
Message-Id: <D0N3X87GYURP.2SDDMB4MME1WI@proxmox.com>
From: "Stefan Sterz" <s.sterz@proxmox.com>
To: "Proxmox VE development discussion" <pve-devel@lists.proxmox.com>
X-Mailer: aerc 0.17.0-69-g65571b67d7d3-dirty
References: <20240418074406.22025-4-a.zeidler@proxmox.com>
In-Reply-To: <20240418074406.22025-4-a.zeidler@proxmox.com>
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.070 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: Re: [pve-devel] [PATCH manager] pveversion: show upgradable package
 version in verbose output
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

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