[tmcode commit] r300 - in spine/trunk/lib/Spine: . Plugin Util

0 views
Skip to first unread message

oss...@gmail.com

unread,
Nov 17, 2009, 7:06:14 PM11/17/09
to tmcode...@googlegroups.com
Author: cfb
Date: Tue Nov 17 16:06:13 2009
New Revision: 300

Log:
Subject: Fix new Exec code to behave during dryrun.

From: Chet Burgess <c...@liquidreality.org>

Trac: Refs #107

Same as changes to spine_2_1 branch, but now on trunk.

The introduction of simple_exec caused a few problems. Most noteably
the fact that the logic for detectin dryrun and intert functions
was incorrect such that command always ran in dryrun mode even if
inert was set to 0. After fixing this I discoverd a number of other
issues around the fact that commands were no longer running during
dryrun mode even when they needed to.

More information on a file by file basis.

M trunk/lib/Spine/Util.pm
-do_rsync needs to support inert since it can be called
in cases that need to run even during dryrun
-Fixed typo wraper => wrapper
-exec_command was only used by RestartServices, updated
RestartService to just use simple_exec directly. Checked
the existing TM data tree and found no uses of the
exec_command function in templates.

M trunk/lib/Spine/Util/Exec.pm
-Fixed detection of dryrun mode (c_dryrun not dryrun).
-_readlines would error if we were in dryrun, no returns undef
if we are running in dryrun mode.

M trunk/lib/Spine/Plugin/Overlay.pm
-Call do_rsync with inert=1 when copying the content of c_root
to the temp overlay.

M trunk/lib/Spine/Plugin/RestartServices.pm
-Call simple_exec directly instead of exec_command.

Signed-off-by: Chet Burgess <c...@liquidreality.org>

Modified:
spine/trunk/lib/Spine/Plugin/Overlay.pm
spine/trunk/lib/Spine/Plugin/RestartServices.pm
spine/trunk/lib/Spine/Util.pm
spine/trunk/lib/Spine/Util/Exec.pm

Modified: spine/trunk/lib/Spine/Plugin/Overlay.pm
==============================================================================
--- spine/trunk/lib/Spine/Plugin/Overlay.pm Tue Nov 17 15:58:23 2009 (r299)
+++ spine/trunk/lib/Spine/Plugin/Overlay.pm Tue Nov 17 16:06:13 2009 (r300)
@@ -122,6 +122,7 @@
{
$c->print(4, "performing overlay from $dir");
unless (do_rsync(Config => $c,
+ Inert => 1,
Source => $overlay,
Target => catfile($tmpdir, $target),
Excludes => \@excludes)) {

Modified: spine/trunk/lib/Spine/Plugin/RestartServices.pm
==============================================================================
--- spine/trunk/lib/Spine/Plugin/RestartServices.pm Tue Nov 17 15:58:23 2009 (r299)
+++ spine/trunk/lib/Spine/Plugin/RestartServices.pm Tue Nov 17 16:06:13 2009 (r300)
@@ -39,7 +39,7 @@


use File::stat;
-use Spine::Util qw(exec_initscript exec_command);
+use Spine::Util qw(exec_initscript simple_exec);

my $DRYRUN;

@@ -128,11 +128,17 @@
else
{
$c->cprint("executing command $command", 2);
- unless ($DRYRUN)
- {
- exec_command($c, $command, 1)
- or $rval++;
- }
+
+ # Work out what th command is vs arguments
+ $command =~ m/^([\S]+)(?:\s+(.*))?$/;
+ my ($cmd, $args) = ($1, $2);
+
+ simple_exec(exec => $cmd,
+ args => $args,
+ inert => 0,
+ quiet => 1,
+ c => $c,
+ merge_error => 1) or $rval++;
}
utime(time, time, @{$rshash{$key}});
}

Modified: spine/trunk/lib/Spine/Util.pm
==============================================================================
--- spine/trunk/lib/Spine/Util.pm Tue Nov 17 15:58:23 2009 (r299)
+++ spine/trunk/lib/Spine/Util.pm Tue Nov 17 16:06:13 2009 (r300)
@@ -200,8 +200,10 @@
$tmpfh->close();
push @rsync_opts, "--exclude-from=$tmpfn"
}
-
+
+ my $inert = exists $args{Inert} ? $args{Inert} : 0;
my @result = simple_exec(c => $c,
+ inert => $inert,
exec => 'rsync',
merge_error => 1,
args => [@rsync_opts,
@@ -240,43 +242,21 @@
return 1;
}

-# wraper to Spine::Util::Exec::simple
+# wrapper to Spine::Util::Exec::simple
sub simple_exec {
return Spine::Util::Exec->simple(@_);
}

-# wraper to Spine::Util::Exec::new
+# wrapper to Spine::Util::Exec::new
sub create_exec {
return Spine::Util::Exec->new(@_);
}

-# wraper to Spine::Util::Exec::find_exec
+# wrapper to Spine::Util::Exec::find_exec
sub find_exec {
return Spine::Util::Exec->find_exec(@_);
}

-# DEPRECIATE: for support of old implementation (used in templates)
-sub exec_command {
- my ($c, $command, $report_error, $inert, $merror) = @_;
-
- # Work out what the command is vs arguments
- $command =~ m/^([\S]+)(?:\s+(.*))?$/;
- my ($cmd, $args) = ($1, $2);
-
- #TODO This should be uncommented in a few releases time
- #$c->error('use of depreciated "exec_command" please use "simple_exec"',
- # 'warning');
-
- return simple_exec(exec => $cmd,
- args => $args,
- inert => $inert,
- quiet => $report_error ? 0 : 1,
- c => $c,
- merge_error => defined $merror ? $merror : 1);
-
-}
-
-

sub octal_conv
{

Modified: spine/trunk/lib/Spine/Util/Exec.pm
==============================================================================
--- spine/trunk/lib/Spine/Util/Exec.pm Tue Nov 17 15:58:23 2009 (r299)
+++ spine/trunk/lib/Spine/Util/Exec.pm Tue Nov 17 16:06:13 2009 (r300)
@@ -177,7 +177,7 @@
# can we run? if we are in dryrun and the command
# has not been described as inert then we will skip
# running.
- if ($self->{c}->getval('dryrun') &&
+ if ($self->{c}->getval('c_dryrun') &&
(! exists $self->{inert} ||
! $self->{inert} )) {
$self->{dryrun} = 1;
@@ -234,8 +234,13 @@
sub _readlines {
my $self = shift;
my $type = shift;
-
- return undef unless $self->{ready};
+
+ # If we are in dryrun we didn't run so just return undef.
+ # Also if we aren't ready yet, return undef.
+ if ( (exists $self->{dryrun} && $self->{dryrun}) || ! $self->{ready} )
+ {
+ return undef;
+ }

my @output = $self->{$type}->getlines();
if ($self->{$type}->error()) {
Reply all
Reply to author
Forward
0 new messages