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 @@ -65,7 +65,19 @@ sub _mirror
6565 { unlink " $dst " }
6666 my $target = readlink " $src " ;
6767 Alien::Build-> log (" ln -s $target $dst " ) if $opt -> {verbose };
68+ if (path($target )-> is_relative) {
69+ if (!$src -> parent-> child($target )-> exists ) {
70+ die " cannot create symlink to nonexistent file $target on MSYS2" ;
71+ }
72+ # NOTE: On linux, it is OK to create broken symlinks, but it is not allowed on
73+ # windows MSYS2, so make sure the target exists.
74+ $dst -> parent-> child($target )-> touchpath;
75+ }
76+ my $curdir = Path::Tiny-> cwd;
77+ # CD into the directory, such that symlink will work on MSYS2
78+ chdir $dst -> parent or die " could not chdir to $src ->parent : $! " ;
6879 symlink ($target , $dst ) || die " unable to symlink $target => $dst " ;
80+ chdir $curdir or die " could not chdir to $curdir : $! " ;
6981 }
7082 elsif (-d " $src " )
7183 {
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