2 # -*- Mode: perl; indent-tabs-mode: nil; cperl-indent-level: 4 -*-
16 my $tagfile = new IO::File;
17 if (!$tagfile->open("CVS/Tag")) {
28 sub get_latest_mtime()
30 my %months=("Jan" => 0, "Feb" => 1, "Mar" => 2, "Apr" => 3, "May" => 4,
31 "Jun" => 5, "Jul" => 6, "Aug" => 7, "Sep" => 8, "Oct" => 9,
32 "Nov" => 10, "Dec" => 11);
35 my @entries = `find . -name Entries`;
37 foreach $entry_file (@entries) {
39 my $entry = new IO::File;
40 if (!$entry->open($entry_file)) {
41 die "unable to open $entry_file: $!\n";
44 while (defined($line = <$entry>)) {
46 #print "line: $line\n";
47 my ($junk, $file, $version, $date) = split(/\//, $line);
49 #print "junk: $junk\nfile: $file\nver: $version\ndate: $date\n";
50 #print "last_mtime: " . localtime($last_mtime) . "\n";
53 $file eq "lustre.spec.in" ||
54 $file !~ m/\.(c|h|am|in)$/) {
58 my $cur_dir = $entry_file;
59 $cur_dir =~ s/\/CVS\/Entries$//;
60 my @statbuf = stat("$cur_dir/$file");
61 my $mtime = $statbuf[9];
62 my $local_date = gmtime($mtime);
63 if ($local_date ne $date &&
64 $file ne "lustre.spec.in") {
65 #print "$file : " . localtime($mtime) . "\n";
69 if ($mtime > $last_mtime) {
74 my @t = split(/ +/, $date);
76 #print "skipping: $date\n";
79 my ($hours, $min, $sec) = split(/:/, $t[3]);
80 my ($mon, $mday, $year) = ($t[1], $t[2], $t[4]);
83 $secs = timelocal($sec, $min, $hours, $mday, $mon, $year);
84 if ($secs > $last_mtime) {
96 my $config = new IO::File;
98 if (!$config->open("Makefile")) {
99 die "Run ./configure first\n";
101 while (defined($line = <$config>)) {
103 if ($line =~ /LINUX = (.*)/) {
109 my $ver = new IO::File;
110 if (!$ver->open("$dir/include/linux/version.h")) {
111 die "Run make dep on $dir\n";
113 while(defined($line = <$ver>)) {
114 $line =~ /\#define UTS_RELEASE "(.*)"/;
126 sub generate_ver($$$)
130 my $linuxdir = shift;
132 #print "localtime: " . localtime($mtime) . "\n";
134 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
138 my $show_last = sprintf("%04d%02d%02d%02d%02d%02d", $year, $mon, $mday,
141 print "#define BUILD_VERSION \"";
143 print "$tag-$show_last-PRISTINE-$linuxdir-$kernver\"\n";
145 print "$tag-$show_last-CHANGED-$linuxdir-$kernver\"\n";
152 my $linuxdir = get_linuxdir();
154 my $mtime = get_latest_mtime();
155 generate_ver($tag, $mtime, $linuxdir);