Inca::Reporter::Version - Convenience module for creating version reporters
use Inca::Reporter::Version; my $reporter = new Inca::Reporter::Version(); my $command = 'somecommand -version'; my $pattern = '^version "(.*)"'; ... $reporter->setPackageName('packageX'); $reporter->setVersionByExecutable($command, $pattern); $reporter->print();
or
$reporter->setVersionByGptQuery('packageX');
or
$reporter->setVersionByRpmQuery('packageX');
or
$reporter->setPackageVersion('x.x.x');
or
foreach my $subpackage(@subpackages) { $reporter->setSubpackageVersion($subpackage, $version); }
This module is a subclass of Inca::Reporter which provides convenience methods for creating version reporters. A version reporter reports the version information for a package in the following schema (i.e., this is the body of the Inca report):
<packageVersion> <ID>packageX</ID> <version>x.x.x</version> </packageVersion>
or
<packageVersion> <ID>packageX</ID> <subpackage> <ID>subpackageX</ID> <version>x.x.x</version> </subpackage> <subpackage> <ID>subpackageY</ID> <version>x.x.x</version> </subpackage> </packageVersion>
Version information can be set using one of the basic methods setPackageVersion (for the first example) or setSubpackageVersion (for the second). In this case, the user retrieves a package's version information directly and uses one of these two methods to report it. This module also provides convenience methods that retrieve a package version using conventional methods of querying version information.
Class constructor which returns a new Inca::Reporter::Version object. The constructor supports the following parameters in addition to those supported by Inca::Reporter.
the name of the package for which a version is being determined; default ''.
the version of the package.
Returns the name of the package
Returns the version of the package
Returns an array of all the names of all subpackages with a set version
Returns the version of subpackage $name
Constructs and returns the body of the reporter.
Set the name of the package.
Report the version of a package as $version.
Report the version of subpackage $name as $version.
Retrieve the package version by compiling and running a program and matching its output against a pattern. Returns 1 if successful, else 0. The function recognizes the following parameter in addition to those supported by the compiledProgramOutput method of Inca::Reporter:
pattern to search for in program output; default '(.+)'
Retrieve package version information by executing $command and greping the output for $pattern. $command is the executable and argument string to retrieve the version (e.g., command_name -version) and $pattern is a pattern containing one grouping (i.e., memory parentheses) to retrieve the version from the output. $pattern defaults to '([\d\.]+)' if not specified. Fails if $timeout is specified and $command does not complete within $timeout seconds. Returns 1 if successful, else 0.
Retrieve the package version by grep'ing the file $path for $pattern. $pattern defaults to '([\d\.]+)' if not specified. Returns 1 if successful, else 0.
Set subpackage version information by querying GPT for packages prefixed with any element of @prefixes. Returns 1 if successful, else 0.
Set subpackage version information by querying GPT for packages that contain the regular expression $pattern. Returns 1 if successful, else 0.
The following example demonstrates the usage of setVersionByGptQuery:
my $reporter = new Inca::Reporter::Version( name => 'grid.middleware.globus.version', version => 1.25, description => 'Reports globus package versions', url => 'http://www.globus.org', package_name => 'globus' ); $reporter->processArgv(@ARGV); $reporter->setVersionByGptQuery('globus'); $reporter->print();
The following example demonstrates the usage of setVersionByRpmQuery:
my $reporter = new Inca::Reporter::Version( name => 'cluster.compiler.gcc.version', version => 1.25, description => 'Reports the version of gcc', url => 'http://gcc.gnu.org', package_name => 'gcc' ); $reporter->processArgv(@ARGV); $reporter->setVersionByRpmQuery('gcc'); $reporter->print();
The following example demonstrates the usage of setVersionByExecutable:
my $command = "java -version"; my $pattern = '^java version \"(.*)\"[.\n]*'; my $reporter = new Inca::Reporter::Version( name => 'cluster.java.sun.version', version => 1.25, description => 'Reports the version of java in the user\'s path', url => 'http://java.sun.com', package_name => 'java' ); $reporter->processArgv(@ARGV); $reporter->setVersionByExecutable($command, $pattern); $reporter->print();
Shava Smallen <ssmallen@sdsc.edu>