-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebian-version
More file actions
executable file
·65 lines (54 loc) · 977 Bytes
/
debian-version
File metadata and controls
executable file
·65 lines (54 loc) · 977 Bytes
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
#!/usr/bin/env perl
use IO::File;
use strict;
use warnings;
my $versionFile = '/etc/debian_version';
my %rxMap = (
1.1 => 'Buzz',
1.2 => 'Rex',
1.3 => 'Bo',
2.0 => 'Hamm',
2.1 => 'Slink',
2.2 => 'Potato',
3.0 => 'Woody',
3.1 => 'Sarge',
4.0 => 'Etch',
5.0 => 'Lenny',
6.0 => 'Squeeze',
7 => 'Wheezy',
8 => 'Jessie',
9 => 'Stretch',
10 => 'Buster',
11 => 'Bullseye',
12 => 'Bookworm',
13 => 'Trixie',
);
sub ver {
my ($file) = @_;
my $actualVersion = '';
my $fh = IO::File->new($file, 'r');
if (defined($fh)) {
$actualVersion = <$fh>;
chomp($actualVersion);
} else {
return 'error';
}
if ($actualVersion) {
while (my ($ver, $codename) = each(%rxMap)) {
my $rx = qr/^$ver/;
if ($actualVersion =~ $rx) {
return $codename;
}
}
}
return 'unknown';
}
sub main {
my $codename = ver($versionFile);
printf("%s\n", $codename);
if ($codename eq 'unknown' || $codename eq 'error') {
return 1;
}
return 0;
}
exit(main());