File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,19 @@ sub _mirror
7676 { unlink " $dst " }
7777 my $target = readlink " $src " ;
7878 Alien::Build-> log (" ln -s $target $dst " ) if $opt -> {verbose };
79+ if (path($target )-> is_relative) {
80+ if (!$src -> parent-> child($target )-> exists ) {
81+ die " cannot create symlink to nonexistent file $target on MSYS2" ;
82+ }
83+ # NOTE: On linux, it is OK to create broken symlinks, but it is not allowed on
84+ # windows MSYS2, so make sure the target exists.
85+ $dst -> parent-> child($target )-> touchpath;
86+ }
87+ my $curdir = Path::Tiny-> cwd;
88+ # CD into the directory, such that symlink will work on MSYS2
89+ chdir $dst -> parent or die " could not chdir to $src ->parent : $! " ;
7990 symlink ($target , $dst ) || die " unable to symlink $target => $dst " ;
91+ chdir $curdir or die " could not chdir to $curdir : $! " ;
8092 }
8193 elsif (-f " $src " )
8294 {
Original file line number Diff line number Diff line change @@ -47,11 +47,16 @@ subtest 'mirror' => sub {
4747
4848 if ($Config {d_symlink })
4949 {
50- foreach my $new (map { $tmp1 -> child(" lib/libfoo$_ " ) } qw( .so.1.2 .so.1 .so ) )
50+ my $newdir = $tmp1 -> child(" lib" );
51+ my $savedir = Path::Tiny-> cwd;
52+ # CD into the the $newdir such that symlink will work on MSYS2
53+ chdir $newdir -> stringify or die " unable to chdir to $newdir : $! " ;
54+ foreach my $new (map { " libfoo$_ " } qw( .so.1.2 .so.1 .so ) )
5155 {
52- my $old = ' libfoo.so.1.2.3 ' ;
53- symlink ($old , $new -> stringify ) || die " unable to symlink $new => $old $! " ;
56+ my $old = $lib -> basename ;
57+ symlink ($old , $new ) || die " unable to symlink $new => $old $! " ;
5458 }
59+ chdir $savedir or die " unable to chdir to $savedir : $! " ;
5560 }
5661
5762 my $tmp2 = Path::Tiny-> tempdir(" mirror_dst_XXXX" );
You can’t perform that action at this time.
0 commit comments