From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 984301FF168 for ; Tue, 21 Jan 2025 11:48:11 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 57C186B31; Tue, 21 Jan 2025 11:48:08 +0100 (CET) Message-ID: Date: Tue, 21 Jan 2025 11:47:34 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta To: Proxmox VE development discussion , Hannes Duerr References: <20250121100415.64884-1-h.duerr@proxmox.com> <20250121100415.64884-4-h.duerr@proxmox.com> Content-Language: en-US From: Dominik Csapak In-Reply-To: <20250121100415.64884-4-h.duerr@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.018 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. 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 pve-nvidia-vgpu-helper v2 3/4] add pve-nvidia-vgpu-helper and Makefile to make dependency installtion more convenient 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 Cc: Thomas Lamprecht Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" looked (&tested) mostly the script itself, not at the Makefile Looks mostly OK to me, the only thing i noticed is that we only look at the current running kernel, maybe we should also check if the opt in kernel is installed? e.g. my test was: install pve + this package run 'pve-nvidia-vgpu-helper' => installs default headers install proxmox-kernel-6.11 run 'pve-nvidia-vgpu-helper' again => says "all required packages are installed' but for dkms i think it wouldn't work (and not loading the module after a reboot) It's probably not a bad idea to install the packages for all installed kernel versions? (@Thomas ?) Not super sure about how exactly DKMS works, but i think it tries to compile for all installed kernel versions no? On 1/21/25 11:04, Hannes Duerr wrote: > we add the pve-nvidia-vgpu-helper script to make the installation of the > required nvidia vgpu driver dependencies more convenient. > We also add a Makefile to assist in building the debian package and > installing the script > > Signed-off-by: Hannes Duerr > --- > Makefile | 54 ++++++++++++++++++++++++++++++++++ > pve-nvidia-vgpu-helper | 66 ++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 120 insertions(+) > create mode 100644 Makefile > create mode 100755 pve-nvidia-vgpu-helper > > diff --git a/Makefile b/Makefile > new file mode 100644 > index 0000000..c6e461d > --- /dev/null > +++ b/Makefile > @@ -0,0 +1,54 @@ > +include /usr/share/dpkg/default.mk > + > +PACKAGE=pve-nvidia-vgpu-helper > + > +BINDIR=/usr/bin/ > +DESTDIR= > + > +GITVERSION:=$(shell git rev-parse HEAD) > + > +BUILDDIR ?= $(PACKAGE)-$(DEB_VERSION) > +DSC=$(PACKAGE)_$(DEB_VERSION).dsc > + > +DEB=$(PACKAGE)_$(DEB_VERSION_UPSTREAM_REVISION)_all.deb > + > +all: > +deb: $(DEB) > + > +$(BUILDDIR): debian > + rm -rf $@ $@.tmp > + rsync -a * $@.tmp/ > + echo "git clone git://git.proxmox.com/git/pve-nvidia-vgpu-helper.git\\ngit checkout $(GITVERSION)" > $@.tmp/debian/SOURCE > + mv $@.tmp $@ > + > +$(DEB): $(BUILDDIR) > + cd $(BUILDDIR); dpkg-buildpackage -b -uc -us > + lintian $(DEB) > + > +dsc: $(DSC) > + $(MAKE) clean > + $(MAKE) $(DSC) > + lintian $(DSC) > + > +$(DSC): $(BUILDDIR) > + cd $(BUILDDIR); dpkg-buildpackage -S -uc -us > + > +sbuild: $(DSC) > + sbuild $(DSC) > + > +.PHONY: install > +install: pve-nvidia-vgpu-helper > + install -d $(DESTDIR)$(BINDIR) > + install -m 0755 pve-nvidia-vgpu-helper $(DESTDIR)$(BINDIR) > + > +.PHONY: upload > +upload: UPLOAD_DIST ?= $(DEB_DISTRIBUTION) > +upload: $(DEB) > + tar cf - $(DEB)|ssh repoman@repo.proxmox.com -- upload --product pve --dist $(UPLOAD_DIST) > + > +.PHONY: distclean > +distclean: clean > + > +.PHONY: clean > +clean: > + rm -rf *~ $(PACKAGE)-[0-9]*/ $(PACKAGE)*.tar.* *.deb *.dsc *.changes *.build *.buildinfo > diff --git a/pve-nvidia-vgpu-helper b/pve-nvidia-vgpu-helper > new file mode 100755 > index 0000000..fc0856e > --- /dev/null > +++ b/pve-nvidia-vgpu-helper > @@ -0,0 +1,66 @@ > +#!/usr/bin/perl > + > +use strict; > +use warnings; > + > +use PVE::Tools qw(run_command); > +use AptPkg::Cache; > + > +my @apt_install = qw(apt-get --no-install-recommends -o Dpkg:Options::=--force-confnew install --); > +my @dependencies = qw(dkms libc6-dev); > +my @missing_packages; > + > +die "Please execute the script with root privileges\n" if $>; > + > +my $apt_cache = AptPkg::Cache->new(); > +die "unable to initialize AptPkg::Cache\n" if !$apt_cache; > + > +sub package_is_installed { > + my ($package) = @_; > + my $p = $apt_cache->{$package}; > + if (!defined($p->{CurrentState}) || $p->{CurrentState} ne "Installed") { > + push(@missing_packages, $package); > + } > +} > + > +foreach my $dependency (@dependencies) { > + package_is_installed($dependency); > +} > + > + > +my $running_kernel; > +run_command( ['/usr/bin/uname', '-r' ], > + outfunc => sub { $running_kernel = shift } ); > + > +my $default_major_minor_version; > +run_command(['/usr/bin/dpkg-query', '-f', '${Depends}', '-W', 'proxmox-default-kernel'], > + outfunc => sub { $default_major_minor_version = shift } ); > + > +my $default_full_version; > +run_command(['/usr/bin/dpkg-query', '-f', '${Version}', '-W', $default_major_minor_version], > + outfunc => sub { $default_full_version = shift } ); > + > +if ($running_kernel =~ /$default_full_version-pve/) { > + print "You are running the proxmox default kernel `proxmox-kernel-$running_kernel`\n"; > + package_is_installed("proxmox-default-headers"); > +} elsif ($running_kernel =~ /pve/) { > + print "You are running the non default proxmox kernel `proxmox-kernel-$running_kernel`\n"; > + package_is_installed("proxmox-headers-$running_kernel"); > +} else { > + die "You are not using a proxmox-kernel, please make sure that the appropriate header package is installed.\n"; > +} > + > +if (!@missing_packages){ > + print "All required packages are installed, you can continue with the Nvidia vGPU driver installation.\n"; > + exit; > +} else { > + print "The following packages are missing:\n" . join("\n", @missing_packages) ."\n"; > + print "Would you like to install them now (y/n)?\n"; > +} > + > +my $answer = ; > +if (defined($answer) && $answer =~ m/^\s*y(?:es)?\s*$/i) { > + if (system(@apt_install, @missing_packages) != 0) { > + die "apt failed during the installation: ($?)\n"; > + } > +} _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel