eg/custom-setup/lib/My/GPU/Setup.pm

filter: Statementstmt 100% 15 / 15 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 2 / 2 totaltotal 100% 23 / 23 CC 2 SCAR 3.4
CC
2
Cov
100%
prepare_source
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« eg/custom-setup/lib/My/GPU/DebianMirror.pm ↑ Summary
1 package My::GPU::Setup;
2 # Example custom NVIDIA driver setup for Rex::GPU (experimental Setup API).
3 #
4 # Lives in the project's lib/ next to the Rexfile: Rex puts that directory on
5 # @INC, so `set gpu_nvidia_setup => 'My::GPU::Setup'` or
6 # `gpu_setup(setup => 'My::GPU::Setup')` finds it without touching Rex::GPU.
7 #
8 # Ubuntu hosts only -- it extends the Ubuntu setup. Two changes:
9 # 1. a pinned source ahead of the built-in ones: the open 580 LTS driver;
10 # 2. an optional extra apt line (a local mirror) before `apt-get update`.
11 # Everything else -- the dpkg lock timeout, the apt-timer stop, the direct
12 # apt-get install and the dpkg -l verification -- is inherited.
13 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 extends 'Rex::GPU::NVIDIA::Setup::Ubuntu';
17  
18 # e.g. 'deb [signed-by=/usr/share/keyrings/internal.gpg] http://apt.internal.example/ubuntu noble main restricted'
19 1 has apt_line => ( is => 'ro', predicate => 1 );
20  
21 # Tried first. The GPUs' requirement still decides: a Turing-to-Blackwell GPU
22 # takes it, a V100 (proprietary only) or a GPU that needs a newer branch
23 # rejects it and falls through to the built-in sources below.
24 2 ▶sub sources {
Subroutine sources: called CC=1 SCAR=0.0
Pod documented
25 2 my ( $self ) = @_;
26 return (
27 {
28 2 name => 'pinned-580-open',
29 kernel_module => 'open',
30 branch => 580,
31 packages => [ 'nvidia-driver-580-server-open' ],
32 verify => [ 'nvidia-driver-580-server-open' ],
33 check_candidate => 'nvidia-driver-580-server-open'
34 },
35 $self->SUPER::sources
36 );
37 }
38  
39 # The mirror goes in before the inherited step runs `apt-get update`; the
40 # candidate check of check_candidate above runs after it (resolve_source).
41 2 ▶sub prepare_source {
Subroutine prepare_source: called CC=2 SCAR=6.9
Pod documented
42 2 my ( $self, $plan ) = @_;
43 2 ▶ if ($self->has_apt_line) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_apt_line) 1 1 2
44 1 $self->file_cmd('/etc/apt/sources.list.d/internal-nvidia.list',
45 content => $self->apt_line."\n");
46 }
47 2 $self->SUPER::prepare_source($plan);
48 }
49  
50 1 1;
« eg/custom-setup/lib/My/GPU/DebianMirror.pm ↑ Summary