Restotre support for relative symlinks

This commit is contained in:
Mikolaj Izdebski 2013-09-23 17:50:17 +02:00
parent 38ca401b57
commit e8e064528a
4 changed files with 79 additions and 1 deletions

View File

@ -1,7 +1,7 @@
From 51259942aacc2a3b02564ae43dfabebb98aebf58 Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Mon, 23 Sep 2013 14:38:34 +0200
Subject: [PATCH] Don't try to relativize symlink targets
Subject: [PATCH 1/3] Don't try to relativize symlink targets
---
.../src/main/java/org/fedoraproject/maven/installer/impl/Package.java | 3 +--

View File

@ -0,0 +1,32 @@
From 48a8417d29b0e8f1b4f5c61281a9b5502e6c4913 Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Mon, 23 Sep 2013 17:29:28 +0200
Subject: [PATCH 2/3] Try to resolve cannonical artifact files
---
.../java/org/fedoraproject/maven/resolver/impl/DefaultResolver.java | 2 ++
1 file changed, 2 insertions(+)
diff --git a/xmvn-core/src/main/java/org/fedoraproject/maven/resolver/impl/DefaultResolver.java b/xmvn-core/src/main/java/org/fedoraproject/maven/resolver/impl/DefaultResolver.java
index 6bbd26b..9fc61c7 100644
--- a/xmvn-core/src/main/java/org/fedoraproject/maven/resolver/impl/DefaultResolver.java
+++ b/xmvn-core/src/main/java/org/fedoraproject/maven/resolver/impl/DefaultResolver.java
@@ -46,6 +46,7 @@ import org.fedoraproject.maven.resolver.ResolutionResult;
import org.fedoraproject.maven.resolver.Resolver;
import org.fedoraproject.maven.utils.ArtifactUtils;
import org.fedoraproject.maven.utils.AtomicFileCounter;
+import org.fedoraproject.maven.utils.FileUtils;
import org.fedoraproject.maven.utils.LoggingUtils;
/**
@@ -241,6 +242,7 @@ public class DefaultResolver
}
File artifactFile = result.getArtifactFile();
+ artifactFile = FileUtils.followSymlink( artifactFile );
logger.debug( "Artifact " + artifact + " was resolved to " + artifactFile );
if ( request.isProviderNeeded() )
result.setProvider( rpmdb.lookupFile( artifactFile ) );
--
1.8.1.4

View File

@ -0,0 +1,41 @@
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

View File

@ -7,6 +7,8 @@ URL: http://mizdebsk.fedorapeople.org/xmvn
BuildArch: noarch
Source0: https://fedorahosted.org/released/%{name}/%{name}-%{version}.tar.xz
Patch0: 0001-Don-t-try-to-relativize-symlink-targets.patch
Patch1: 0002-Try-to-resolve-cannonical-artifact-files.patch
Patch2: 0003-Restotre-support-for-relative-symlinks.patch
BuildRequires: maven >= 3.1.0
BuildRequires: maven-local
@ -34,6 +36,8 @@ This package provides %{summary}.
%prep
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
# Add cglib test dependency as a workaround for rhbz#911365
#pom_add_dep cglib:cglib::test %{name}-core
@ -145,6 +149,7 @@ end
%changelog
* Mon Sep 23 2013 Mikolaj Izdebski <mizdebsk@redhat.com> - 1.0.2-2
- Don't try to relativize symlink targets
- Restotre support for relative symlinks
* Fri Sep 20 2013 Mikolaj Izdebski <mizdebsk@redhat.com> - 1.0.2-1
- Update to upstream version 1.0.2