diff options
author | John Arthorne | 2012-09-20 15:52:11 +0000 |
---|---|---|
committer | John Arthorne | 2012-09-20 15:52:11 +0000 |
commit | b1df469a2938fd2d98cba299ca8d9a88cbdaf0f9 (patch) | |
tree | 8f4cbad2585e4eb2b6a1cb3e4d43eaa779e570c8 | |
parent | 0f85cc10f6086cde746b969917a23ad5cd24d167 (diff) | |
download | rt.equinox.p2-20120920-155211.tar.gz rt.equinox.p2-20120920-155211.tar.xz rt.equinox.p2-20120920-155211.zip |
Revert "Bug 387557 - JarProcessor 'tampers' eclipse.inf of signed jars in some cases"v20120920-155211I20120925-0800I20120920-1300
This reverts commit ea959ede352a6b092680341160ceb851accf0924.
8 files changed, 36 insertions, 73 deletions
diff --git a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/CommandStep.java b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/CommandStep.java index d03a9f795..dde666095 100644 --- a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/CommandStep.java +++ b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/CommandStep.java @@ -62,8 +62,7 @@ public abstract class CommandStep implements IProcessStep { return options; } - public boolean adjustInf(File input, Properties inf, List containers) { - //do nothing by default - return false; + public void adjustInf(File input, Properties inf, List containers) { + //nothing } } diff --git a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/PackStep.java b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/PackStep.java index f85bb5584..bb4cac8c2 100644 --- a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/PackStep.java +++ b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/PackStep.java @@ -164,31 +164,30 @@ public class PackStep extends CommandStep { return "Pack"; //$NON-NLS-1$ } - public boolean adjustInf(File input, Properties inf, List containers) { + public void adjustInf(File input, Properties inf, List containers) { if (input == null || inf == null) - return false; + return; //don't be verbose to check if we should mark the inf boolean v = verbose; verbose = false; if (!shouldPack(input, containers, inf)) { verbose = v; - return false; + return; } verbose = v; //mark as conditioned if not previously marked. A signed jar is assumed to be previously conditioned. - if (inf.getProperty(Utils.MARK_PROPERTY) != null) - return false; - - inf.put(Utils.MARK_PROPERTY, "true"); //$NON-NLS-1$ - //record arguments used - String arguments = inf.getProperty(Utils.PACK_ARGS); - if (arguments == null) { - arguments = getArguments(input, inf, containers); - if (arguments != null && arguments.length() > 0) - inf.put(Utils.PACK_ARGS, arguments); + if (inf.getProperty(Utils.MARK_PROPERTY) == null) { + inf.put(Utils.MARK_PROPERTY, "true"); //$NON-NLS-1$ + + //record arguments used + String arguments = inf.getProperty(Utils.PACK_ARGS); + if (arguments == null) { + arguments = getArguments(input, inf, containers); + if (arguments != null && arguments.length() > 0) + inf.put(Utils.PACK_ARGS, arguments); + } } - return true; } } diff --git a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/internal/provisional/equinox/p2/jarprocessor/IProcessStep.java b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/internal/provisional/equinox/p2/jarprocessor/IProcessStep.java index e0bd05974..1479c4c32 100644 --- a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/internal/provisional/equinox/p2/jarprocessor/IProcessStep.java +++ b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/internal/provisional/equinox/p2/jarprocessor/IProcessStep.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2012 IBM Corporation and others. + * Copyright (c) 2006, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -59,7 +59,6 @@ public interface IProcessStep { * @param input * @param inf * @param containers inf properties for containing jars, innermost jar is first on the list - * @return <code>true</code> if the properties file was adjusted, and false othewise */ - public boolean adjustInf(File input, Properties inf, List containers); + public void adjustInf(File input, Properties inf, List containers); } diff --git a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/internal/provisional/equinox/p2/jarprocessor/JarProcessor.java b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/internal/provisional/equinox/p2/jarprocessor/JarProcessor.java index 5e6ec83e9..235915696 100644 --- a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/internal/provisional/equinox/p2/jarprocessor/JarProcessor.java +++ b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/internal/provisional/equinox/p2/jarprocessor/JarProcessor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2012 IBM Corporation and others. + * Copyright (c) 2006, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -256,13 +256,11 @@ public class JarProcessor { return input; } - private boolean adjustInf(File input, Properties inf) { - boolean adjusted = false; + private void adjustInf(File input, Properties inf) { for (Iterator iter = steps.iterator(); iter.hasNext();) { IProcessStep step = (IProcessStep) iter.next(); - adjusted |= step.adjustInf(input, inf, containingInfs); + step.adjustInf(input, inf, containingInfs); } - return adjusted; } public File processJar(File input) throws IOException { @@ -309,28 +307,25 @@ public class JarProcessor { Properties inf = Utils.getEclipseInf(workingFile, verbose); extractEntries(jar, tempDir, replacements, inf); - boolean infAdjusted = false; if (inf != null) - infAdjusted = adjustInf(workingFile, inf); + adjustInf(workingFile, inf); //Recreate the jar with replacements. - //This is not strictly necessary if we didn't change the inf file and didn't change any content - if (!replacements.isEmpty() || infAdjusted) { - File tempJar = null; - tempJar = new File(tempDir, workingFile.getName()); - File parent = tempJar.getParentFile(); - if (!parent.exists()) - parent.mkdirs(); - JarOutputStream jarOut = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(tempJar))); - recreateJar(jar, jarOut, replacements, tempDir, inf); - - jar.close(); - if (tempJar != null) { - if (!workingFile.equals(input)) { - workingFile.delete(); - } - workingFile = tempJar; + //TODO: This is not strictly necessary if we didn't change the inf file and didn't change any content + File tempJar = null; + tempJar = new File(tempDir, workingFile.getName()); + File parent = tempJar.getParentFile(); + if (!parent.exists()) + parent.mkdirs(); + JarOutputStream jarOut = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(tempJar))); + recreateJar(jar, jarOut, replacements, tempDir, inf); + + jar.close(); + if (tempJar != null) { + if (!workingFile.equals(input)) { + workingFile.delete(); } + workingFile = tempJar; } //post diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/Pack200ProcessorTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/Pack200ProcessorTest.java index b2b8f93b3..73c829551 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/Pack200ProcessorTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/Pack200ProcessorTest.java @@ -68,33 +68,4 @@ public class Pack200ProcessorTest extends TestCase { assertFalse(step.getStatus().isOK()); } - /** - * Tests the case where we are unpacking a file that was not packed by - * our own pack step. In this case the eclipse.inf may not be present - * and we must not attempt to modify it. - * @throws IOException - */ - public void testUnpackFileNotPackedByJarProcessor() throws IOException { - //this test is only applicable if pack200 is available - if (!PackStep.canPack()) - return; - // Setup the processor - ProcessingStep step = new Pack200ProcessorStep(); - ByteArrayOutputStream destination = new ByteArrayOutputStream(); - step.link(destination, new NullProgressMonitor()); - - // drive the source data through the step - Bundle bundle = TestActivator.getContext().getBundle(); - InputStream inputStream = bundle.getEntry("testData/optimizers/bug387557.bundle_1.0.0.201208200951.jar.pack.gz").openStream(); - FileUtils.copyStream(inputStream, true, step, true); - - // Get the expected result - inputStream = bundle.getEntry("testData/optimizers/bug387557.bundle_1.0.0.201208200951.jar").openStream(); - ByteArrayOutputStream expected = new ByteArrayOutputStream(); - FileUtils.copyStream(inputStream, true, expected, true); - - // Compare - assertTrue(Arrays.equals(expected.toByteArray(), destination.toByteArray())); - } - } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationArtifactTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationArtifactTest.java index 7b240a5ce..a79eb95ff 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationArtifactTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationArtifactTest.java @@ -344,7 +344,7 @@ public class NewMirrorApplicationArtifactTest extends AbstractProvisioningTest { fail(message + " descriptor mismatch"); if (!(expectedFile.exists() && actualFile.exists())) fail(message + " file does not exist"); - assertEquals("Unexpected difference in " + actualFile.getName(), expectedFile.length(), actualFile.length()); + assertTrue(expectedFile.length() == actualFile.length()); continue top; } } diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/bug387557.bundle_1.0.0.201208200951.jar b/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/bug387557.bundle_1.0.0.201208200951.jar Binary files differdeleted file mode 100644 index 842fc4f1e..000000000 --- a/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/bug387557.bundle_1.0.0.201208200951.jar +++ /dev/null diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/bug387557.bundle_1.0.0.201208200951.jar.pack.gz b/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/bug387557.bundle_1.0.0.201208200951.jar.pack.gz Binary files differdeleted file mode 100644 index 7ef9c7a98..000000000 --- a/bundles/org.eclipse.equinox.p2.tests/testData/optimizers/bug387557.bundle_1.0.0.201208200951.jar.pack.gz +++ /dev/null |