Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / scripts / version_tag.pl
index 0433366..31978cf 100644 (file)
@@ -154,6 +154,10 @@ sub get_linuxdir()
             $dir = $1;
         } elsif ($line =~ /LINUX_OBJ :?= (.*)/) {
             $objdir = $1;
+        } elsif ($line =~ /MODULES_TRUE :?= (.*)/) {
+            # nothing to do if modules are not being built
+            return ""
+                if ($1 eq "#");
             last;
         }
     }
@@ -165,6 +169,7 @@ sub get_linuxdir()
         !$ver->open("$dir/include/linux/version.h")) {
             die "Run make dep on $dir\n";
         }
+
     while(defined($line = <$ver>)) {
         $line =~ /\#define UTS_RELEASE "(.*)"/;
         if ($1) {
@@ -198,23 +203,33 @@ sub generate_ver($$$)
     my $mtime = shift;
     my $linuxdir = shift;
 
-    #print "localtime: " . localtime($mtime) . "\n";
+    # assume building without modules
+    my $postfix = "";
 
-    my $show_last = mtime2date($mtime);
+    if ($linuxdir ne "") {
+        $postfix = "-$kernver";
+    }
 
-    print "#define BUILD_VERSION \"";
+    #print "localtime: " . localtime($mtime) . "\n";
 
     my $lustre_vers = $ENV{LUSTRE_VERS};
 
+    print "#define BUILD_VERSION \"";
+
     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) {
-        print "$tag-$show_last-PRISTINE-$linuxdir-$kernver\"\n";
+    if ($pristine) {
+        print "$tag-$show_last-PRISTINE$postfix\"\n";
     } else {
-        print "$tag-$show_last-CHANGED-$linuxdir-$kernver\"\n";
+        print "$tag-$show_last-CHANGED$postfix\"\n";
     }
 }
 
@@ -236,7 +251,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();