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-22-2007, 01:56 PM
Marian Marinov
 
Default [Cluster-devel] Addition to the configure script

Hello,

today while I was in #linux-cluster I found that the configure script doesn't
check for the kernel version.

I wrote a little function which checks the kernel version and returns 0 or 1.

Here is the code:
sub kernel_version {
* my $makefile = shift;
* my $build_version_min = shift;
* my $build_patchlevel_min = shift;
* my $build_sublevel_min = shift;
* my $build_version_max = shift;
* my $build_patchlevel_max = shift;
* my $build_sublevel_max = shift;
* # add the Makefile to the path
* $makefile .= 'Makefile';
* my $version=0;
* my $patchlevel=0;
* my $sublevel=0;
* if ( -f $makefile ) {
* * # open the Makefile to feth VERSION, PATCHLEVEL and SUBLEVEL, if needed I
can add EXTRAVERSION too
* * open MAKEFILE, '<', $makefile;
* * while (<MAKEFILE>) {
* * * if ($_ =~ /^VERSION/) {
* * * * $version = $_;
* * * }
* * * if ($_ =~ /^PATCHLEVEL/) {
* * * * $patchlevel = $_;
* * * }
* * * if ($_ =~ /^SUBLEVEL/) {
* * * * $sublevel = $_;
* * * * # we don't need to check any thing else in this file so we are
stopping the read
* * * * last;
* * * }
* * }
* * close MAKEFILE;
* * # leaving only the numbers from the lines
* * # this is faster then split and doesn't alocate useless arrays
* * $version =~ s/.*s([0-9]+)[
|
]/$1/;
* * $patchlevel =~ s/.*s([0-9]+)[
|
]/$1/;
* * $sublevel =~ s/.*s([0-9]+)[
|
]/$1/;
* * # checking VERSION, PATCHLEVEL and SUBLEVEL for a kernel
* * # if needed I can add also EXTRAVERSION to the check
* * if ($version >= $build_version_min &&
* * * * $version <= $build_version_max &&
* * * * $patchlevel >= $build_patchlevel_min &&
* * * * $patchlevel <= $build_patchlevel_max &&
* * * * $sublevel >= $build_sublevel_min &&
* * * * $sublevel <= $build_sublevel_max) {
* * * print 'Current kernel version is OK',"
";
* * * return 1;
* * } else {
* * * print 'Current kernel version: ',$version.'.'.$patchlevel.'.'.
$sublevel,"
Minimum version: ".$build_version_min.'.'.
$build_patchlevel_min.'.'.$build_sublevel_min,"
Maximum version: ".
$build_version_max.'.'.$build_patchlevel_max.'.'.$ build_sublevel_max,"
";
* * * return 0;
* * }
* } else {
* * print "Unable to find kernel Makefile!
";
* * return 0;
* }
}
# the options to this function are:
# * source path
# * minimum kernel version
# * minimum kernel patchlevel
# * minimum kernel sublevel
# * maximum kernel version
# * maximum kernel patchlevel
# * maximum kernel sublevel
kernel_version('/usr/src/linux/',2,6,24,2,6,25);

The function can be used to check the makefile from $kernel_build or
$kernel_src.

I hope that this will be useful to you guys.

Best regards
* Marian Marinov
 

Thread Tools




All times are GMT. The time now is 09:11 AM.

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