2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 09:16:53 +00:00

98_Installer: fix numeric argument (Forum #98381)

git-svn-id: https://svn.fhem.de/fhem/trunk@19232 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jpawlowski 2019-04-21 11:17:26 +00:00
parent 73aa116dea
commit 1f50805a98

View File

@ -44,11 +44,6 @@ use ExtUtils::Installed;
# Run before module compilation # Run before module compilation
BEGIN { BEGIN {
# JSON preference order
$ENV{PERL_JSON_BACKEND} =
'Cpanel::JSON::XS,JSON::XS,JSON::PP,JSON::backportPP'
unless ( defined( $ENV{PERL_JSON_BACKEND} ) );
# Import from main:: # Import from main::
GP_Import( GP_Import(
qw( qw(
@ -99,6 +94,12 @@ if ($@) {
# try to use JSON wrapper # try to use JSON wrapper
# for chance of better performance # for chance of better performance
eval { eval {
# JSON preference order
local $ENV{PERL_JSON_BACKEND} =
'Cpanel::JSON::XS,JSON::XS,JSON::PP,JSON::backportPP'
unless ( defined( $ENV{PERL_JSON_BACKEND} ) );
require JSON; require JSON;
import JSON qw( decode_json encode_json ); import JSON qw( decode_json encode_json );
1; 1;
@ -357,6 +358,7 @@ sub Set($$@) {
my ( $hash, $name, @aa ) = @_; my ( $hash, $name, @aa ) = @_;
my ( $cmd, @args ) = @aa; my ( $cmd, @args ) = @aa;
my $ret;
my $updatePerlDualLifeModules = my $updatePerlDualLifeModules =
AttrVal( $name, 'updatePerlDualLifeModules', 0 ); AttrVal( $name, 'updatePerlDualLifeModules', 0 );
@ -420,12 +422,14 @@ sub Set($$@) {
unless ($update); unless ($update);
$hash->{".fhem"}{installer}{cmd} = "installPerl " . $update; $hash->{".fhem"}{installer}{cmd} = "installPerl " . $update;
$ret = "Update started in background";
} }
# installPerl # installPerl
elsif ( lc($cmd) eq 'installperl' ) { elsif ( lc($cmd) eq 'installperl' ) {
return "usage: $cmd <package>" if ( @args < 1 ); return "usage: $cmd <package>" if ( @args < 1 );
$hash->{".fhem"}{installer}{cmd} = 'installPerl ' . join( " ", @args ); $hash->{".fhem"}{installer}{cmd} = 'installPerl ' . join( " ", @args );
$ret = "Installation started in background";
} }
# uninstallPerl # uninstallPerl
@ -445,6 +449,7 @@ m/^(?:@([\w-]+)\/)?(?:App::)?(cpan\-?outdated)(?:@([\d\.=<>]+|latest))?$/i,
); );
$hash->{".fhem"}{installer}{cmd} = $hash->{".fhem"}{installer}{cmd} =
'uninstallPerl ' . join( " ", @args ); 'uninstallPerl ' . join( " ", @args );
$ret = "Deinstallation started in background";
} }
# return Usage: # return Usage:
@ -499,6 +504,7 @@ m/^(?:@([\w-]+)\/)?(?:App::)?(cpan\-?outdated)(?:@([\d\.=<>]+|latest))?$/i,
AsynchronousExecuteFhemCommand($hash); AsynchronousExecuteFhemCommand($hash);
return $ret if ($ret);
return undef; return undef;
} }
@ -854,15 +860,16 @@ sub ExecuteFhemCommand($) {
my $installer = {}; my $installer = {};
$installer->{debug} = $cmd->{debug}; $installer->{debug} = $cmd->{debug};
my $sudo = 'sudo -H -n '; my $sudo = 'sudo -n ';
my $sudoH = 'sudo -H -n ';
$installer->{cpanversions} = $installer->{cpanversions} =
'echo n | TEST=$(which cpanm) || echo "sh: command not found: cpanm"; which cpanm >/dev/null 2>&1 && sh -c "' 'echo n | TEST=$(which cpanm) || echo "sh: command not found: cpanm"; which cpanm >/dev/null 2>&1 && sh -c "'
. $sudo . $sudoH
. '$(which cpanm) --version 2>&1" 2>&1'; . '$(which cpanm) --version 2>&1" 2>&1';
$installer->{installperl} = $installer->{installperl} =
'echo n | sh -c "' 'echo n | sh -c "'
. $sudo . $sudoH
. '$(which cpanm) --quiet ' . '$(which cpanm) --quiet '
. $cmd->{installPerlReinstall} . $cmd->{installPerlReinstall}
. $cmd->{installPerlNoTest} . $cmd->{installPerlNoTest}
@ -870,12 +877,12 @@ sub ExecuteFhemCommand($) {
. '%PACKAGES%" 2>&1'; . '%PACKAGES%" 2>&1';
$installer->{uninstallperl} = $installer->{uninstallperl} =
'echo n | sh -c "' 'echo n | sh -c "'
. $sudo . $sudoH
. '$(which cpanm) -U --quiet --force %PACKAGES%" 2>&1'; . '$(which cpanm) -U --quiet --force %PACKAGES%" 2>&1';
$installer->{outdatedperl} = $installer->{outdatedperl} =
'echo n | ' 'echo n | '
. 'sh -c "' . 'sh -c "'
. $sudo . $sudoH
. '$(which cpanm) --version 2>&1" 2>&1 && ' . '$(which cpanm) --version 2>&1" 2>&1 && '
. 'L1=$(cpan-outdated --verbose 2>&1) && ' . 'L1=$(cpan-outdated --verbose 2>&1) && '
. '[ "$L1" != "" ] && [ "$L1" != "\n" ] && echo "@Outdated:\n$L1"; '; . '[ "$L1" != "" ] && [ "$L1" != "\n" ] && echo "@Outdated:\n$L1"; ';
@ -890,10 +897,10 @@ sub ExecuteFhemCommand($) {
if ( $1 =~ /App::cpanminus/i ) { if ( $1 =~ /App::cpanminus/i ) {
$installer->{installperl} = $installer->{installperl} =
'sh -c "curl -fsSL https://git.io/cpanm | ' 'sh -c "curl -fsSL https://git.io/cpanm | '
. $sudo . $sudoH
. '$(which perl) - App::cpanminus >/dev/null 2>&1" 2>&1 ' . '$(which perl) - App::cpanminus >/dev/null 2>&1" 2>&1 '
. '&& TEST=$(which cpanm) || echo "sh: command not found: cpanm"; which cpanm >/dev/null 2>&1 && sh -c "' . '&& TEST=$(which cpanm) || echo "sh: command not found: cpanm"; which cpanm >/dev/null 2>&1 && sh -c "'
. $sudo . $sudoH
. ' $(which cpanm) --quiet App::cpanoutdated" 2>&1'; . ' $(which cpanm) --quiet App::cpanoutdated" 2>&1';
} }
} }
@ -5133,7 +5140,7 @@ sub LoadInstallStatusPerl(;$) {
foreach my $t (qw(missing outdated)) { foreach my $t (qw(missing outdated)) {
if ( defined( $pkgStatus{$area}{$t} ) if ( defined( $pkgStatus{$area}{$t} )
&& ref( $pkgStatus{$area}{$t} ) eq 'HASH' && ref( $pkgStatus{$area}{$t} ) eq 'HASH'
&& %{ $pkgStatus{$area}{$t} } > 0 ) && scalar keys %{ $pkgStatus{$area}{$t} } > 0 )
{ {
foreach my $pkg ( keys %{ $pkgStatus{$area}{$t} } ) { foreach my $pkg ( keys %{ $pkgStatus{$area}{$t} } ) {
next next
@ -5499,7 +5506,7 @@ sub __list_module {
"abstract": "Modul zum Update von FHEM, zur Installation von Drittanbieter FHEM Modulen und der Verwaltung von Systemvoraussetzungen" "abstract": "Modul zum Update von FHEM, zur Installation von Drittanbieter FHEM Modulen und der Verwaltung von Systemvoraussetzungen"
} }
}, },
"version": "v0.5.1", "version": "v0.5.2",
"release_status": "testing", "release_status": "testing",
"author": [ "author": [
"Julian Pawlowski <julian.pawlowski@gmail.com>" "Julian Pawlowski <julian.pawlowski@gmail.com>"