From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 23A151FF176 for ; Fri, 24 Jan 2025 15:41:48 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6CA122CEE9; Fri, 24 Jan 2025 15:41:30 +0100 (CET) From: Hannes Duerr To: pve-devel@lists.proxmox.com Date: Fri, 24 Jan 2025 15:41:20 +0100 Message-Id: <20250124144121.215130-6-h.duerr@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250124144121.215130-1-h.duerr@proxmox.com> References: <20250124144121.215130-1-h.duerr@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.033 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 T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH pve-nvidia-vgpu-helper v3 5/5] script: install headers for running and newer kernel version only X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" also add the new dependency for `libdpkg-perl` Signed-off-by: Hannes Duerr --- debian/control | 1 + pve-nvidia-vgpu-helper | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/debian/control b/debian/control index 4492b60..352e63a 100644 --- a/debian/control +++ b/debian/control @@ -9,6 +9,7 @@ Homepage: https://www.proxmox.com Package: pve-nvidia-vgpu-helper Architecture: all Depends: libapt-pkg-perl, + libdpkg-perl, ${misc:Depends}, Description: Proxmox Nvidia vGPU helper script and systemd service This package provides a script, that helps with installing all required diff --git a/pve-nvidia-vgpu-helper b/pve-nvidia-vgpu-helper index 885b879..4c57578 100755 --- a/pve-nvidia-vgpu-helper +++ b/pve-nvidia-vgpu-helper @@ -5,6 +5,7 @@ use warnings; use PVE::Tools qw(run_command); use AptPkg::Cache; +use Dpkg::Version; my @apt_install = qw(apt-get --no-install-recommends install --); my @dependencies = qw(dkms libc6-dev proxmox-default-headers); @@ -23,6 +24,16 @@ sub package_is_installed { } } +sub install_newer_headers { + my ($running_version, @installed_versions) = @_; + for my $version (@installed_versions) { + # install header for the running kernel and newer kernel versions + if (Dpkg::Version::version_compare($running_version, $version) != 1){ + package_is_installed("proxmox-headers-$version-pve"); + } + } +} + foreach my $dependency (@dependencies) { package_is_installed($dependency); } @@ -32,17 +43,18 @@ my $running_kernel; run_command( ['/usr/bin/uname', '-r' ], outfunc => sub { $running_kernel = shift } ); +my @installed_versions; run_command(['/usr/bin/dpkg-query', '-W', 'proxmox-kernel-*-pve'], outfunc => sub { my $installed_kernel = shift; - $installed_kernel =~ s/^\s*proxmox-kernel(-\d+.\d+.\d+-\d+-pve)\s*$/proxmox-headers$1/; - package_is_installed($installed_kernel); + $installed_kernel =~ m/^\s*proxmox-kernel-(\d+.\d+.\d+-\d+)-pve\s*$/; + push(@installed_versions, $1); }); - -if ($running_kernel =~ m/^\d+\.\d+\.\d+-\d+-pve$/) { +if ($running_kernel =~ m/^(\d+\.\d+\.\d+-\d+)-pve$/) { print "You are running the proxmox kernel `proxmox-kernel-$running_kernel`\n"; + install_newer_headers($1, @installed_versions); } else { die "You are not using a proxmox-kernel, please make sure that the appropriate header package is installed.\n"; } -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel