components/perl_modules/cssh/patches/001-no-exception.patch
author Rich Burridge <rich.burridge@oracle.com>
Tue, 18 Apr 2017 16:00:10 -0700
changeset 7906 57070a2dbc4f
parent 1720 d8e7a59298b8
permissions -rw-r--r--
PSARC 2017/052 cssh version 4.09 25766514 Update the Perl cssh module to version 4.09

#
# Patch out the use of Exception::Class and Try::Tiny since they aren't
# currently available on Solaris.  Once we add them, this patch can be removed.
#

--- App-ClusterSSH-4.09/lib/App/ClusterSSH/Base.pm.orig	2017-03-22 10:15:41.590929247 +0000
+++ App-ClusterSSH-4.09/lib/App/ClusterSSH/Base.pm	2017-03-22 10:24:02.509863095 +0000
@@ -5,17 +5,6 @@
 use Carp;
 use App::ClusterSSH::L10N;
 
-use Exception::Class (
-    'App::ClusterSSH::Exception',
-    'App::ClusterSSH::Exception::Config' => {
-        fields => 'unknown_config',
-    },
-    'App::ClusterSSH::Exception::Cluster',
-    'App::ClusterSSH::Exception::LoadFile',
-    'App::ClusterSSH::Exception::Helper',
-    'App::ClusterSSH::Exception::Getopt',
-);
-
 # Don't use SVN revision as it can cause problems
 use version;
 our $VERSION = version->new('0.02');
