Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 133666 Details for
Bug 274181
[publisher] Jars don't have directory entries.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
potential patch
274181.txt (text/plain), 11.59 KB, created by
Andrew Niefer
on 2009-04-28 19:24:54 EDT
(
hide
)
Description:
potential patch
Filename:
MIME Type:
Creator:
Andrew Niefer
Created:
2009-04-28 19:24:54 EDT
Size:
11.59 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.equinox.p2.core >Index: src/org/eclipse/equinox/internal/p2/core/helpers/Messages.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/Messages.java,v >retrieving revision 1.4 >diff -u -r1.4 Messages.java >--- src/org/eclipse/equinox/internal/p2/core/helpers/Messages.java 30 Mar 2009 01:48:55 -0000 1.4 >+++ src/org/eclipse/equinox/internal/p2/core/helpers/Messages.java 28 Apr 2009 23:21:14 -0000 >@@ -27,5 +27,7 @@ > > public static String Util_Invalid_Zip_File_Format; > public static String Util_Error_Unzipping; >+ public static String Util_Empty_Zip_Entry; >+ public static String Util_Absolute_Entry; > > } >Index: src/org/eclipse/equinox/internal/p2/core/helpers/FileUtils.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/FileUtils.java,v >retrieving revision 1.15 >diff -u -r1.15 FileUtils.java >--- src/org/eclipse/equinox/internal/p2/core/helpers/FileUtils.java 20 Apr 2009 21:44:16 -0000 1.15 >+++ src/org/eclipse/equinox/internal/p2/core/helpers/FileUtils.java 28 Apr 2009 23:21:14 -0000 >@@ -12,6 +12,7 @@ > > import java.io.*; > import java.util.*; >+import java.util.jar.JarFile; > import java.util.zip.*; > import org.eclipse.core.runtime.*; > import org.eclipse.osgi.util.NLS; >@@ -243,10 +244,11 @@ > FileOutputStream fileOutput = new FileOutputStream(destinationArchive); > ZipOutputStream output = new ZipOutputStream(fileOutput); > HashSet exclusionSet = exclusions == null ? new HashSet() : new HashSet(Arrays.asList(exclusions)); >+ HashSet directoryEntries = new HashSet(); > try { > for (int i = 0; i < inclusions.length; i++) { > pathComputer.reset(); >- zip(output, inclusions[i], exclusionSet, pathComputer); >+ zip(output, inclusions[i], exclusionSet, pathComputer, directoryEntries); > } > } finally { > try { >@@ -272,26 +274,31 @@ > * @throws IOException > */ > public static void zip(ZipOutputStream output, File source, Set exclusions, IPathComputer pathComputer) throws IOException { >+ zip(output, source, exclusions, pathComputer, new HashSet()); >+ } >+ >+ public static void zip(ZipOutputStream output, File source, Set exclusions, IPathComputer pathComputer, Set directoryEntries) throws IOException { > if (exclusions.contains(source)) > return; > if (source.isDirectory()) //if the file path is a URL then isDir and isFile are both false >- zipDir(output, source, exclusions, pathComputer); >+ zipDir(output, source, exclusions, pathComputer, directoryEntries); > else >- zipFile(output, source, pathComputer); >+ zipFile(output, source, pathComputer, directoryEntries); > } > >- /* >- * Zip the contents of the given directory into the zip file represented by >- * the given zip stream. Prepend the given prefix to the file paths. >- */ >- private static void zipDir(ZipOutputStream output, File source, Set exclusions, IPathComputer pathComputer) throws IOException { >- File[] files = source.listFiles(); >- if (files.length == 0) { >+ private static void zipDirectoryEntry(ZipOutputStream output, IPath entry, long time, Set directoryEntries) { >+ entry = entry.addTrailingSeparator(); >+ if (!directoryEntries.contains(entry)) { >+ //make sure parent entries are in the zip >+ if (entry.segmentCount() > 1) >+ zipDirectoryEntry(output, entry.removeLastSegments(1), time, directoryEntries); >+ > try { >- ZipEntry dirEntry = new ZipEntry(pathComputer.computePath(source).toString() + "/"); //$NON-NLS-1$ >- dirEntry.setTime(source.lastModified()); >+ ZipEntry dirEntry = new ZipEntry(entry.toString()); >+ dirEntry.setTime(time); > output.putNextEntry(dirEntry); >- } catch (ZipException ze) { >+ directoryEntries.add(entry); >+ } catch (IOException ze) { > //TODO: something about duplicate entries > } finally { > try { >@@ -301,6 +308,17 @@ > } > } > } >+ } >+ >+ /* >+ * Zip the contents of the given directory into the zip file represented by >+ * the given zip stream. Prepend the given prefix to the file paths. >+ */ >+ private static void zipDir(ZipOutputStream output, File source, Set exclusions, IPathComputer pathComputer, Set directoryEntries) throws IOException { >+ File[] files = source.listFiles(); >+ if (files.length == 0) { >+ zipDirectoryEntry(output, pathComputer.computePath(source), source.lastModified(), directoryEntries); >+ } > > // Different OSs return files in a different order. This affects the creation > // the dynamic path computer. To address this, we sort the files such that >@@ -327,19 +345,31 @@ > }); > > for (int i = 0; i < files.length; i++) >- zip(output, files[i], exclusions, pathComputer); >+ zip(output, files[i], exclusions, pathComputer, directoryEntries); > } > > /* > * Add the given file to the zip file represented by the specified stream. > * Prepend the given prefix to the path of the file. > */ >- private static void zipFile(ZipOutputStream output, File source, IPathComputer pathComputer) throws IOException { >- InputStream input = new FileInputStream(source); >+ private static void zipFile(ZipOutputStream output, File source, IPathComputer pathComputer, Set directoryEntries) throws IOException { >+ boolean isManifest = false; //manifest files are special >+ InputStream input = new BufferedInputStream(new FileInputStream(source)); > try { > IPath entryPath = pathComputer.computePath(source); >+ if (entryPath.isAbsolute()) >+ throw new IOException(Messages.Util_Absolute_Entry); > if (entryPath.segmentCount() == 0) >- throw new IOException("Cannot have an empty zip entry."); //$NON-NLS-1$ >+ throw new IOException(Messages.Util_Empty_Zip_Entry); >+ >+ //make sure parent directory entries are in the zip >+ if (entryPath.segmentCount() > 1) { >+ //manifest files should be first, add their directory entry afterwards >+ isManifest = JarFile.MANIFEST_NAME.equals(entryPath.toString()); >+ if (!isManifest) >+ zipDirectoryEntry(output, entryPath.removeLastSegments(1), source.lastModified(), directoryEntries); >+ } >+ > ZipEntry zipEntry = new ZipEntry(entryPath.toString()); > zipEntry.setTime(source.lastModified()); > output.putNextEntry(zipEntry); >@@ -358,6 +388,10 @@ > // ignore > } > } >+ >+ if (isManifest) { >+ zipDirectoryEntry(output, new Path("META-INF"), source.lastModified(), directoryEntries); //$NON-NLS-1$ >+ } > } > > /** >Index: src/org/eclipse/equinox/internal/p2/core/helpers/messages.properties >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/messages.properties,v >retrieving revision 1.4 >diff -u -r1.4 messages.properties >--- src/org/eclipse/equinox/internal/p2/core/helpers/messages.properties 30 Mar 2009 01:48:55 -0000 1.4 >+++ src/org/eclipse/equinox/internal/p2/core/helpers/messages.properties 28 Apr 2009 23:21:14 -0000 >@@ -11,3 +11,6 @@ > > Util_Invalid_Zip_File_Format=Invalid zip file format > Util_Error_Unzipping=Error unzipping {0}: {1} >+ >+Util_Empty_Zip_Entry=Cannot have an empty zip entry. >+Util_Absolute_Entry=Zip entries cannot be absolute. >#P org.eclipse.equinox.p2.tests >Index: src/org/eclipse/equinox/p2/tests/core/FileUtilsTest.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/FileUtilsTest.java,v >retrieving revision 1.4 >diff -u -r1.4 FileUtilsTest.java >--- src/org/eclipse/equinox/p2/tests/core/FileUtilsTest.java 21 Apr 2009 23:40:07 -0000 1.4 >+++ src/org/eclipse/equinox/p2/tests/core/FileUtilsTest.java 28 Apr 2009 23:21:15 -0000 >@@ -108,6 +108,7 @@ > assertTrue("2.2", archive.length() > 0); > assertExists("2.3", archive, "a.txt"); > assertExists("2.4", archive, "b/b.txt"); >+ assertExists("2.5", archive, "b/"); > } > > public void testZipDynamicPathComputer() { >@@ -142,7 +143,9 @@ > assertTrue("3.1", archive.exists()); > assertTrue("3.2", archive.length() > 0); > assertExists("3.3", archive, "a2/a.txt"); >+ assertExists("3.3.1", archive, "a2/"); > assertExists("3.4", archive, "b/b.txt"); >+ assertExists("3.4.1", archive, "b/"); > > archive = new File(temp, getUniqueString() + ".zip"); > File[] input = new File[] {getTestData("4.0", "testData/core/x/y"), getTestData("4.0", "testData/core/z")}; >@@ -154,7 +157,9 @@ > assertTrue("4.1", archive.exists()); > assertTrue("4.2", archive.length() > 0); > assertExists("4.3", archive, "features/feature.txt"); >+ assertExists("4.3.1", archive, "features/"); > assertExists("4.4", archive, "plugins/bundle.txt"); >+ assertExists("4.4.1", archive, "plugins/"); > } > > public void testZipParentPrefixComputer() { >#P org.eclipse.pde.build.tests >Index: src/org/eclipse/pde/build/internal/tests/p2/PublishingTests.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/build/org.eclipse.pde.build.tests/src/org/eclipse/pde/build/internal/tests/p2/PublishingTests.java,v >retrieving revision 1.58 >diff -u -r1.58 PublishingTests.java >--- src/org/eclipse/pde/build/internal/tests/p2/PublishingTests.java 28 Apr 2009 21:10:36 -0000 1.58 >+++ src/org/eclipse/pde/build/internal/tests/p2/PublishingTests.java 28 Apr 2009 23:21:15 -0000 >@@ -41,8 +41,8 @@ > IFolder buildFolder = newTest("PublishBundle_simple"); > > IFolder bundle = Utils.createFolder(buildFolder, "plugins/bundle"); >- Utils.writeBuffer(bundle.getFile("src/A.java"), new StringBuffer("import b.B; public class A { B b = new B(); }")); >- Utils.writeBuffer(bundle.getFile("src/b/B.java"), new StringBuffer("package b; public class B { int i = 0; }")); >+ Utils.writeBuffer(bundle.getFile("src/A.java"), new StringBuffer("import b.c.d.B; public class A { B b = new B(); }")); >+ Utils.writeBuffer(bundle.getFile("src/b/c/d/B.java"), new StringBuffer("package b.c.d; public class B { int i = 0; }")); > Utils.writeBuffer(bundle.getFile("about.txt"), new StringBuffer("All about bundle.")); > Utils.writeBuffer(bundle.getFile("META-INF/p2.inf"), new StringBuffer("instructions.install=myRandomAction(foo: bar);")); > Properties properties = new Properties(); >@@ -75,7 +75,10 @@ > HashSet contents = new HashSet(); > contents.add("about.txt"); > contents.add("A.class"); >- contents.add("b/B.class"); >+ contents.add("b/"); >+ contents.add("b/c/"); >+ contents.add("b/c/d/"); >+ contents.add("b/c/d/B.class"); > assertZipContents(buildFolder, "buildRepo/plugins/bundle_1.0.0.v1234.jar", contents); > > IMetadataRepository repository = loadMetadataRepository("file:" + buildFolder.getFolder("buildRepo").getLocation().toOSString()); >@@ -292,9 +295,13 @@ > entries.add("about_files/about_cairo.html"); > entries.add("about_files/mpl-v11.txt"); > entries.add("about_files/pixman-licenses.txt"); >+ entries.add("about_files/"); > assertZipContents(buildFolder.getFolder("buildRepo/binary"), executable + "_root.gtk.linux.x86_" + version, entries); > >+ entries.add("Eclipse.app/"); >+ entries.add("Eclipse.app/Contents/"); > entries.add("Eclipse.app/Contents/Info.plist"); >+ entries.add("Eclipse.app/Contents/MacOS/"); > entries.add("Eclipse.app/Contents/MacOS/eclipse.ini"); > entries.add("Eclipse.app/Contents/MacOS/launcher"); > assertZipContents(buildFolder.getFolder("buildRepo/binary"), executable + "_root.carbon.macosx.ppc_" + version, entries);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 274181
: 133666