ValidateChecksum validates the checksum of the driver.
(ctx context.Context, version string, checksums nvproxy.Checksums)
| 341 | |
| 342 | // ValidateChecksum validates the checksum of the driver. |
| 343 | func 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 | |
| 372 | func osIsUbuntu2204() bool { |
| 373 | m, err := getOSRelease() |
searching dependent graphs…