xmvn/0003-Restotre-support-for-relative-symlinks.patch
2013-09-23 18:08:08 +02:00

42 lines
1.8 KiB
Diff

From 9da9a832135610a40625c73a38222ea995c79ef5 Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Mon, 23 Sep 2013 17:47:45 +0200
Subject: [PATCH 3/3] Restotre support for relative symlinks
---
.../org/fedoraproject/maven/installer/impl/Package.java | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/xmvn-core/src/main/java/org/fedoraproject/maven/installer/impl/Package.java b/xmvn-core/src/main/java/org/fedoraproject/maven/installer/impl/Package.java
index 1ab04b6..d0e33ba 100644
--- a/xmvn-core/src/main/java/org/fedoraproject/maven/installer/impl/Package.java
+++ b/xmvn-core/src/main/java/org/fedoraproject/maven/installer/impl/Package.java
@@ -86,11 +86,21 @@ class Package
addFile( file, target.getParent(), target.getFileName(), mode );
}
- public void addSymlink( Path symlink, Path target )
+ public void addSymlink( Path symlinkFile, Path symlinkTarget )
throws IOException
{
- Path symlinkFile = FileUtils.createAnonymousSymlink( target );
- addFile( symlinkFile, symlink, 0644 );
+ if ( symlinkFile.isAbsolute() )
+ throw new IllegalArgumentException( "symlinkFile is absolute path: " + symlinkFile );
+ if ( symlinkTarget.isAbsolute() )
+ throw new IllegalArgumentException( "symlinkTarget is absolute path: " + symlinkTarget );
+
+ symlinkFile = symlinkFile.normalize();
+ symlinkTarget = symlinkTarget.normalize();
+ if ( symlinkFile.getParent() != null )
+ symlinkTarget = symlinkFile.getParent().relativize( symlinkTarget );
+
+ Path symlinkTempFile = FileUtils.createAnonymousSymlink( symlinkTarget );
+ addFile( symlinkTempFile, symlinkFile, 0644 );
}
private Path installDirectory( Path root, Path target )
--
1.8.1.4