From f171c85917a20efb9c2573d5979c360743491f91 Mon Sep 17 00:00:00 2001 From: pschwan Date: Mon, 25 Nov 2002 18:58:58 +0000 Subject: [PATCH] land b_phil onto b_md. This is the last stop for b_phil, everyone please exit. --- lustre/scripts/version_tag.pl | 105 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 lustre/scripts/version_tag.pl diff --git a/lustre/scripts/version_tag.pl b/lustre/scripts/version_tag.pl new file mode 100644 index 0000000..f74ac27 --- /dev/null +++ b/lustre/scripts/version_tag.pl @@ -0,0 +1,105 @@ +#!/usr/bin/perl +$pristine=1; +if($ARGV[0]){chdir($ARGV[0]);} +get_linuxdir(); +get_tag(); +get_latest_mtime(); +generate_ver(); + +sub get_tag +{ + $tag=open(TAG,"CVS/Tag"); + if(!$tag){ + $tag="HEAD"; + } else { + $tag=; + $tag=~/.(.*)$/; + $tag=$1; + close(TAG); + } +} +sub get_latest_mtime +{ + use Time::Local; + %months=("Jan"=>1,"Feb"=>2,"Mar"=>3,"Apr"=>4,"May"=>5, + "Jun"=>6,"Jul"=>7,"Aug"=>8,"Sep"=>9,"Oct"=>10, + "Nov"=>11,"Dec"=>12); + + $last_mtime=0; + @entries=`find . -name Entries`; + foreach $entry(@entries){ + open(ENTRY,$entry); + while() { + $line=$_; + @temp_file_entry=split("/",$line); + $time_entry=$temp_file_entry[3]; + $file=$temp_file_entry[1]; + + $cur_dir=$entry; + $cur_dir=~s/\/CVS\/Entries$//g; + chomp($cur_dir); + ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, + $atime,$mtime,$ctime,$blksize,$blocks) + = stat($cur_dir."/".$file); + $local_date=gmtime($mtime); + if(! ($local_date =~ /$time_entry/) && + !($temp_file_entry[0] =~ /D/) && + !($file =~ /lustre\.spec\.in/)) { + #print "$file\n"; + $pristine=0; + } + + if($time_entry && + $file =~ m/\.c$|\.h$|\.am$|\.in$/ && + !($file =~ /lustre\.spec\.in/)){ + + @time=split(" ",$time_entry); + ($hours,$min,$sec)=split(":",$time[3]); + ($mday, $mon, $year)=($time[2],$time[1], + $time[4]); + $secs=0; + $mon=$months{$mon}; + if($mon>0 && $mon<13){ + $secs=timelocal($sec,$min,$hours,$mday, + $mon,$year); + } + if($secs>$last_mtime){ + $last_mtime=$secs; + $show_last=$hours.$min.$sec. + $year.$mon.$mday; + } + + } + } + close(ENTRY); + } +} + +sub get_linuxdir +{ + open(CONFIG,"config.status") or die "Run ./configure first \n"; + while($line=){ + $line =~ /(.*)\%\@LINUX\@\%(.*)\%g/; + if($2){$linuxdir=$2;last;} + } + close(CONFIG); + open(VER,"$linuxdir/include/linux/version.h") + or die "Run make dep on $linuxdir \n"; + while($line=){ + $line =~ /#define UTS_RELEASE "(.*)"/; + if($1){ $kernver=$1; last;} + } + chomp($kernver); + $linuxdir=~s/\//\./g; + close(VER); +} + +sub generate_ver +{ + print "#define BUILD_VERSION \""; + if($pristine){ + print "$tag-$show_last-PRISTINE-$linuxdir-$kernver\"\n"; + }else{ + print "$tag-$show_last-CHANGED-$linuxdir-$kernver\"\n"; + } +} -- 1.8.3.1