forked from PADL/nss_ldap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vers_string
executable file
·87 lines (80 loc) · 3.06 KB
/
vers_string
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/perl
#
#ident $Id$
#
# Implementation of SGS vers_string which uses CVSVersionInfo.txt.
if (-f "./cvslib.pl") {
require "./cvslib.pl";
} else {
require "/usr/share/cvslib.pl";
}
$OUTFILE = (-f "version.h") ? "version.h" : "vers.c";
$AUTHOR = `whoami`;
$HEADER = '$Id$';
if ($ENV{'PROGRAM'}) { $PROGRAM = $ENV{'PROGRAM'}; }
chop($AUTHOR);
chop($DATE=`date -u`);
chop($CWD=`pwd`);
($PROJECT, $VERSION) = split(/\-/, &getCVSVersionInfo(), 2);
if (!defined($PROJECT)) {
$PROJECT = "Unknown";
$PROGRAM = "Unknown";
} else {
$SEP = "-";
if (!defined($PROGRAM)) {
chop($PROGRAM=`basename $CWD`);
}
}
if ($ARGV[0] eq "-f") {
print $PROJECT, $SEP, $VERSION, "\n";
} elsif ($ARGV[0] eq "-l") {
print "static const char SGS_VERS[] = \"";
print '@(#)LIBRARY:', $PROGRAM, ' PROJECT:', $PROJECT, $SEP, $VERSION, ' DEVELOPER:', $AUTHOR, ' BUILT:', $DATE;
print "\";\n";
} elsif ($ARGV[0] eq "-c") {
print "const char SGS_VERS[] = \"";
print '@(#)PROGRAM:', $PROGRAM, ' PROJECT:', $PROJECT, $SEP, $VERSION, ' DEVELOPER:', $AUTHOR, ' BUILT:', $DATE;
print "\";\n";
print "const char VERS_NUM[] = \"$VERSION\";\n";
} elsif ($ARGV[0] eq "-n") {
print "$VERSION\n";
} elsif ($ARGV[0] eq "-B") {
print 'PROGRAM:', $PROGRAM, ' PROJECT:', $PROJECT, $SEP, $VERSION, ' DEVELOPER:', $AUTHOR, ' BUILT:NO DATE SET (-B used)',"\n";
} elsif ($ARGV[0] eq "-v") {
unlink($OUTFILE);
open(OUTFILE,">$OUTFILE");
print OUTFILE "/* $OUTFILE built by $HEADER */\n";
print OUTFILE "\n";
if ($OUTFILE eq "version.h") {
print OUTFILE "#define USE_SGS_VERS\n\n";
}
print OUTFILE "const char SGS_VERS[] = \"";
print OUTFILE '@(#)PROGRAM:', $PROGRAM, ' PROJECT:', $PROJECT, $SEP, $VERSION, ' DEVELOPER:', $AUTHOR, ' BUILT:', $DATE;
print OUTFILE "\";\n\n";
print OUTFILE "const char VERS_NUM[] = \"$VERSION\";\n\n";
close(OUTFILE);
} elsif ($ARGV[0] ne "") {
print STDERR "$HEADER\n";
print STDERR "Copyright (C) 1997-2011 Luke Howard <lukeh\@padl.com>";
print STDERR "\n\n";
print STDERR "Unknown command line option $ARGV[0].\n";
print STDERR "Usage: vers_string [-f|-l|-c|-n|-B|-v]\n";
print STDERR "\t-f: echo project-n to stdout\n";
print STDERR "\t-l: echo static const char SGS_VERS to stdout\n";
print STDERR "\t-c: echo const char VERS_NUM and SGS_VERS to stdout\n";
print STDERR "\t-n: echo version number to stdout\n";
print STDERR "\t-B: emulate vers_string -B (why?)\n";
print STDERR "\t-v: generate $OUTFILE\n";
print STDERR "\tother options same as vers_string\n";
print STDERR "\n";
print STDERR "\tTo attach a project name and version number to a CVS\n";
print STDERR "\tmodule, use checkpoint\n";
print STDERR "\tTo find out the current project version, type cvsver\n";
print STDERR "\tTo create a new project, type cvsnew [project]\n";
print STDERR "\tTo sync with an existing project, type cvssync\n";
print STDERR "\tTo create a project distribution, type tarup\n";
print STDERR "\tTo commit a project, type commit [message]\n";
} else {
print 'PROGRAM:', $PROGRAM, ' PROJECT:', $PROJECT, $SEP, $VERSION, ' DEVELOPER:', $AUTHOR, ' BUILT:', $DATE;
print "\n";
}