Whamcloud - gitweb
b=19927
[fs/lustre-release.git] / lustre / scripts / version_tag.pl
index 8ae53ae..84365b1 100644 (file)
@@ -144,7 +144,7 @@ sub get_latest_mtime()
 sub get_linuxdir()
 {
     my $config = new IO::File;
-    my ($line, $dir);
+    my ($line, $dir, $objdir);
     if (!$config->open("autoMakefile")) {
         die "Run ./configure first\n";
     }
@@ -152,16 +152,19 @@ sub get_linuxdir()
         chomp($line);
         if ($line =~ /LINUX :?= (.*)/) {
             $dir = $1;
+        } elsif ($line =~ /LINUX_OBJ :?= (.*)/) {
+            $objdir = $1;
             last;
         }
     }
     $config->close();
     my $ver = new IO::File;
-    if (!$ver->open("$dir/include/linux/utsrelease.h")) {
-        if (!$ver->open("$dir/include/linux/version.h")) {
+    if (!$ver->open("$objdir/include/linux/utsrelease.h") &&
+        !$ver->open("$objdir/include/linux/version.h") &&
+        !$ver->open("$dir/include/linux/utsrelease.h") &&
+        !$ver->open("$dir/include/linux/version.h")) {
             die "Run make dep on $dir\n";
         }
-    }
     while(defined($line = <$ver>)) {
         $line =~ /\#define UTS_RELEASE "(.*)"/;
         if ($1) {
@@ -197,18 +200,21 @@ sub generate_ver($$$)
 
     #print "localtime: " . localtime($mtime) . "\n";
 
-    my $show_last = mtime2date($mtime);
+    my $lustre_vers = $ENV{LUSTRE_VERS};
 
     print "#define BUILD_VERSION \"";
 
-    my $lustre_vers = $ENV{LUSTRE_VERS};
-
     if ($lustre_vers) {
         print "$tag-$lustre_vers\"\n";
+        return 0;
+    }
+
+    my $show_last = mtime2date($mtime);
+
     # if we want to get rid of the PRISTINE/CHANGED thing, get rid of these
     # lines.  maybe we only want to print -CHANGED when something is changed
     # and print nothing when it's pristine
-    } elsif ($pristine) {
+    if ($pristine) {
         print "$tag-$show_last-PRISTINE-$linuxdir-$kernver\"\n";
     } else {
         print "$tag-$show_last-CHANGED-$linuxdir-$kernver\"\n";
@@ -233,7 +239,8 @@ if ($ARGV[0]) {
     chdir($ARGV[0]);
 }
 my $tag = get_tag();
-my $mtime = get_latest_mtime();
+my $mtime = get_latest_mtime()
+    if (!defined($ENV{LUSTRE_VERS}));
 
 if ($progname eq "version_tag.pl") {
     my $linuxdir = get_linuxdir();