#!/usr/bin/perl
our
$VERSION
=
'1.0.1'
;
GetOptions(
'p=s'
=> \
my
$package
,
'h'
=> \
my
$help
,
'r=s'
=> \
my
@repositories
,
'v=s'
=> \
my
$version
,
'vv'
=> \
my
$verbose
,
'version'
=> \
my
$print_version
,
'list'
=> \
my
$list_available
,
'sudo'
=> \
my
$sudo
,
'force'
=> \
my
$force
,
);
unshift
@ARGV
,
$package
if
$package
;
if
(
$print_version
) {
print
OPM::Installer->VERSION();
exit
;
}
if
(
$list_available
) {
my
$installer
= OPM::Installer->new;
for
my
$addon
(
$installer
->list_available ) {
say
sprintf
"%s (%s) from\n %s\n"
,
$addon
->{name},
$addon
->{version},
$addon
->{url};
}
exit
;
}
if
(
$help
|| !
@ARGV
) {
print_usage();
exit
;
}
my
%opts
;
$opts
{repositories} = \
@repositories
if
@repositories
;
$opts
{version} =
$version
if
$version
;
my
%class_opts
;
$class_opts
{verbose} = 1
if
$verbose
;
$class_opts
{sudo} = 1
if
$sudo
;
$class_opts
{force} = 1
if
$force
;
my
$installer
= OPM::Installer->new(
%class_opts
);
for
my
$package_info
(
@ARGV
) {
my
(
$package
,
$version
) =
split
/=/,
$package_info
;
$opts
{version} =
$version
if
$version
;
$installer
->install(
package
=>
$package
,
%opts
,
);
}
sub
print_usage {
print
qq~$0 [-h] [-r <repository>] [-v <version>] [vv] <package> [<package>...]
version: exact version of otrs package to be installed
repository: repository for Znuny/OTOBO packages
help: show this screen
vv: be verbose
~
;
}