Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / gpl2 / lvm2 / dist / scripts / last_cvs_update.sh
blobe8d7426c28e5cecb48caab4e4d8f08f3fe86ff6e
1 #!/bin/sh
2 #$Header: /pub/NetBSD/misc/repositories/cvsroot/src/external/gpl2/lvm2/dist/scripts/last_cvs_update.sh,v 1.1.1.1 2008/12/22 00:18:57 haad Exp $
3 ################################################################################
4 ##
5 ## Copyright 2001 Sistina Software, Inc.
6 ##
7 ## This is free software released under the GNU General Public License.
8 ## There is no warranty for this software. See the file COPYING for
9 ## details.
11 ## See the file CONTRIBUTORS for a list of contributors.
13 ## This file is maintained by:
14 ## AJ Lewis <lewis@sistina.com>
15 ##
16 ## File name: last_cvs_update.sh
18 ## Description: displays the last file updated by CVS commands and the date
19 ## it was updated. May be given a relative or absolute path.
20 ## Based on this information, you should be able to do a
21 ## cvs co -D $date GFS and get the same version of the source
22 ## tree as this tool was run on.
23 ##
24 ## Will also give you the CVS tag the source tree is based off
25 ## off when appropriate
26 ##
27 ## Output format:
28 ## [Tag: $TAG]
29 ## The last file updated by CVS was:
30 ## $path/$file
31 ## on
32 ## $date
34 ################################################################################
36 if [[ -z $1 ]];
37 then path=.;
38 else
39 if [[ $1 == "-h" ]];
40 then echo "usage: $0 [ -h | path ]"
41 exit 0;
42 else
43 if [[ -d $1 ]]
44 then path=$1;
45 else
46 echo "usage: $0 [ -h | path ]"
47 exit 0;
52 # grab the tag from the path passed in
53 if [[ -f $path/CVS/Tag ]];
54 then echo "Tag: " `cat $path/CVS/Tag | sed -e 's/^[NT]//'`
57 awk '
58 BEGIN {
59 FS = "/"
62 # find the path for the Entries file
63 path = FILENAME
64 sub(/^\.\//, "", path)
66 # remove the CVS part of it
67 sub(/CVS\/Entries/, "", path)
69 # add the path the the filename that was modified, and put the date it was
70 # modified in as well
71 print path $2 " " $4
73 }' `find $path -name "Entries" -printf "%h/%f "` | awk '
74 # converts string name of month the a numeral
75 function cvt_month(month) {
76 if(month == "Jan")
77 return 0
78 if(month == "Feb")
79 return 1
80 if(month == "Mar")
81 return 2
82 if(month == "Apr")
83 return 3
84 if(month == "May")
85 return 4
86 if(month == "Jun")
87 return 5
88 if(month == "Jul")
89 return 6
90 if(month == "Aug")
91 return 7
92 if(month == "Sep")
93 return 8
94 if(month == "Oct")
95 return 9
96 if(month == "Nov")
97 return 10
98 if(month == "Dec")
99 return 11
100 return -1
102 BEGIN {
103 FS = " "
104 latest=""
105 maxyear = 0
106 maxdate = 0
107 maxmonth = "Jan"
108 maxtime = "00:00:00"
111 # check year first
112 if (maxyear < $6) {
113 date = $2 " " $3 " " $4 " " $5 " " $6
114 file = $1
115 maxyear = $6
116 maxmonth = $3
117 maxdate = $4
118 maxtime = $5
120 else {
121 if (maxyear == $6) {
122 # then month if year is the same
123 if (cvt_month(maxmonth) < cvt_month($3)) {
124 date = $2 " " $3 " " $4 " " $5 " " $6
125 file = $1
126 maxmonth = $3
127 maxdate = $4
128 maxtime = $5
130 else {
131 if (cvt_month(maxmonth) == cvt_month($3)) {
132 #then date if month is the same
133 if (maxdate < $4) {
134 date = $2 " " $3 " " $4 " " $5 " " $6
135 file = $1
136 maxdate = $4
137 maxtime = $5
139 else {
140 if (maxdate == $4) {
141 # then time if date is the same
142 if (maxtime < $5) {
143 date = $2 " " $3 " " $4 " " $5 " " $6
144 file = $1
145 maxtime = $5
155 END {
156 # strip leading "./" from filename
157 sub(/^\.\//, "", file)
158 print "The last file updated by CVS was:"
159 print file
160 print "on"
161 print date " GMT"