| 1 | # ABSTRACT: NVIDIA driver setup for openSUSE Leap (experimental) | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | package Rex::GPU::NVIDIA::Setup::SUSE; | ||||||||||||||||||||
| 4 | 36 | our $VERSION = '0.005'; | |||||||||||||||||||
| 5 | 36 | ▶ | use Moo; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 36 | ▶ | use Rex::Logger (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 36 | ▶ | use namespace::autoclean; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 36 | extends 'Rex::GPU::NVIDIA::Setup::Rpm'; | |||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 59 | ▶ | sub package_manager { 'zypper' } | ||||||||||||||||||
|
Subroutine
package_manager: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 340 | ▶ | sub zypper_lock_timeout { 120 } | ||||||||||||||||||
|
Subroutine
zypper_lock_timeout: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 341 | ▶ | sub zypper { | ||||||||||||||||||
|
Subroutine
zypper: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 18 | 341 | my ( $self ) = @_; | |||||||||||||||||||
| 19 | 341 | return 'ZYPP_LOCK_TIMEOUT='.$self->zypper_lock_timeout.' zypper'; | |||||||||||||||||||
| 20 | } | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 59 | ▶ | sub package_manager_command { | ||||||||||||||||||
|
Subroutine
package_manager_command: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 23 | 59 | my ( $self ) = @_; | |||||||||||||||||||
| 24 | 59 | return $self->zypper; | |||||||||||||||||||
| 25 | } | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 86 | ▶ | sub leap_version { | ||||||||||||||||||
|
Subroutine
leap_version: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||
| 29 | 86 | my ( $self ) = @_; | |||||||||||||||||||
| 30 | 86 | my $release = $self->release; | |||||||||||||||||||
| 31 | 86 | ▶ | return '16.0' if $self->_major_version($release) >= 16; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 32 | 41 | ▶ | my ($leap_version) = ($release // '') =~ /^(\d+\.\d+)/; | ||||||||||||||||||
|
Condition50%1/2
$release // ""
MC/DC0%0/1
$release // ""
$release
Truth table50%1/2
A
A= $release
| |||||||||||||||||||||
| 33 | 41 | ▶ | return $leap_version // $release; | ||||||||||||||||||
|
Condition33%1/3
$leap_version // $release
MC/DC0%0/2
$leap_version // $release
$leap_version
$release
Truth table33%1/3
A // B
A= $leap_versionB= $release
| |||||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 87 | ▶ | sub repo_url { | ||||||||||||||||||
|
Subroutine
repo_url: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 37 | 87 | my ( $self, $leap_version ) = @_; | |||||||||||||||||||
| 38 | 87 | return "https://download.nvidia.com/opensuse/leap/$leap_version/"; | |||||||||||||||||||
| 39 | } | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | # G06 is NVIDIA's series up to 580, G07 the open-only one after it. Checked | ||||||||||||||||||||
| 42 | # 2026-09-23 in the repos' primary.xml: the G06 metas (open on leap/15.6, | ||||||||||||||||||||
| 43 | # proprietary on 15.6 and 16.0) carry branches 570 and 580 only, zypper | ||||||||||||||||||||
| 44 | # resolves the newest, so they install 580 -- branch 580 exactly; 590 never | ||||||||||||||||||||
| 45 | # went into G06. The G07 open meta on leap/16.0 carries 594 and 595, newer | ||||||||||||||||||||
| 46 | # branches land there: branch_at_least 595. NVIDIA's leap/15.6/ and leap/16.0/ repos | ||||||||||||||||||||
| 47 | # both carry nvidia-driver-G06-kmp-meta (x86_64 + aarch64, up to 580.178.04, | ||||||||||||||||||||
| 48 | # checked in their primary.xml 2026-09-23); it requires | ||||||||||||||||||||
| 49 | # nvidia-driver-G06-kmp and nvidia-userspace-meta-G06 at its own exact | ||||||||||||||||||||
| 50 | # version. The open G06/G07 metas do not support pre-Turing GPUs. | ||||||||||||||||||||
| 51 | # | ||||||||||||||||||||
| 52 | # Verification (karr #27), from the same primary.xml (x86_64, 2026-09-23): | ||||||||||||||||||||
| 53 | # every meta requires the capability "<kmp> = <its version>" plus | ||||||||||||||||||||
| 54 | # nvidia-userspace-meta-G0x. nvidia-driver-G06-kmp is provided by | ||||||||||||||||||||
| 55 | # nvidia-driver-G06-kmp-default / -64kb (NVIDIA's repo); the | ||||||||||||||||||||
| 56 | # nvidia-open-driver-G0x-signed-kmp capability by no package in NVIDIA's | ||||||||||||||||||||
| 57 | # repo -- the signed kmp comes from openSUSE's own repositories. rpm -q of | ||||||||||||||||||||
| 58 | # the meta alone would trust that libzypp, which commits package by package | ||||||||||||||||||||
| 59 | # and resolves dependencies itself, never leaves a meta without its kmp; the | ||||||||||||||||||||
| 60 | # capability query checks it, flavour-independent. | ||||||||||||||||||||
| 61 | 86 | ▶ | sub sources { | ||||||||||||||||||
|
Subroutine
sources: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 62 | 86 | my ( $self ) = @_; | |||||||||||||||||||
| 63 | 86 | my $url = $self->repo_url($self->leap_version); | |||||||||||||||||||
| 64 | 86 | ▶ | my $open = $self->_major_version($self->release) >= 16 | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 65 | ? { name => 'nvidia-gfx-G07-open', branch_at_least => 595, | ||||||||||||||||||||
| 66 | packages => [ 'nvidia-open-driver-G07-signed-kmp-meta' ], | ||||||||||||||||||||
| 67 | verify => [ 'nvidia-open-driver-G07-signed-kmp-meta', 'nvidia-open-driver-G07-signed-kmp' ] } | ||||||||||||||||||||
| 68 | : { name => 'nvidia-gfx-G06-open', branch => 580, | ||||||||||||||||||||
| 69 | packages => [ 'nvidia-open-driver-G06-signed-kmp-meta' ], | ||||||||||||||||||||
| 70 | verify => [ 'nvidia-open-driver-G06-signed-kmp-meta', 'nvidia-open-driver-G06-signed-kmp' ] }; | ||||||||||||||||||||
| 71 | return ( | ||||||||||||||||||||
| 72 | 86 | { %$open, kernel_module => 'open', repo_url => $url }, | |||||||||||||||||||
| 73 | { | ||||||||||||||||||||
| 74 | name => 'nvidia-gfx-G06', | ||||||||||||||||||||
| 75 | kernel_module => 'proprietary', | ||||||||||||||||||||
| 76 | branch => 580, | ||||||||||||||||||||
| 77 | packages => [ 'nvidia-driver-G06-kmp-meta' ], | ||||||||||||||||||||
| 78 | verify => [ 'nvidia-driver-G06-kmp-meta', 'nvidia-driver-G06-kmp' ], | ||||||||||||||||||||
| 79 | repo_url => $url | ||||||||||||||||||||
| 80 | } | ||||||||||||||||||||
| 81 | ); | ||||||||||||||||||||
| 82 | } | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | 115 | ▶ | sub verify_query { | ||||||||||||||||||
|
Subroutine
verify_query: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 85 | 115 | my ( $self, $what ) = @_; | |||||||||||||||||||
| 86 | 115 | return 'rpm -q --whatprovides '.$what; | |||||||||||||||||||
| 87 | } | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | 96 | ▶ | sub plan { | ||||||||||||||||||
|
Subroutine
plan: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||
| 90 | 96 | my ( $self ) = @_; | |||||||||||||||||||
| 91 | 96 | my $plan = $self->SUPER::plan; | |||||||||||||||||||
| 92 | 76 | ▶ | $plan->{repo_url} = $plan->{source} && $plan->{source}{repo_url}; | ||||||||||||||||||
|
Condition33%1/3
$plan->{'source'} && $plan->{'source'}{'repo_url'}
MC/DC0%0/2
$plan->{'source'} && $plan->{'source'}{'repo_url'}
$plan->{'source'}
$plan->{'source'}{'repo_url'}
Truth table33%1/3
A && B
A= $plan->{'source'}B= $plan->{'source'}{'repo_url'}
| |||||||||||||||||||||
| 93 | 76 | return $plan; | |||||||||||||||||||
| 94 | } | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | 64 | ▶ | sub prepare_host { | ||||||||||||||||||
|
Subroutine
prepare_host: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 98 | 64 | my ( $self, $plan ) = @_; | |||||||||||||||||||
| 99 | 64 | Rex::Logger::info(' Removing any existing NVIDIA packages...'); | |||||||||||||||||||
| 100 | 64 | $self->run_cmd(q{rpm -e $(rpm -qa | grep -E '^(nvidia|libnvidia)' | grep -v 'container') 2>/dev/null || true}, | |||||||||||||||||||
| 101 | auto_die => 0); | ||||||||||||||||||||
| 102 | } | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | 64 | ▶ | sub prepare_source { | ||||||||||||||||||
|
Subroutine
prepare_source: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 106 | 64 | my ( $self, $plan ) = @_; | |||||||||||||||||||
| 107 | 64 | Rex::Logger::info(' Adding NVIDIA GFX repo (Leap '.$self->release.'): '.$plan->{repo_url}); | |||||||||||||||||||
| 108 | 64 | $self->add_repo('nvidia-gfx', $plan->{repo_url}); | |||||||||||||||||||
| 109 | } | ||||||||||||||||||||
| 110 | |||||||||||||||||||||
| 111 | |||||||||||||||||||||
| 112 | 72 | ▶ | sub add_repo { | ||||||||||||||||||
|
Subroutine
add_repo: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||
| 113 | 72 | my ( $self, $alias, $url ) = @_; | |||||||||||||||||||
| 114 | # karr #52: both exit codes used to be ignored. rr first keeps re-runs from | ||||||||||||||||||||
| 115 | # tripping over addrepo's "already exists" (exit 4). | ||||||||||||||||||||
| 116 | 72 | $self->run_cmd($self->zypper.' rr '.$alias.' 2>/dev/null || true', auto_die => 0); | |||||||||||||||||||
| 117 | 72 | my $out = $self->run_cmd($self->zypper.' addrepo --refresh '.$url.' '.$alias.' 2>&1', auto_die => 0); | |||||||||||||||||||
| 118 | 72 | ▶ | $self->_die_zypper_repo('addrepo', $alias, $url, $out) if $? != 0; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 119 | 68 | $out = $self->run_cmd($self->zypper.' --gpg-auto-import-keys refresh '.$alias.' 2>&1', auto_die => 0); | |||||||||||||||||||
| 120 | 68 | ▶ | return if $? == 0; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 121 | 4 | my $exit = $?; | |||||||||||||||||||
| 122 | 4 | $self->run_cmd($self->zypper.' rr '.$alias.' 2>/dev/null || true', auto_die => 0); | |||||||||||||||||||
| 123 | 4 | $? = $exit; | |||||||||||||||||||
| 124 | 4 | $self->_die_zypper_repo('refresh', $alias, $url, $out); | |||||||||||||||||||
| 125 | } | ||||||||||||||||||||
| 126 | |||||||||||||||||||||
| 127 | 8 | ▶ | sub _die_zypper_repo { | ||||||||||||||||||
|
Subroutine
_die_zypper_repo: called CC=4 SCAR=13.9
| |||||||||||||||||||||
| 128 | 8 | my ( $self, $step, $alias, $url, $out ) = @_; | |||||||||||||||||||
| 129 | 8 | my $exit = $? >> 8; | |||||||||||||||||||
| 130 | 8 | ▶ | $out //= ''; | ||||||||||||||||||
|
Condition50%1/2
$out //= ""
MC/DC0%0/1
$out //= ""
$out
Truth table50%1/2
A
A= $out
| |||||||||||||||||||||
| 131 | 8 | $out =~ s/\s+\z//; | |||||||||||||||||||
| 132 | 8 | ▶ | die 'zypper '.$step.' of repository '.$alias.' ('.$url.') failed (exit '.$exit.')' | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 133 | .(length $out ? ': '.$out : '') | ||||||||||||||||||||
| 134 | .($step eq 'refresh' ? '; the repository was removed again' : '') | ||||||||||||||||||||
| 135 | ."; nothing was installed from it\n"; | ||||||||||||||||||||
| 136 | } | ||||||||||||||||||||
| 137 | |||||||||||||||||||||
| 138 | |||||||||||||||||||||
| 139 | 57 | ▶ | sub install_packages { | ||||||||||||||||||
|
Subroutine
install_packages: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 140 | 57 | my ( $self, $plan ) = @_; | |||||||||||||||||||
| 141 | 57 | $self->SUPER::install_packages($plan); | |||||||||||||||||||
| 142 | 57 | $self->run_cmd($self->zypper.' addlock libnvidia-ml libnvidia-cfg 2>/dev/null || true', auto_die => 0); | |||||||||||||||||||
| 143 | } | ||||||||||||||||||||
| 144 | |||||||||||||||||||||
| 145 | 36 | 1; | |||||||||||||||||||
| 146 | |||||||||||||||||||||
| 147 | __END__ | ||||||||||||||||||||