Page Menu
Home
ClusterLabs Projects
Search
Configure Global Search
Log In
Files
F3154465
linuxver
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
linuxver
View Options
#!/usr/bin/perl
###############################################################################
###############################################################################
##
## Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
## Copyright (C) 2004 Red Hat, Inc. All rights reserved.
##
## This copyrighted material is made available to anyone wishing to use,
## modify, copy, or redistribute it subject to the terms and conditions
## of the GNU General Public License v.2.
##
###############################################################################
###############################################################################
## Description: outputs the version of linux in the src directory specified
## to stdout
use Getopt::Std;
getopt('d');
$linux_src = $opt_d;
$majorver = $opt_b;
$noextra = $opt_s;
# help message
if(defined($opt_h)) {
$msg = "usage: $0 [OPTIONS]\n";
$msg = $msg . "\t-b\tBrief format (MAJOR_MINOR)\n";
$msg = $msg . "\t-s\tsimple format (MAJOR.MINOR.RELEASE)\n";
$msg = $msg . "\t-d\tLinux src directory (Default: /usr/src/linux)\n";
$msg = $msg . "\t-h\tDisplay this help message\n";
$msg = $msg . "\t-v\tVerbose format (${MAJOR}.${MINOR}.${RELEASE}${EXTRAVERSION}) - Default\n";
die $msg;
}
# if there was an argument to linuxver, use it as the linux source directory
if ($linux_src) {
$file = $linux_src . '/include/linux/version.h';
}
# otherwise, use the default
else {
$file = '/usr/src/linux/include/linux/version.h';
}
open(DATAFILE, "< $file") || die "$0: can't open $file\n";
while ($line = <DATAFILE>)
{
if ($majorver) {
if ($line =~ /UTS_RELEASE.+"(\d+\.\d+)\.\d+/)
{
$version = $1;
$version =~ tr/\./_/;
}
}
else {
if ($noextra) {
if ($line =~ /UTS_RELEASE.+"(\d+\.\d+\.\d+)/)
{
$version = $1;
}
}
else {
if ($line =~ /UTS_RELEASE.+"(\d+\.\d+\.[\+\_\-\.\d\w]+)/)
{
$version = $1;
}
}
}
}
close(DATAFILE);
die "linuxver can't determine Linux version\n" unless (defined($version));
print "$version\n";
File Metadata
Details
Attached
Mime Type
text/x-perl
Expires
Wed, Feb 26, 1:47 PM (18 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1459027
Default Alt Text
linuxver (2 KB)
Attached To
Mode
rF Fence Agents
Attached
Detach File
Event Timeline
Log In to Comment