Codebase list libnss-ldap / HEAD cvslib.pl
HEAD

Tree @HEAD (Download .tar.gz)

cvslib.pl @HEADraw · history · blame

#ident $Id: cvslib.pl,v 2.1 2009/11/06 10:26:22 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";
}