ePages 6.17.40 - DE_EPAGES/Core/API/Program/Base.pm

Package DE_EPAGES::Core::API::Program::Base

Common OS-independend interface for 3rd party programs. Sub classes must implement the abstract methods command and version.

Example
use MyProgram; # sub class of DE_EPAGES::Core::API::Program::Base
$Program = MyProgram->new;
say "MyProgram is installed" if $Program->isInstalled;
say "Version=".$Program->version;
system $MyProgram->command, '-v';

Functions

command
installCmd
isInstalled
isUpToDate
new
postInstall
preInstall
resource
update
version
winpkg

command

Returns the executable command. The result may or may not contain the full path name and extension. Note: the command may contain spaces - therefore use quotes where required. The method does not verify if the executable actually exists, has execute permissions or is included in the search path. Examples:

Syntax
$Command = $Program->command;
Example
SystemCommand( [ $Program->command, '-e', 'print "1+2"' ] );
$Output = SystemCommand( '"'.$Program->command.'" -v', { Capture => 1 } );
Return
$Command (string)
executable command

installCmd

Returns the install command for program

Syntax
my $Cmd = $Program->installCmd;
Return
$Cmd (string)
install command for program

isInstalled

checks if $Program is installed

Syntax
$IsInstalled = $Program->isInstalled;
Return
$IsInstalled (string)
installed version if installed, else 0

isUpToDate

checks if $Program is up-to-date (not installed -> not up-to-date)

Syntax
$Program->update unless $Program->isUpToDate;
Return
$IsUpToDate (string)
current version if up-to-date, else 0

new

Creates a new program object.

Syntax
$Program = SubClass->new;
Example
$Node = DE_EPAGES::Core::API::Program::nodejs->new;
Return
$Program (DE_EPAGES::Core::API::Program::Base)
program object

postInstall

runs code to be executed before installing/updating $Program

Syntax
$Program->postInstall

preInstall

runs code to be executed before installing/updating $Program

Syntax
$Program->preInstall

resource

Returns available URL and version of the product on the download site. If envvar EPAGES_REPO is set, prefer that URL (space-separated URL or absolute path).

Syntax
($DownloadUrl, $DownloadVersion) = @{$Program->resource};
Return
$DownloadUrl (string)
download URL
$DownloadVersion (string)
download version

update

updates/installs $Program unless up-to-date

Syntax
$Update = $Program->update;
Return
$Update (boolean)
true if was updated, else false

version

Returns the current version number executable command, typically in the format "0.0.0". Throws an error if the program is not installed or is not executable by the current user. Possible error codes are: CommandError|CommandFailed|NoVersionFound.

Syntax
$Version = $Program->version;
Example
say "Version=".$Program->version;
Return
$Version (string)
version number

winpkg

Returns the current package name including suffix (e.g. .zip or .msi).

Syntax
$Package = $Program->winpkg;
Return
$Package (string)
package name