<<

NAME

Inca::Reporter::Version - Convenience module for creating version reporters

SYNOPSIS

  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);
  }

DESCRIPTION

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 METHODS

new

Class constructor which returns a new Inca::Reporter::Version object. The constructor supports the following parameters in addition to those supported by Inca::Reporter.

package_name

the name of the package for which a version is being determined; default ''.

package_version

the version of the package.

getPackageName

Returns the name of the package

getPackageVersion

Returns the version of the package

getSubpackageNames

Returns an array of all the names of all subpackages with a set version

getSubpackageVersion($name)

Returns the version of subpackage $name

reportBody

Constructs and returns the body of the reporter.

setPackageName($packageName)

Set the name of the package.

setPackageVersion($version)

Report the version of a package as $version.

setSubpackageVersion($name, $version)

Report the version of subpackage $name as $version.

setVersionByCompiledProgramOutput(%attrs)

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: parameters:

pattern

pattern to search for in program output; default '(.+)'

setVersionByExecutable($command, $pattern, $timeout)

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.

setVersionByFileContents($path, $pattern)

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.

setVersionByGptQuery(@prefixes)

Set subpackage version information by querying GPT for packages prefixed with any element of @prefixes. Returns 1 if successful, else 0.

setVersionByRpmQuery($pattern)

Set subpackage version information by querying GPT for packages that contain the regular expression $pattern. Returns 1 if successful, else 0.

EXAMPLES

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();

AUTHOR

Shava Smallen <ssmallen@sdsc.edu>

SEE ALSO

Inca::Reporter

<<