8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / sgs / packages / common / readme_revision
blob7cde955a9d36ae8ccdcccc5ff03433620097677f
1 #!/usr/bin/perl -w
3 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
4 # Use is subject to license terms.
6 # CDDL HEADER START
8 # The contents of this file are subject to the terms of the
9 # Common Development and Distribution License (the "License").
10 # You may not use this file except in compliance with the License.
12 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
13 # or http://www.opensolaris.org/os/licensing.
14 # See the License for the specific language governing permissions
15 # and limitations under the License.
17 # When distributing Covered Code, include this CDDL HEADER in each
18 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
19 # If applicable, add the following below this CDDL HEADER, with the
20 # fields enclosed by brackets "[]" replaced with your own identifying
21 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # CDDL HEADER END
25 #pragma ident "%Z%%M% %I% %E% SMI"
29 # Generate a revision number for the sgs linker components, based
30 # on usr/src/cmd/sgs/packages/common/SUNWonld-README.
32 # usage: readme_revision [-d] [readme-file]
34 # This revision number used to be the SCCS revision id for that file,
35 # in the form 1.xxx (where xxx was the revision). There were two benefits:
37 # (1) You could examine the sccs revision log to determine the CR
38 # of the putback that created the revision.
39 # (2) The revisions were monotonically increasing.
41 # In order to remove the hard wired dependence on sccs, this script generates
42 # a replacement revision number, by returning the string '1.xxx', where
43 # xxx is an integer giving the number of unique CR lines found in the file.
44 # This means that the revision goes up by one for each CR we fix, which
45 # makes intutive sense, and is similar to the way the SCCS revision worked.
47 # If this is a debug/development build (-d option), then we include
48 # additional information at the end of the revision:
50 # - Workspace name
51 # - user
52 # - CR # of last item in the readme file
53 # - date,
55 # This extra information is useful when we need to identify SUNWonld
56 # linker packages in the field, and provides the information previously
57 # supplied by (1) above.
60 use vars qw($script $usage $readme $cnt);
61 use vars qw($debug $last_cr $wsname $date);
63 # Use the basename of the name we're invoked under as the script name
64 @_ = split /\//, $0;
65 $script = $_[$#_];
66 $usage = "usage: $script [-d] [readme-file]\n";
68 $debug = 0;
69 # Process the options
70 while ((scalar(@ARGV) > 0) && ($_ = $ARGV[0],/^-/)) {
71 ARG: {
72 if (/^-d$/) {
73 $debug = 1;
74 last ARG;
78 # If it gets here, the option is unknown.
79 die $usage;
81 shift;
84 # Plain argument
85 $cnt = scalar @ARGV;
87 if ($cnt == 0) {
88 $readme = 'SUNWonld-README';
89 next;
92 if ($cnt == 1) {
93 $readme = $ARGV[0];
94 next;
97 die $usage;
101 open(FILE, $readme) || die "$script: Unable to open $readme\n";
103 # At the date this script was put into service, the SCCS revision
104 # of SUNWonld-README was 1.627, and SUNWonld-README had 588 unique
105 # CRs. Revisions are supposed to always increase monotonically, so
106 # we add 1000 to the number of unique CRs.
108 # This means that any linker with a version <1000 was built using
109 # the SCCS revision, and any linker with version >=1000 was built
110 # with this script.
111 $cnt = 1000;
113 while ($_ = <FILE>) {
114 chomp $_;
116 # If the line starts with a number, it is taken as a CR.
117 if ($_ =~ /^(\d+)\s/) {
118 $cnt++;
119 $last_cr = $1;
122 close FILE;
124 # If this is a standard build, the revision # is all we want
125 if ($debug == 0) {
126 print "1.$cnt\n";
127 exit 0;
130 # For debug mode, add diagnostic data
132 ($wsname = $ENV{'CODEMGR_WS'}) ne '' || ($wsname = 'unknown');
133 @wsname = split /\//, $wsname;
134 $wsname = $wsname[$#wsname];
136 $date = `date +%m/%d/%y`;
138 print "1.$cnt:$wsname-$ENV{USER}-$last_cr-$date\n";
140 exit 0;