Allow xmvn to install files who names whitespace

This commit is contained in:
Mikolaj Izdebski 2017-01-16 14:49:52 +01:00
parent 262e0c9406
commit fb2e01f9a8
5 changed files with 116 additions and 10 deletions

View File

@ -1,7 +1,7 @@
From 969d50782dbf912f40c6979f15c25684404d3b38 Mon Sep 17 00:00:00 2001
From a2f918fe86c91e1a76d198e824118d5ba474808c Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Wed, 28 Oct 2015 22:26:44 +0100
Subject: [PATCH 1/3] Copy core dependencies to lib/core in assembly
Subject: [PATCH 1/4] Copy core dependencies to lib/core in assembly
---
xmvn-core/pom.xml | 15 +++++++++++++++
@ -34,5 +34,5 @@ index e792f6a..b0ef6b5 100644
</build>
</project>
--
2.7.4
2.9.3

View File

@ -1,7 +1,7 @@
From 530df7f2f2f6751a06862955fafbe319f86a3808 Mon Sep 17 00:00:00 2001
From 3b214255464d5baca5ee26a897cd9afca53e52c3 Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Thu, 26 Nov 2015 14:18:48 +0100
Subject: [PATCH 2/3] Try to procect builddep MOJO against patological cases
Subject: [PATCH 2/4] Try to procect builddep MOJO against patological cases
- Clone model before processing it to avoid
UnsupportedOperationException (rhbz#1276729).
@ -50,5 +50,5 @@ index 8bbdf5f..dd6a8f5 100644
String compatVersion = resolution[1];
String namespace = resolution[2];
--
2.7.4
2.9.3

View File

@ -1,7 +1,7 @@
From 84ee943dbe1c474aa7559242080d9f66b315b77d Mon Sep 17 00:00:00 2001
From 077ea8168a80eab45417ec40e48084998df8681e Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Mon, 4 Jul 2016 11:57:34 +0200
Subject: [PATCH 3/3] Don't install POM files for Tycho projects
Subject: [PATCH 3/4] Don't install POM files for Tycho projects
---
.../java/org/fedoraproject/xmvn/mojo/InstallMojo.java | 19 +++++++++++--------
@ -38,5 +38,5 @@ index fd76421..d6c95c8 100644
Set<Artifact> attachedArtifacts = new LinkedHashSet<>();
for ( org.apache.maven.artifact.Artifact mavenArtifact : project.getAttachedArtifacts() )
--
2.7.4
2.9.3

View File

@ -0,0 +1,101 @@
From 9de9f15cd6d0f362a396ec0fe9499278495ec9d1 Mon Sep 17 00:00:00 2001
From: Mat Booth <mat.booth@redhat.com>
Date: Sat, 14 Jan 2017 15:36:45 +0000
Subject: [PATCH 4/4] Allow xmvn to install files who names whitespace
Eclipse plugins may be installed as "dir-shaped" bundles, which means
that they will be installed as exploded directory trees instead of
ordinary jar files. If such a bundle contains a file that has a space
in its name, then this will cause RPM build failure due to RPM mis-
interpreting the descriptor line as two separate paths instead of a
single path containing a space.
This change adds quoting to paths that contain whitespace when writing
the descriptor.
---
.../org/fedoraproject/xmvn/tools/install/File.java | 15 ++++++++++-
.../xmvn/tools/install/JavaPackageTest.java | 31 +++++++++++++++++++++-
2 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/File.java b/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/File.java
index 1f4c4ea..7710aa4 100644
--- a/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/File.java
+++ b/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/File.java
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2014-2015 Red Hat, Inc.
+ * Copyright (c) 2014-2017 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -161,9 +161,22 @@ public abstract class File
sb.append( ' ' );
}
+ // Paths containing whitespace (e.g. one of [ \t\n\v\f\r]) must be quoted in the descriptor
+ boolean needsQuote = targetPath.toString().matches( ".*\\s+.*" );
+
+ if ( needsQuote )
+ {
+ sb.append( '"' );
+ }
+
sb.append( '/' );
sb.append( targetPath );
+ if ( needsQuote )
+ {
+ sb.append( '"' );
+ }
+
return sb.toString();
}
diff --git a/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/tools/install/JavaPackageTest.java b/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/tools/install/JavaPackageTest.java
index b0e6a56..2e791d7 100644
--- a/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/tools/install/JavaPackageTest.java
+++ b/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/tools/install/JavaPackageTest.java
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2014-2015 Red Hat, Inc.
+ * Copyright (c) 2014-2017 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -60,4 +60,33 @@ public class JavaPackageTest
new MetadataStaxReader().read( installRoot.resolve( metadataPath ).toString(), true );
assertEquals( "test-uuid", actualMetadata.getUuid() );
}
+
+ @Test
+ public void testSpacesInFileNames() throws Exception
+ {
+ JavaPackage pkg = new JavaPackage( "space-test",
+ Paths.get( "usr/share/maven-metadata/space-test.xml" ) );
+ pkg.addFile( new RegularFile(
+ Paths.get(
+ "usr/share/eclipse/droplets/space-test/plugins/space-test_1.0.0/META-INF/MANIFEST.MF" ),
+ new byte[0] ) );
+ pkg.addFile( new RegularFile(
+ Paths.get(
+ "usr/share/eclipse/droplets/space-test/plugins/space-test_1.0.0/file with spaces" ),
+ new byte[0] ) );
+ pkg.addFile( new RegularFile(
+ Paths.get(
+ "usr/share/eclipse/droplets/space-test/plugins/space-test_1.0.0/other\twhitespace" ),
+ new byte[0] ) );
+ pkg.addFile( new RegularFile(
+ Paths.get(
+ "usr/share/eclipse/droplets/space-test/plugins/space-test_1.0.0/other\u000Bwhitespace" ),
+ new byte[0] ) );
+ assertDescriptorEquals( pkg,
+ "%attr(0644,root,root) /usr/share/eclipse/droplets/space-test/plugins/space-test_1.0.0/META-INF/MANIFEST.MF",
+ "%attr(0644,root,root) \"/usr/share/eclipse/droplets/space-test/plugins/space-test_1.0.0/file with spaces\"",
+ "%attr(0644,root,root) \"/usr/share/eclipse/droplets/space-test/plugins/space-test_1.0.0/other\twhitespace\"",
+ "%attr(0644,root,root) \"/usr/share/eclipse/droplets/space-test/plugins/space-test_1.0.0/other\u000Bwhitespace\"",
+ "%attr(0644,root,root) /usr/share/maven-metadata/space-test.xml" );
+ }
}
--
2.9.3

