Sys::Linux::KernelVersion
This is a simple module that helps look up the particular Linux kernel version number in a safe and otherwise portable way. It's intended for doing configure_requires checks and also during test suites that can't test certain features on older kernels.
get_kernel_version
Returns a hashref containing the parsed kernel version
The hashref will always contain the following keys: major, minor, revision
It may contain: subpart, subparts
The subpart key will contain anything after the revision that was included as part of the version of the kernel. There is no standard to how these must be formatted other than starting with a -. Most commonly you'll see things like -10, -generic, -amd64, or even -rc4, or a combination of all of those. Usually a bare number like -10 will mean a build number, or a distro patch number. -generic is what Ubuntu likes to use for marking what kind of kernel it is, i.e. the generic configuration, a hardware enablement kernel, or a realtime kernel. A sometimes present -amd64 would indicate that this is a kernel for an amd64 architecture. None of these subparts are actually standard across vendors and can't be depended on to be present, or in any particular order.
-
-10
-generic
-amd64
-rc4
is_linux_kernel
Just a simple check that we actually appear to be running on a linux kernel, or at least something compatible enough to call itself linux.
is_at_least_kernel_version
This takes a string as it's only parameter, to give a minimum version number.
use Sys::Linux::KernelVersion qw/is_at_least_kernel_version/; die "Too old!" unless is_at_least_kernel_version("12.56.42");
This is useful for segmenting off tests or failing a build early during module configuration if there's not at least a minimum kernel version running.
If putting this into a test for a minimum kernel version running, I'd recommend also providing a way to override the check with an Environment Variable, so that build servers don't have to be running the same kernels as development or production release machines in all environments. This would give a way for users to acknowledge that the check is incorrect/insufficient for their environments and checking that the versions in use is their responsibility.
I would not use this to choose what features should be built or not-built in the module, instead that should happen at runtime so that features match the running kernel and not the building kernel.
is_development_kernel
Check if the currently running kernel is a development series kernel.
Report any issues on the public github bugtracker.
Ryan Voots <simcop@cpan.org>
This software is Copyright (c) 2020 by Ryan Voots.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install Sys::Linux::KernelVersion, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sys::Linux::KernelVersion
CPAN shell
perl -MCPAN -e shell install Sys::Linux::KernelVersion
For more information on module installation, please visit the detailed CPAN module installation guide.