summaryrefslogtreecommitdiff
path: root/cvslib.pl
diff options
context:
space:
mode:
Diffstat (limited to 'cvslib.pl')
-rw-r--r--cvslib.pl77
1 files changed, 77 insertions, 0 deletions
diff --git a/cvslib.pl b/cvslib.pl
new file mode 100644
index 0000000..e809ea1
--- /dev/null
+++ b/cvslib.pl
@@ -0,0 +1,77 @@
+#ident $Id: cvslib.pl,v 1.1 2009/11/06 10:27:49 lukeh Exp $
+
+$CVSVERSIONDIR = $ENV{'CVSVERSIONDIR'};
+
+$INFOFILE = $CVSVERSIONDIR ne "" ? $CVSVERSIONDIR."/CVSVersionInfo.txt" : "CVSVersionInfo.txt";
+
+$DISTDIR = $ENV{'HOME'} . "/dist";
+
+sub getSGSFile
+{
+ if (-f "version.h") { return "version.h"; }
+ elsif (-f "vers.c") { return "vers.c"; }
+ else { return; }
+}
+
+sub nameToTag
+{
+ local($tag) = shift;
+ $tag =~ s/\./\~/g;
+ return ($tag);
+}
+
+sub getCVSRepository
+{
+ if (!(-d "CVS"))
+ {
+ return;
+ }
+
+ open(ROOT, "CVS/Root") || return;
+ open(REPOSITORY, "CVS/Repository") || return;
+ local ($CVSROOT) = <ROOT>;
+ chop ($CVSROOT);
+ if ($CVSROOT =~ '^:') {
+ local(@C) = split(/:/, $CVSROOT);
+ $CVSROOT = $C[3];
+ }
+ local ($CVSREPOSITORY) = <REPOSITORY>;
+ chop ($CVSREPOSITORY);
+ close(ROOT);
+ close(REPOSITORY);
+
+ if ($CVSREPOSITORY =~ /^\//)
+ {
+ $CVSREPOSITORY =~ s/^$CVSROOT\///g;
+ }
+ return($CVSREPOSITORY);
+}
+
+sub getCVSVersionInfo
+{
+ local ($VERSION, $PROJECT);
+
+ if (-f $INFOFILE)
+ {
+ open(INFOFILE, $INFOFILE) || return;
+ while(<INFOFILE>)
+ {
+ if (/^#/) { next; }
+
+ local ($key, $value) = split(/:\s+/);
+ chop($value);
+
+ if ($key eq "ProjectVersion")
+ {
+ $VERSION = $value;
+ }
+ elsif ($key eq "ProjectName")
+ {
+ $PROJECT = $value;
+ }
+ }
+ }
+ close(INFOFILE);
+ return "$PROJECT-$VERSION";
+}
+