Add $level variable in stow_contents and stow_node
This variables is used to keep track of the current level in the source.
This commit is contained in:
parent
d4e413536e
commit
a2db7a9c76
1 changed files with 13 additions and 9 deletions
|
@ -317,6 +317,7 @@ sub plan_stow {
|
||||||
$package,
|
$package,
|
||||||
'.',
|
'.',
|
||||||
$path, # source from target
|
$path, # source from target
|
||||||
|
0,
|
||||||
);
|
);
|
||||||
debug(2, "Planning stow of package $package... done");
|
debug(2, "Planning stow of package $package... done");
|
||||||
$self->{action_count}++;
|
$self->{action_count}++;
|
||||||
|
@ -368,11 +369,12 @@ sub within_target_do {
|
||||||
#============================================================================
|
#============================================================================
|
||||||
sub stow_contents {
|
sub stow_contents {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($stow_path, $package, $target, $source) = @_;
|
my ($stow_path, $package, $target, $source, $level) = @_;
|
||||||
|
|
||||||
# Remove leading .. from $source
|
|
||||||
my $path = join '/', map { ($_ eq '..') ? ( ) : $_ } (split m{/+}, $source);
|
|
||||||
|
|
||||||
|
# Remove leading $level times .. from $source
|
||||||
|
my $n = 0;
|
||||||
|
my $path = join '/', map { (++$n <= $level) ? ( ) : $_ } (split m{/+}, $source);
|
||||||
|
|
||||||
return if $self->should_skip_target_which_is_stow_dir($target);
|
return if $self->should_skip_target_which_is_stow_dir($target);
|
||||||
|
|
||||||
my $cwd = getcwd();
|
my $cwd = getcwd();
|
||||||
|
@ -409,6 +411,7 @@ sub stow_contents {
|
||||||
$package,
|
$package,
|
||||||
$node_target, # target
|
$node_target, # target
|
||||||
join_paths($source, $node), # source
|
join_paths($source, $node), # source
|
||||||
|
$level
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -431,7 +434,7 @@ sub stow_contents {
|
||||||
#============================================================================
|
#============================================================================
|
||||||
sub stow_node {
|
sub stow_node {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($stow_path, $package, $target, $source) = @_;
|
my ($stow_path, $package, $target, $source, $level) = @_;
|
||||||
|
|
||||||
my $path = join_paths($stow_path, $package, $target);
|
my $path = join_paths($stow_path, $package, $target);
|
||||||
|
|
||||||
|
@ -501,12 +504,14 @@ sub stow_node {
|
||||||
$existing_package,
|
$existing_package,
|
||||||
$target,
|
$target,
|
||||||
join_paths('..', $existing_source),
|
join_paths('..', $existing_source),
|
||||||
|
$level + 1,
|
||||||
);
|
);
|
||||||
$self->stow_contents(
|
$self->stow_contents(
|
||||||
$self->{stow_path},
|
$self->{stow_path},
|
||||||
$package,
|
$package,
|
||||||
$target,
|
$target,
|
||||||
join_paths('..', $source),
|
join_paths('..', $source),
|
||||||
|
$level + 1,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -533,6 +538,7 @@ sub stow_node {
|
||||||
$package,
|
$package,
|
||||||
$target,
|
$target,
|
||||||
join_paths('..', $source),
|
join_paths('..', $source),
|
||||||
|
$level + 1,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -556,6 +562,7 @@ sub stow_node {
|
||||||
$package,
|
$package,
|
||||||
$target,
|
$target,
|
||||||
join_paths('..', $source),
|
join_paths('..', $source),
|
||||||
|
$level + 1,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -742,10 +749,7 @@ sub unstow_node_orig {
|
||||||
#============================================================================
|
#============================================================================
|
||||||
sub unstow_contents {
|
sub unstow_contents {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($stow_path, $package, $target, $source) = @_;
|
my ($stow_path, $package, $target, $path) = @_;
|
||||||
|
|
||||||
# Remove leading .. from $source
|
|
||||||
my $path = join '/', map { ($_ eq '..') ? ( ) : $_ } (split m{/+}, $source);
|
|
||||||
|
|
||||||
return if $self->should_skip_target_which_is_stow_dir($target);
|
return if $self->should_skip_target_which_is_stow_dir($target);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue