/usr/share/perl5/DebianLinux.pm is in linux-base 4.0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | # Copyright 2011 Ben Hutchings
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
package DebianLinux;
use strict;
use warnings;
use POSIX qw(uname);
BEGIN {
use Exporter ();
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(version_cmp image_list);
}
sub version_split {
# Split into numbers and non-numeric strings, but break the non-
# numeric strings at hyphens
my $version = shift;
return $version =~ /(?:\d+|-?[^-\d]*)/g;
}
sub version_cmp {
my ($left_ver, $right_ver) = @_;
my @left_comp = version_split($left_ver);
my @right_comp = version_split($right_ver);
for (my $i = 0; ; $i++) {
my $left = $left_comp[$i];
my $right = $right_comp[$i];
# Do the components indicate pre-releases?
my $left_pre = defined($left) && $left =~ /^-(?:rc|trunk)$/;
my $right_pre = defined($right) && $right =~ /^-(?:rc|trunk)$/;
# Are the components numeric?
my $left_num = defined($left) && $left =~ /^\d+/;
my $right_num = defined($right) && $right =~ /^\d+/;
# Pre-releases sort before anything, even end-of-string
if ($left_pre or $right_pre) {
return -1 if !$right_pre;
return 1 if !$left_pre;
}
# End-of-string sorts before anything else.
# End-of-string on both sides means equality.
if (!defined($left) or !defined($right)) {
return -1 if defined($right);
return defined($left) || 0;
}
# Use numeric comparison if both sides numeric.
# Otherwise use ASCII comparison.
if ($left_num && $right_num) {
return -1 if $left < $right;
return 1 if $left > $right;
} else {
# Note that '.' > '-' thus 2.6.x.y > 2.6.x-z for any y, z.
return -1 if $left lt $right;
return 1 if $left gt $right;
}
}
}
# Find kernel image name stem for this architecture
my $image_stem;
if ((uname())[4] =~ /^(?:mips|parisc|powerpc|ppc)/) {
$image_stem = 'vmlinux';
} else {
$image_stem = 'vmlinuz';
}
sub image_list {
my @results;
my $prefix = "/boot/$image_stem-";
for (glob("$prefix*")) {
push @results, [substr($_, length($prefix)), $_];
}
return @results;
}
1;
|