View File

@ -8,7 +8,7 @@
Name: xmvn
Version: 2.5.0
Release: 15%{?dist}
Release: 16%{?dist}
Summary: Local Extensions for Apache Maven
License: ASL 2.0
URL: https://fedora-java.github.io/xmvn/
@ -19,6 +19,7 @@ Source0: https://github.com/fedora-java/xmvn/releases/download/%{version}
Patch0: 0001-Copy-core-dependencies-to-lib-core-in-assembly.patch
Patch1: 0002-Try-to-procect-builddep-MOJO-against-patological-cas.patch
Patch2: 0003-Don-t-install-POM-files-for-Tycho-projects.patch
Patch3: 0004-Allow-xmvn-to-install-files-who-names-whitespace.patch
BuildRequires: maven-lib >= 3.4.0
BuildRequires: maven-local
@ -196,6 +197,7 @@ This package provides %{summary}.
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%mvn_package ":xmvn{,-it}" __noinstall
@ -370,6 +372,9 @@ cp -P %{_datadir}/maven/bin/m2.conf %{buildroot}%{_datadir}/%{name}/bin/
%doc LICENSE NOTICE
%changelog
* Mon Jan 16 2017 Mikolaj Izdebski <mizdebsk@redhat.com> - 2.5.0-16
- Allow xmvn to install files who names whitespace
* Mon Aug 15 2016 Michael Simacek <msimacek@redhat.com> - 2.5.0-15
- Switch launcher scripts