parseRelease parses a string and creates a KernelVersion based on it.
(release string)
| 64 | |
| 65 | // parseRelease parses a string and creates a KernelVersion based on it. |
| 66 | func parseRelease(release string) (*KernelVersion, error) { |
| 67 | var version = KernelVersion{} |
| 68 | |
| 69 | // We're only make sure we get the "kernel" and "major revision". Sometimes we have |
| 70 | // 3.12.25-gentoo, but sometimes we just have 3.12-1-amd64. |
| 71 | _, err := fmt.Sscanf(release, "%d.%d", &version.Kernel, &version.Major) |
| 72 | if err != nil { |
| 73 | return nil, fmt.Errorf("failed to parse kernel version %q: %w", release, err) |
| 74 | } |
| 75 | return &version, nil |
| 76 | } |
| 77 | |
| 78 | // GreaterEqualThan checks if the host's kernel version is greater than, or |
| 79 | // equal to the given kernel version v. Only "kernel version" and "major revision" |
no outgoing calls
searching dependent graphs…