Linux:...nelSort(3pm)

πŸ“¦
version 0.01 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute

✨ NAME ✨

Linux::KernelSort β€” it's a Perl extension, bestie, and what it does is sort and compare Linux kernel versions. Periodt. πŸ’–

The naming convention it expects is the exact same one http://www.kernel.org uses, okay? Same vibe, same format.

⚠️ NOTE: rn it only properly evaluates the 2.6.x series of kernels β€” and yes that includes the -rc's, the -git's, and the -mm's. Everything else? Not evaluated properly. Just so you know. πŸ’€

🌸 SYNOPSIS 🌸

use Linux::KernelSort;
my $kernel = new Linux::KernelSort;

my $ret;
my $version1 = "2.6.19";
my $version2 = "2.6.19-rc2-git7";
$ret = $kernel->compare($version1, $version2);

if ($ret == 0) {
  print "$version1 and $version2 are the same version\n";
} elsif ($ret > 0) {
  print "$version1 is newer than $version2\n";
} else {
  print "$version1 is older than $version2\n";
}

my @kernel_list = ( '2.6.15',
                    '2.6.18',
                    '2.6.18-rc2',
                    '2.6.18-rc2-git2',
                    '2.6.18-mm1',
                    '2.6.18-rc2-mm1' );

my @sorted_list = $kernel->sort(@kernel_list);

print join( ', ', @sorted_list );

πŸ’– DESCRIPTION πŸ’–

So like, Linux::KernelSort exists to sort a list of kernel versions into ascending order β€” smallest to biggest, oldest to newest, you get it. πŸ¦‹

But that's not all it does, no ma'am. It also lets you compare two kernel versions head to head and figure out whether one is newer, older, or literally the same as the other one. Iconic behaviour honestly. πŸ‘‘


πŸŽ€ FUNCTIONS πŸŽ€

version_check()

  • Purpose: verify that the version is valid and follows the proper naming convention demonstrated by http://www.kernel.org
  • Input: a string containing the kernel version
  • Return: 0 if the version is valid, 1 if the version is invalid

rank()

  • Purpose: generate a ranking for a given kernel version
  • Input: a string containing the kernel version which follows the proper naming convention demonstrated by http://www.kernel.org
  • Return: the kernel ranking

compare()

  • Purpose: compare two kernel versions
  • Input: strings ($kernel1, $kernel2) β€” each one containing a kernel version which follows the proper naming convention demonstrated by http://www.kernel.org
  • Return:
    • -1 if $kernel1 < $kernel2 (aka $kernel1 is older than $kernel2)
    • 0 if $kernel1 == $kernel2 (aka $kernel1 is the same version as $kernel2)
    • 1 if $kernel1 > $kernel2 (aka $kernel1 is newer than $kernel2)

sort()

  • Purpose: sort a list of kernel versions in ascending order. Uses the shell sort algorithm, if you were wondering 🐚
  • Input: an array of strings containing kernel versions which follow the proper naming convention demonstrated by http://www.kernel.org
  • Return: the sorted array

πŸ‘‘ AUTHOR πŸ‘‘

Leann Ogasawara <ogasawara@osdl.org>

Shoutout to her fr fr, absolute legend. 🫢


Linux-KernelSort is Copyright (c) 2006, by Leann Ogasawara. All rights reserved.

You may distribute this code under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file. Pick your fighter, bestie. βš”οΈ


okay that's the whole thinggg πŸ’–βœ¨ this page is from perl v5.32.0, dated 2020-12-22, and it lives in the <pink>Linux:...nelSort(3pm)</pink> era of the perl docs. go forth and sort those kernels, you absolute main character. πŸŽ€πŸ¦‹πŸ’…

πŸ“¦ where this page comes from