@@ -94,9 +83,7 @@
     my ( $self, $level ) = @_;
     if ( !defined $level ) {
         croak(
-            App::ClusterSSH::Exception->throw(
-                error => _translate('Debug level not provided')
-            )
+            _translate('Debug level not provided')
         );
     }
     if ( $level > 9 ) {
@@ -136,9 +123,7 @@
 
     if ( !$app_configuration ) {
         croak(
-            App::ClusterSSH::Exception->throw(
-                _translate('config has not yet been set')
-            )
+            _translate('config has not yet been set')
         );
     }
 
@@ -150,17 +135,13 @@
 
     if ($app_configuration) {
         croak(
-            App::ClusterSSH::Exception->throw(
                 _translate('config has already been set')
-            )
         );
     }
 
     if ( !$config ) {
         croak(
-            App::ClusterSSH::Exception->throw(
                 _translate('passed config is empty')
-            )
         );
     }
 
@@ -176,17 +157,13 @@
 
     if ( !$args{filename} ) {
         croak(
-            App::ClusterSSH::Exception->throw(
-                error => '"filename" arg not passed'
-            )
+                '"filename" arg not passed'
         );
     }
 
     if ( !$args{type} ) {
         croak(
-            App::ClusterSSH::Exception->throw(
-                error => '"type" arg not passed'
-            )
+                '"type" arg not passed'
         );
     }
 
@@ -194,12 +171,10 @@
 
     if ( !-e $args{filename} ) {
         croak(
-            App::ClusterSSH::Exception::LoadFile->throw(
-                error => $self->loc(
+                $self->loc(
                     'Unable to read file [_1]: [_2]' . $/, $args{filename},
                     $!
                 ),
-            ),
         );
     }
 
@@ -207,20 +182,16 @@
         = $args{type} eq 'config'  ? qr/\s*(\S+)\s*=\s*(.*)/
         : $args{type} eq 'cluster' ? qr/\s*(\S+)\s+(.*)/
         : croak(
-        App::ClusterSSH::Exception::LoadFile->throw(
-            error => 'Unknown arg type: ',
+            'Unknown arg type: ',
             $args{type}
-        )
         );
 
     open( my $fh, '<', $args{filename} )
         or croak(
-        App::ClusterSSH::Exception::LoadFile->throw(
-            error => $self->loc(
+            $self->loc(
                 "Unable to read file [_1]: [_2]",
                 $args{filename}, $!
             )
-        ),
         );
 
     my %results;
@@ -257,9 +228,7 @@
 
     close($fh)
         or croak(
-        App::ClusterSSH::Exception::LoadFile->throw(
-            error => "Could not close $args{filename} after reading: $!"
-        ),
+            "Could not close $args{filename} after reading: $!"
         );
 
     return %results;
--- App-ClusterSSH-4.09/lib/App/ClusterSSH/Cluster.pm.orig	2017-03-22 10:24:35.452015893 +0000
+++ App-ClusterSSH-4.09/lib/App/ClusterSSH/Cluster.pm	2017-03-22 10:26:02.835966591 +0000
@@ -7,7 +7,6 @@
 our $VERSION = version->new('0.01');
 
 use Carp;
-use Try::Tiny;
 use English qw( -no_match_vars );
 
 use base qw/ App::ClusterSSH::Base /;
@@ -100,13 +99,11 @@
 
     if ( $return_code != 0 ) {
         croak(
-            App::ClusterSSH::Exception::Cluster->throw(
-                error => $self->loc(
+                $self->loc(
                     "External command failure.\nCommand: [_1]\nReturn Code: [_2]",
                     $command,
                     $return_code,
                 ),
-            )
         );
     }
 
--- App-ClusterSSH-4.09/lib/App/ClusterSSH/Config.pm.orig	2017-03-22 10:26:22.186034799 +0000
+++ App-ClusterSSH-4.09/lib/App/ClusterSSH/Config.pm	2017-03-22 10:48:16.196491331 +0000
@@ -7,7 +7,6 @@
 our $VERSION = version->new('0.02');
 
 use Carp;
-use Try::Tiny;
 
 use FindBin qw($Script);
 use File::Copy;
@@ -159,32 +158,25 @@
 
     if (@unknown_config) {
         croak(
-            App::ClusterSSH::Exception::Config->throw(
-                unknown_config => \@unknown_config,
-                error          => $self->loc(
+                $self->loc(
                     'Unknown configuration parameters: [_1]' . $/,
                     join( ',', @unknown_config )
                 )
-            )
         );
     }
 
     if ( !$self->{comms} ) {
         croak(
-            App::ClusterSSH::Exception::Config->throw(
-                error => $self->loc( 'Invalid variable: comms' . $/ ),
-            ),
+                $self->loc( 'Invalid variable: comms' . $/ ),
         );
     }
 
     if ( !$self->{ $self->{comms} } ) {
         croak(
-            App::ClusterSSH::Exception::Config->throw(
-                error => $self->loc(
+                $self->loc(
                     'Invalid variable: [_1]' . $/,
                     $self->{comms}
                 ),
-            ),
         );
     }
 
@@ -207,12 +199,10 @@
 
     #    if ( !-e $config_file || !-r $config_file ) {
     #        croak(
-    #            App::ClusterSSH::Exception::Config->throw(
-    #                error => $self->loc(
+    #                $self->loc(
     #                    'File [_1] does not exist or cannot be read' . $/,
     #                    $config_file
     #                ),
-    #            ),
     #        );
     #    }
     #
@@ -280,10 +270,9 @@
     }
 
     # write out default config file if necesasry
-    try {
-        $self->write_user_config_file();
-    }
-    catch {
+    if (
+        $self->write_user_config_file()
+    ) {
         warn $_, $/;
     };
 
@@ -309,12 +298,10 @@
 
         if ($@) {
             croak(
-                App::ClusterSSH::Exception::Config->throw(
-                    error => $self->loc(
+                    $self->loc(
                         'Unable to move [_1] to [_2]: [_3]' . $/,
                         '$HOME/.csshrc', '$HOME/.csshrc.DISABLED', $@
                     ),
-                )
             );
         }
         else {
@@ -332,12 +319,10 @@
     if ( !-d "$ENV{HOME}/.clusterssh" ) {
         if ( !mkdir("$ENV{HOME}/.clusterssh") ) {
             croak(
-                App::ClusterSSH::Exception::Config->throw(
-                    error => $self->loc(
+                    $self->loc(
                         'Unable to create directory [_1]: [_2]' . $/,
                         '$HOME/.clusterssh', $!
                     ),
-                ),
             );
 
         }
@@ -357,13 +342,11 @@
         }
         else {
             croak(
-                App::ClusterSSH::Exception::Config->throw(
-                    error => $self->loc(
+                    $self->loc(
                         'Unable to write [_1]: [_2]' . $/,
                         '$HOME/.clusterssh/clusters',
                         $!
                     ),
-                ),
             );
         }
     }
@@ -386,12 +369,10 @@
     }
     else {
         croak(
-            App::ClusterSSH::Exception::Config->throw(
-                error => $self->loc(
+                $self->loc(
                     'Unable to write default [_1]: [_2]' . $/,
                     '$HOME/.clusterssh/config', $!
                 ),
-            ),
         );
     }
 
@@ -424,9 +405,7 @@
 
     if ( !$binary ) {
         croak(
-            App::ClusterSSH::Exception::Config->throw(
-                error => $self->loc('argument not provided') . $/,
-            ),
+                $self->loc('argument not provided') . $/,
         );
     }
 
@@ -475,13 +454,11 @@
     }
     if ( !$path || !-f $path || !-x $path ) {
         croak(
-            App::ClusterSSH::Exception::Config->throw(
-                error => $self->loc(
+                $self->loc(
                     '"[_1]" binary not found - please amend $PATH or the cssh config file'
                         . $/,
                     $binary
                 ),
-            ),
         );
     }
 
--- App-ClusterSSH-4.09/lib/App/ClusterSSH/Getopt.pm.orig	2017-03-22 10:50:26.768566311 +0000
+++ App-ClusterSSH-4.09/lib/App/ClusterSSH/Getopt.pm	2017-03-22 10:51:02.323515604 +0000
@@ -7,7 +7,6 @@
 our $VERSION = version->new('0.01');
 
 use Carp;
-use Try::Tiny;
 use Pod::Usage;
 use Getopt::Long qw(:config no_ignore_case bundling no_auto_abbrev);
 use FindBin qw($Script);
--- App-ClusterSSH-4.09/lib/App/ClusterSSH/Helper.pm.orig	2017-03-22 10:33:08.703980475 +0000
+++ App-ClusterSSH-4.09/lib/App/ClusterSSH/Helper.pm	2017-03-22 10:33:20.035706452 +0000
@@ -7,7 +7,6 @@
 our $VERSION = version->new('0.02');
 
 use Carp;
-use Try::Tiny;
 
 use base qw/ App::ClusterSSH::Base /;
 
--- App-ClusterSSH-4.09/lib/App/ClusterSSH/Host.pm.orig	2017-03-22 10:33:52.690436764 +0000
+++ App-ClusterSSH-4.09/lib/App/ClusterSSH/Host.pm	2017-03-22 10:34:42.232192289 +0000
@@ -19,9 +19,7 @@
 
     if ( !$args{hostname} ) {
         croak(
-            App::ClusterSSH::Exception->throw(
-                error => $class->loc('hostname is undefined')
-            )
+                $class->loc('hostname is undefined')
         );
     }
 
@@ -280,11 +278,9 @@
 
     # if we got this far, we didnt parse the host_string properly
     croak(
-        App::ClusterSSH::Exception->throw(
-            error => $self->loc(
+            $self->loc(
                 'Unable to parse hostname from "[_1]"', $host_string
             )
-        )
     );
 }