FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Cluster Development

 
 
LinkBack Thread Tools
 
Old 11-23-2007, 07:53 AM
Marian Marinov
 
Default kernel check for configure

Hello,
as I sent you yesterday my proposition for a kernel check, today I'm sending a
new simplified function of the same check:

sub kernel_version {
my $autoconf_path = shift;
my $required_version = shift;
my $build_version = 0;
my $build_patchlevel = 0;
my $build_sublevel = 0;
my $build_extraversion = 0;

# add autoconf to the path
$autoconf_path .= 'include/linux/autoconf.h';
my @version = split /./, $required_version;
my $current_version = 0;
if ( -f $autoconf_path ) {
# open the autoconf.h to feth VERSION, PATCHLEVEL and SUBLEVEL, if needed
I can add EXTRAVERSION too
open AUTOCONF, '<', $autoconf_path;
while (<AUTOCONF>) {
if ($_ =~ /CONFIG_KERNELVERSION/) {
$current_version = $_;
# we don't need to check any thing else in this file so we are
stopping the read
last;
}
}
close AUTOCONF;
# leaving only the numbers from the lines
# this is faster then split and doesn't alocate useless arrays
$current_version =~ s/.*"(.*)"
/$1/;
$current_version =~ s/.*"(.*)"
/$1/;
# parse the kernel version into the variables
if ($current_version =~ /-/) {
my @line = split /-/, $current_version;
my @ver = split /./, $line[0];
$build_version = $ver[0];
$build_patchlevel = $ver[1];
$build_sublevel = $ver[2];
$build_extraversion = $line[1];
print "Note: You are using unstable kernel version!
";
} else {
my @kernel = split /./, $current_version;
$build_version = $kernel[0];
$build_patchlevel = $kernel[1];
$build_sublevel = $kernel[2];
$build_extraversion = $kernel[3];
}
# checking VERSION, PATCHLEVEL and SUBLEVEL for the supplied kernel
# if needed I can add also EXTRAVERSION to the check
if ($build_version >= $version[0] &&
$build_patchlevel >= $version[1] &&
$build_sublevel >= $version[2]) {
print 'Current kernel version is OK',"
";
return 1;
} else {
print 'Current kernel version: ',$build_version.'.'.
$build_patchlevel.'.'.$build_sublevel,"
Minimum version: ".$version[0].'.'.
$version[1].'.'.$version[2],"
";
return 0;
}
} else {
print "Unable to find ($autoconf_path)!
";
return 0;
}
}
# the options to this function are:
# source path
# minimum kernel version
kernel_version('/usr/src/linux/','2.6.22');

Best regards,
Marian Marinov(HackMan)
 

Thread Tools




All times are GMT. The time now is 02:05 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org