fix stowing of relative links when --no-folding is used

With a tree like this:

    .
    |-- stow
    |   `-- pkg
    |       `-- lib
    |           |-- itk-current -> itk4.0.0
    |           `-- itk4.0.0
    |               `-- libitk4.0.0.so
    `-- target
        `-- lib
            |-- itk4.0.0 -> ../../stow/pkg/lib/itk4.0.0
            `-- libfoo-1.2.3.so

stowing pkg with the --no-folding option resulted in itk-current
being "unpacked":

    .
    `-- target
        `-- lib
            |-- itk-current
            |   `-- libitk4.0.0.so -> ../../../stow/pkg/lib/itk-current/libitk4.0.0.so
            |-- itk4.0.0
            |   `-- libitk4.0.0.so -> ../../../stow/pkg/lib/itk4.0.0/libitk4.0.0.so
            `-- libfoo-1.2.3.so

This commit fixes it so that it gets stowed as a symlink:

  .
  `-- target
      `-- lib
          ...
          |-- itk-current -> ../../stow/pkg/lib/itk-current
          ...

Thanks to Gabriele Balducci for reporting this problem:

    http://thread.gmane.org/gmane.comp.gnu.stow.general/6676
This commit is contained in:
Adam Spiers 2015-01-01 19:02:46 +00:00
parent 5be496a795
commit 7b43622dd9
2 changed files with 7 additions and 4 deletions

View file

@ -520,7 +520,7 @@ sub stow_node {
}
}
}
elsif ($self->{'no-folding'} && -d $path) {
elsif ($self->{'no-folding'} && -d $path && ! -l $path) {
$self->do_mkdir($target);
$self->stow_contents(
$self->{stow_path},

View file

@ -7,7 +7,7 @@
use strict;
use warnings;
use Test::More tests => 112;
use Test::More tests => 118;
use Test::Output;
use English qw(-no_match_vars);
@ -461,6 +461,7 @@ sub create_pkg {
# yet stowed
make_dir ("$stow_pkg/$id-$pkg-only-new2/subdir");
make_file("$stow_pkg/$id-$pkg-only-new2/subdir/$id-file-$pkg");
make_link("$stow_pkg/$id-$pkg-only-new2/current", "subdir");
# create a hierarchy specific to this package which is already
# stowed via a folded tree
@ -487,7 +488,7 @@ $stow->plan_stow('no-folding-a');
is_deeply([ $stow->get_conflicts ], [] => 'no conflicts with --no-folding');
my @tasks = $stow->get_tasks;
use Data::Dumper;
is(scalar(@tasks), 12 => "6 dirs, 6 links") || warn Dumper(\@tasks);
is(scalar(@tasks), 13 => "6 dirs, 7 links") || warn Dumper(\@tasks);
$stow->process_tasks();
sub check_no_folding {
@ -508,6 +509,8 @@ sub check_no_folding {
is_dir_not_symlink("no-folding-$pkg-only-new2/subdir");
is_link("no-folding-$pkg-only-new2/subdir/no-folding-file-$pkg",
"../../$stow_pkg/no-folding-$pkg-only-new2/subdir/no-folding-file-$pkg");
is_link("no-folding-$pkg-only-new2/current",
"../$stow_pkg/no-folding-$pkg-only-new2/current");
# check shared tree is not folded. first time round this will be
# newly stowed.
@ -530,7 +533,7 @@ $stow = new_Stow('no-folding' => 1);
$stow->plan_stow('no-folding-b');
is_deeply([ $stow->get_conflicts ], [] => 'no conflicts with --no-folding');
@tasks = $stow->get_tasks;
is(scalar(@tasks), 10 => '4 dirs, 6 links') || warn Dumper(\@tasks);
is(scalar(@tasks), 11 => '4 dirs, 7 links') || warn Dumper(\@tasks);
$stow->process_tasks();
check_no_folding('a');