-
Notifications
You must be signed in to change notification settings - Fork 29
patch atnodes for cnangel #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ requires ('Net::OpenSSH' => '0.34'); | |
| requires ('File::Temp'); | ||
| requires ('Term::ReadKey' => '2.30'); | ||
| requires ('IO::Pty'); | ||
| requires ('Time::HiRes'); | ||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should really add the |
||
| build_requires ('IPC::Run3'); | ||
| #build_requires ('Test::Base' => '0.54'); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ NAME | |
| arithmetic | ||
|
|
||
| VERSION | ||
| This document describes SSH::Batch 0.028 released on 26 August 2011. | ||
| This document describes SSH::Batch 0.029 released on 29 April 2012. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please exclude these irrelevant changes. You shouldn't do the release anyway :) |
||
|
|
||
| SYNOPSIS | ||
| The following scripts are provided: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ use Term::ReadKey; | |
| use SSH::Batch::ForNodes; | ||
| use File::Temp qw/ :POSIX /; | ||
| use Time::HiRes qw/sleep/; | ||
| use Expect; | ||
|
|
||
| sub help ($); | ||
| sub check_openssh_version ($); | ||
|
|
@@ -30,6 +31,8 @@ my $found_sep; | |
| my $last_option; | ||
| my $use_tty; | ||
| my $use_quiet_mode; | ||
| my $use_expect_mode; | ||
| my $expect_timeout = 1; | ||
| my $line_mode = $ENV{SSH_BATCH_LINE_MODE}; | ||
| for (@ARGV) { | ||
| if (defined $fetch_value) { | ||
|
|
@@ -71,6 +74,10 @@ for (@ARGV) { | |
| $use_tty = 1; | ||
| } elsif ($group eq 'q') { | ||
| $use_quiet_mode = 1; | ||
| } elsif ($group eq 'E') { | ||
| $use_expect_mode = 1; | ||
| } elsif ($group eq 'tmout') { | ||
| $fetch_value = sub { $expect_timeout = shift }; | ||
| } else { | ||
| die "Unknown option: $_\n"; | ||
| } | ||
|
|
@@ -200,14 +207,30 @@ while (1) { | |
| for my $host (@active_hosts) { | ||
| my ($out, $outfile) = tmpnam(); | ||
| my $ssh = $conns{$host}; | ||
| my $pid = $ssh->system({ | ||
| (defined $password? | ||
| (stdin_data => "$password\n") : ()), | ||
| stdout_fh => $out, | ||
| stderr_to_stdout => 1, | ||
| async => 1, | ||
| defined $use_tty ? (tty => 1) : (), | ||
| }, @cmd); | ||
| my $pid; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like bad indentation? Please fix the coding style. Thank you. |
||
| my $pty; | ||
| if ($use_expect_mode && $use_expect_mode == 1) { | ||
| ($pty, $pid) = $ssh->open2pty({'stderr_to_stdout' => 1}, @cmd); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, we use 4 space indentation. |
||
| my $expect = Expect->init($pty); | ||
| $expect->log_file($outfile, "w"); | ||
| $expect->raw_pty(1); | ||
| $expect->expect($expect_timeout, ":"); | ||
| if (defined $password) { | ||
| $expect->send("$password\n"); | ||
| } | ||
| $expect->expect($expect_timeout, "\n"); | ||
| $expect->raw_pty(0); | ||
| close $expect; | ||
| } else { | ||
| $pid = $ssh->system({ | ||
| (defined $password? | ||
| (stdin_data => "$password\n") : ()), | ||
| stdout_fh => $out, | ||
| stderr_to_stdout => 1, | ||
| async => 1, | ||
| defined $use_tty ? (tty => 1) : (), | ||
| }, @cmd); | ||
| } | ||
| #warn "PID: $pid\n"; | ||
| if (!defined $pid or $pid == -1) { | ||
| $active_count--; | ||
|
|
@@ -311,7 +334,9 @@ OPTIONS: | |
| -P Prompt for passphrase (used for login, | ||
| could be privided by SSH_BATCH_PASSPHRASE). | ||
| -tty Pseudo-tty. | ||
| -q Run SSH in quiet mode | ||
| -E Use expect for input, such as password. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Options documented in this usage message should be sorted alphabetically. |
||
| -tmout Set timeout of expect. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like this |
||
| -q Run SSH in quiet mode. | ||
| _EOC_ | ||
| if ($exit_code == 0) { | ||
| print $msg; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ use ExtUtils::MakeMaker (); | |
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please exclude all the changes under |
||
| use vars qw{$VERSION}; | ||
| BEGIN { | ||
| $VERSION = '1.03'; | ||
| $VERSION = '1.04'; | ||
| } | ||
|
|
||
| # special map on pre-defined feature sets | ||
|
|
@@ -17,11 +17,14 @@ my %FeatureMap = ( | |
| ); | ||
|
|
||
| # various lexical flags | ||
| my ( @Missing, @Existing, %DisabledTests, $UnderCPAN, $HasCPANPLUS ); | ||
| my ( @Missing, @Existing, %DisabledTests, $UnderCPAN, $InstallDepsTarget, $HasCPANPLUS ); | ||
| my ( | ||
| $Config, $CheckOnly, $SkipInstall, $AcceptDefault, $TestOnly, $AllDeps | ||
| $Config, $CheckOnly, $SkipInstall, $AcceptDefault, $TestOnly, $AllDeps, | ||
| $UpgradeDeps | ||
| ); | ||
| my ( $PostambleActions, $PostambleUsed ); | ||
| my ( $PostambleActions, $PostambleActionsNoTest, $PostambleActionsUpgradeDeps, | ||
| $PostambleActionsUpgradeDepsNoTest, $PostambleActionsListDeps, | ||
| $PostambleActionsListAllDeps, $PostambleUsed, $NoTest); | ||
|
|
||
| # See if it's a testing or non-interactive session | ||
| _accept_default( $ENV{AUTOMATED_TESTING} or ! -t STDIN ); | ||
|
|
@@ -31,6 +34,10 @@ sub _accept_default { | |
| $AcceptDefault = shift; | ||
| } | ||
|
|
||
| sub _installdeps_target { | ||
| $InstallDepsTarget = shift; | ||
| } | ||
|
|
||
| sub missing_modules { | ||
| return @Missing; | ||
| } | ||
|
|
@@ -63,6 +70,11 @@ sub _init { | |
| __PACKAGE__->install( $Config, @Missing = split( /,/, $1 ) ); | ||
| exit 0; | ||
| } | ||
| elsif ( $arg =~ /^--upgradedeps=(.*)$/ ) { | ||
| $UpgradeDeps = 1; | ||
| __PACKAGE__->install( $Config, @Missing = split( /,/, $1 ) ); | ||
| exit 0; | ||
| } | ||
| elsif ( $arg =~ /^--default(?:deps)?$/ ) { | ||
| $AcceptDefault = 1; | ||
| } | ||
|
|
@@ -125,7 +137,7 @@ sub import { | |
| # check entirely since we don't want to have to load (and configure) | ||
| # an old CPAN just for a cosmetic message | ||
|
|
||
| $UnderCPAN = _check_lock(1) unless $SkipInstall; | ||
| $UnderCPAN = _check_lock(1) unless $SkipInstall || $InstallDepsTarget; | ||
|
|
||
| while ( my ( $feature, $modules ) = splice( @args, 0, 2 ) ) { | ||
| my ( @required, @tests, @skiptests ); | ||
|
|
@@ -207,6 +219,7 @@ sub import { | |
| $CheckOnly | ||
| or ($mandatory and $UnderCPAN) | ||
| or $AllDeps | ||
| or $InstallDepsTarget | ||
| or _prompt( | ||
| qq{==> Auto-install the } | ||
| . ( @required / 2 ) | ||
|
|
@@ -237,10 +250,17 @@ sub import { | |
| } | ||
| } | ||
|
|
||
| if ( @Missing and not( $CheckOnly or $UnderCPAN ) ) { | ||
| if ( @Missing and not( $CheckOnly or $UnderCPAN) ) { | ||
| require Config; | ||
| "*** Dependencies will be installed the next time you type '$Config::Config{make}'.\n"; | ||
| my $make = $Config::Config{make}; | ||
| if ($InstallDepsTarget) { | ||
| "*** To install dependencies type '$make installdeps' or '$make installdeps_notest'.\n"; | ||
| } | ||
| else { | ||
| "*** Dependencies will be installed the next time you type '$make'.\n"; | ||
| } | ||
|
|
||
| # make an educated guess of whether we'll need root permission. | ||
| print " (You may need to do that as the 'root' user.)\n" | ||
|
|
@@ -271,6 +291,10 @@ END_MESSAGE | |
| sub _check_lock { | ||
| return unless @Missing or @_; | ||
|
|
||
| if ($ENV{PERL5_CPANM_IS_RUNNING}) { | ||
| return _running_under('cpanminus'); | ||
| } | ||
|
|
||
| my $cpan_env = $ENV{PERL5_CPAN_IS_RUNNING}; | ||
|
|
||
| if ($ENV{PERL5_CPANPLUS_IS_RUNNING}) { | ||
|
|
@@ -332,6 +356,11 @@ sub install { | |
| } | ||
| } | ||
|
|
||
| if ($UpgradeDeps) { | ||
| push @modules, @installed; | ||
| @installed = (); | ||
| } | ||
|
|
||
| return @installed unless @modules; # nothing to do | ||
| return @installed if _check_lock(); # defer to the CPAN shell | ||
|
|
||
|
|
@@ -463,6 +492,11 @@ sub _cpanplus_config { | |
| } else { | ||
| die "*** Cannot convert option $key = '$value' to CPANPLUS version.\n"; | ||
| } | ||
| push @config, 'prereqs', $value; | ||
| } elsif ( $key eq 'force' ) { | ||
| push @config, $key, $value; | ||
| } elsif ( $key eq 'notest' ) { | ||
| push @config, 'skiptest', $value; | ||
| } else { | ||
| die "*** Cannot convert option $key to CPANPLUS version.\n"; | ||
| } | ||
|
|
@@ -497,10 +531,14 @@ sub _install_cpan { | |
| # set additional options | ||
| while ( my ( $opt, $arg ) = splice( @config, 0, 2 ) ) { | ||
| ( $args{$opt} = $arg, next ) | ||
| if $opt =~ /^force$/; # pseudo-option | ||
| if $opt =~ /^(?:force|notest)$/; # pseudo-option | ||
| $CPAN::Config->{$opt} = $arg; | ||
| } | ||
|
|
||
| if ($args{notest} && (not CPAN::Shell->can('notest'))) { | ||
| die "Your version of CPAN is too old to support the 'notest' pragma"; | ||
| } | ||
|
|
||
| local $CPAN::Config->{prerequisites_policy} = 'follow'; | ||
|
|
||
| while ( my ( $pkg, $ver ) = splice( @modules, 0, 2 ) ) { | ||
|
|
@@ -519,8 +557,16 @@ sub _install_cpan { | |
| delete $INC{$inc}; | ||
| } | ||
|
|
||
| my $rv = $args{force} ? CPAN::Shell->force( install => $pkg ) | ||
| : CPAN::Shell->install($pkg); | ||
| my $rv = do { | ||
| if ($args{force}) { | ||
| CPAN::Shell->force( install => $pkg ) | ||
| } elsif ($args{notest}) { | ||
| CPAN::Shell->notest( install => $pkg ) | ||
| } else { | ||
| CPAN::Shell->install($pkg) | ||
| } | ||
| }; | ||
|
|
||
| $rv ||= eval { | ||
| $CPAN::META->instance( 'CPAN::Distribution', $obj->cpan_file, ) | ||
| ->{install} | ||
|
|
@@ -763,6 +809,35 @@ sub _make_args { | |
| : "\$(NOECHO) \$(NOOP)" | ||
| ); | ||
|
|
||
| my $deps_list = join( ',', @Missing, @Existing ); | ||
|
|
||
| $PostambleActionsUpgradeDeps = | ||
| "\$(PERL) $0 --config=$config --upgradedeps=$deps_list"; | ||
|
|
||
| my $config_notest = | ||
| join( ',', (UNIVERSAL::isa( $Config, 'HASH' ) ? %{$Config} : @{$Config}), | ||
| 'notest', 1 ) | ||
| if $Config; | ||
|
|
||
| $PostambleActionsNoTest = ( | ||
| ($missing and not $UnderCPAN) | ||
| ? "\$(PERL) $0 --config=$config_notest --installdeps=$missing" | ||
| : "\$(NOECHO) \$(NOOP)" | ||
| ); | ||
|
|
||
| $PostambleActionsUpgradeDepsNoTest = | ||
| "\$(PERL) $0 --config=$config_notest --upgradedeps=$deps_list"; | ||
|
|
||
| $PostambleActionsListDeps = | ||
| '@$(PERL) -le "print for @ARGV" ' | ||
| . join(' ', map $Missing[$_], grep $_ % 2 == 0, 0..$#Missing); | ||
|
|
||
| my @all = (@Missing, @Existing); | ||
|
|
||
| $PostambleActionsListAllDeps = | ||
| '@$(PERL) -le "print for @ARGV" ' | ||
| . join(' ', map $all[$_], grep $_ % 2 == 0, 0..$#all); | ||
|
|
||
| return %args; | ||
| } | ||
|
|
||
|
|
@@ -797,24 +872,44 @@ sub Write { | |
|
|
||
| sub postamble { | ||
| $PostambleUsed = 1; | ||
| my $fragment; | ||
|
|
||
| return <<"END_MAKE"; | ||
| $fragment .= <<"AUTO_INSTALL" if !$InstallDepsTarget; | ||
|
|
||
| config :: installdeps | ||
| \t\$(NOECHO) \$(NOOP) | ||
| AUTO_INSTALL | ||
|
|
||
| $fragment .= <<"END_MAKE"; | ||
|
|
||
| checkdeps :: | ||
| \t\$(PERL) $0 --checkdeps | ||
|
|
||
| installdeps :: | ||
| \t$PostambleActions | ||
|
|
||
| installdeps_notest :: | ||
| \t$PostambleActionsNoTest | ||
|
|
||
| upgradedeps :: | ||
| \t$PostambleActionsUpgradeDeps | ||
|
|
||
| upgradedeps_notest :: | ||
| \t$PostambleActionsUpgradeDepsNoTest | ||
|
|
||
| listdeps :: | ||
| \t$PostambleActionsListDeps | ||
|
|
||
| listalldeps :: | ||
| \t$PostambleActionsListAllDeps | ||
|
|
||
| END_MAKE | ||
|
|
||
| return $fragment; | ||
| } | ||
|
|
||
| 1; | ||
|
|
||
| __END__ | ||
|
|
||
| #line 1071 | ||
| #line 1178 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please exclude these irrelevant changes.