MCPcopy
hub / github.com/google/gvisor / ValidateChecksum

Function ValidateChecksum

tools/gpu/drivers/install_driver.go:343–370  ·  view source on GitHub ↗

ValidateChecksum validates the checksum of the driver.

(ctx context.Context, version string, checksums nvproxy.Checksums)

Source from the content-addressed store, hash-verified

341
342// ValidateChecksum validates the checksum of the driver.
343func ValidateChecksum(ctx context.Context, version string, checksums nvproxy.Checksums) error {
344 for _, arch := range []string{archAMD64, archARM64} {
345 wantChecksum := checksums.X86_64
346 if arch == archARM64 {
347 wantChecksum = checksums.ARM64
348 }
349 installer, err := NewInstaller(version, false)
350 if err != nil {
351 return fmt.Errorf("failed to create installer for driver %q on arch %q: %v", version, arch, err)
352 }
353 gotChecksum, err := installer.ChecksumDriver(ctx, arch)
354 if wantChecksum == nvproxy.ChecksumNoDriver {
355 log.Infof("Runfile does not exist for driver %q arch: %q", version, arch)
356 if err == nil || !strings.Contains(err.Error(), "failed to download driver with statusCode: 404") {
357 return fmt.Errorf("checksum mismatch for driver %q on arch %q: got %q, want %q", version, arch, gotChecksum, wantChecksum)
358 }
359 return nil
360 }
361 log.Infof("Checksum for driver %q arch: %q: %q", version, arch, gotChecksum)
362 if err != nil {
363 return fmt.Errorf("failed to get checksum for driver %q on arch %q: %v", version, arch, err)
364 }
365 if gotChecksum != wantChecksum {
366 return fmt.Errorf("checksum mismatch for driver %q on arch %q: got %q, want %q", version, arch, gotChecksum, wantChecksum)
367 }
368 }
369 return nil
370}
371
372func osIsUbuntu2204() bool {
373 m, err := getOSRelease()

Callers 2

mainFunction · 0.92
TestDriverChecksumsFunction · 0.92

Calls 6

ChecksumDriverMethod · 0.95
InfofFunction · 0.92
NewInstallerFunction · 0.85
ErrorfMethod · 0.65
ContainsMethod · 0.45
ErrorMethod · 0.45

Tested by 1

TestDriverChecksumsFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…