diff options
Diffstat (limited to 'bundles')
48 files changed, 5 insertions, 2072 deletions
diff --git a/bundles/ie.wombat.jbdiff.test/.classpath b/bundles/ie.wombat.jbdiff.test/.classpath deleted file mode 100644 index 751c8f2e5..000000000 --- a/bundles/ie.wombat.jbdiff.test/.classpath +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="output" path="bin"/> -</classpath> diff --git a/bundles/ie.wombat.jbdiff.test/.project b/bundles/ie.wombat.jbdiff.test/.project deleted file mode 100644 index ac8a8a03f..000000000 --- a/bundles/ie.wombat.jbdiff.test/.project +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>ie.wombat.jbdiff.test</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.ManifestBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.SchemaBuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.pde.PluginNature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> diff --git a/bundles/ie.wombat.jbdiff.test/.settings/org.eclipse.jdt.core.prefs b/bundles/ie.wombat.jbdiff.test/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index dc78f95cd..000000000 --- a/bundles/ie.wombat.jbdiff.test/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,12 +0,0 @@ -#Tue Dec 18 11:44:16 EST 2007 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.4 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning -org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning -org.eclipse.jdt.core.compiler.source=1.3 diff --git a/bundles/ie.wombat.jbdiff.test/.settings/org.eclipse.pde.core.prefs b/bundles/ie.wombat.jbdiff.test/.settings/org.eclipse.pde.core.prefs deleted file mode 100644 index 0c5082bd7..000000000 --- a/bundles/ie.wombat.jbdiff.test/.settings/org.eclipse.pde.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Thu Nov 01 14:26:02 CET 2007 -eclipse.preferences.version=1 -pluginProject.extensions=false -resolve.requirebundle=false diff --git a/bundles/ie.wombat.jbdiff.test/META-INF/MANIFEST.MF b/bundles/ie.wombat.jbdiff.test/META-INF/MANIFEST.MF deleted file mode 100644 index adc5f2301..000000000 --- a/bundles/ie.wombat.jbdiff.test/META-INF/MANIFEST.MF +++ /dev/null @@ -1,13 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: JBDiff Test Plug-in -Bundle-SymbolicName: ie.wombat.jbdiff.test -Bundle-Version: 0.1.0.qualifier -Bundle-Activator: ie.wombat.jbdiff.test.Activator -Import-Package: org.osgi.framework;version="1.3.0" -Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1, - J2SE-1.4 -Require-Bundle: org.junit, - ie.wombat.jbdiff -Automatic-Module-Name: ie.wombat.jbdiff.test diff --git a/bundles/ie.wombat.jbdiff.test/build.properties b/bundles/ie.wombat.jbdiff.test/build.properties deleted file mode 100644 index 34d2e4d2d..000000000 --- a/bundles/ie.wombat.jbdiff.test/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/bundles/ie.wombat.jbdiff.test/forceQualifierUpdate.txt b/bundles/ie.wombat.jbdiff.test/forceQualifierUpdate.txt deleted file mode 100644 index 56f1032a8..000000000 --- a/bundles/ie.wombat.jbdiff.test/forceQualifierUpdate.txt +++ /dev/null @@ -1,2 +0,0 @@ -# To force a version qualifier update add the bug here -Bug 403352 - Update all parent versions to match our build stream diff --git a/bundles/ie.wombat.jbdiff.test/pom.xml b/bundles/ie.wombat.jbdiff.test/pom.xml deleted file mode 100644 index efee50058..000000000 --- a/bundles/ie.wombat.jbdiff.test/pom.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.eclipse.equinox.p2</groupId> - <artifactId>rt.equinox.p2</artifactId> - <version>4.9.0-SNAPSHOT</version> - <relativePath>../..</relativePath> - </parent> - <groupId>ie.wombat.jbdiff</groupId> - <artifactId>ie.wombat.jbdiff.test</artifactId> - <version>0.1.0-SNAPSHOT</version> - <packaging>eclipse-test-plugin</packaging> -</project> diff --git a/bundles/ie.wombat.jbdiff.test/src/ie/wombat/jbdiff/test/Activator.java b/bundles/ie.wombat.jbdiff.test/src/ie/wombat/jbdiff/test/Activator.java deleted file mode 100644 index 0d0bb3f2a..000000000 --- a/bundles/ie.wombat.jbdiff.test/src/ie/wombat/jbdiff/test/Activator.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 compeople AG 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * compeople AG (Stefan Liebig) - initial API and implementation - *******************************************************************************/ -package ie.wombat.jbdiff.test; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; - -public class Activator implements BundleActivator { - - private static BundleContext context; - - /* - * (non-Javadoc) - * - * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - Activator.context = context; - } - - /* - * (non-Javadoc) - * - * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - Activator.context = null; - } - - /** - * @return the context - */ - public static BundleContext getContext() { - return context; - } - -} diff --git a/bundles/ie.wombat.jbdiff.test/src/ie/wombat/jbdiff/test/DiffPatchTest.java b/bundles/ie.wombat.jbdiff.test/src/ie/wombat/jbdiff/test/DiffPatchTest.java deleted file mode 100644 index 5f5e7d8f7..000000000 --- a/bundles/ie.wombat.jbdiff.test/src/ie/wombat/jbdiff/test/DiffPatchTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 compeople AG 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * compeople AG (Stefan Liebig) - initial API and implementation - *******************************************************************************/ -package ie.wombat.jbdiff.test; - -import ie.wombat.jbdiff.JBDiff; -import ie.wombat.jbdiff.JBPatch; - -import java.io.BufferedInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Arrays; - -import junit.framework.TestCase; - -public class DiffPatchTest extends TestCase { - - public void testNullData() throws Exception { - bench("null.data", "null.data"); - } - - public void testOneData() throws Exception { - bench("one.data", "one.data"); - } - - public void testOneHundredData() throws Exception { - bench("onehundred.data", "onehundred.data"); - } - - public void testOneHundredXData() throws Exception { - bench("onehundred.data", "onehundredX.data"); - } - - public void testOneXHundredXData() throws Exception { - bench("onehundred.data", "oneXhundredX.data"); - } - - public void testPdeCoreJar() throws Exception { - bench("org.eclipse.pde.core_3.2.jar", "org.eclipse.pde.core_3.3.jar"); - } - - public void testEclipse() throws Exception { - bench("eclipse-3.2.exe", "eclipse-3.3.exe"); - } - - private void bench(String resource1, String resource2) throws Exception { - - byte[] oldData = getTestData(resource1); - byte[] newData = getTestData(resource2); - - System.out.println(resource1 + "(" + (oldData.length / 1024) - + " kb) -> " + resource2 + "(" + (newData.length / 1024) - + " kb)"); - - diffAndPatchJBDiff(oldData, newData); - - System.out.println(""); - } - - /** - * @param resource1 - * @param resource2 - * @throws IOException - */ - private void diffAndPatchJBDiff(byte[] oldData, byte[] newData) - throws IOException { - - try { - - long start = System.currentTimeMillis(); - - byte[] diff = JBDiff.bsdiff(oldData, oldData.length, newData, - newData.length); - - long diffEnd = System.currentTimeMillis(); - - byte[] patch = JBPatch.bspatch(oldData, oldData.length, diff); - - long patchEnd = System.currentTimeMillis(); - - System.out.println("JBDiff: Size= " + diff.length + " b (" - + diff.length / 1024 + " kb), Diffing " + (diffEnd - start) - + " ms, Patching: " + (patchEnd - diffEnd) + " ms"); - - assertTrue(Arrays.equals(newData, patch)); - - } catch (RuntimeException re) { - System.err.println("JBDiff: error: " + re.getMessage()); - } - } - - private static byte[] getTestData(String name) throws IOException { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - InputStream input = new BufferedInputStream(Activator.getContext() - .getBundle().getEntry("testData/" + name).openStream()); - int r; - while ((r = input.read()) != -1) { - out.write(r); - } - input.close(); - out.close(); - return out.toByteArray(); - } -}
\ No newline at end of file diff --git a/bundles/ie.wombat.jbdiff.test/testData/eclipse-3.2.exe b/bundles/ie.wombat.jbdiff.test/testData/eclipse-3.2.exe Binary files differdeleted file mode 100644 index 7826d1ed8..000000000 --- a/bundles/ie.wombat.jbdiff.test/testData/eclipse-3.2.exe +++ /dev/null diff --git a/bundles/ie.wombat.jbdiff.test/testData/eclipse-3.3.exe b/bundles/ie.wombat.jbdiff.test/testData/eclipse-3.3.exe Binary files differdeleted file mode 100644 index c5cd8f038..000000000 --- a/bundles/ie.wombat.jbdiff.test/testData/eclipse-3.3.exe +++ /dev/null diff --git a/bundles/ie.wombat.jbdiff.test/testData/null.data b/bundles/ie.wombat.jbdiff.test/testData/null.data deleted file mode 100644 index e69de29bb..000000000 --- a/bundles/ie.wombat.jbdiff.test/testData/null.data +++ /dev/null diff --git a/bundles/ie.wombat.jbdiff.test/testData/one.data b/bundles/ie.wombat.jbdiff.test/testData/one.data deleted file mode 100644 index 56a6051ca..000000000 --- a/bundles/ie.wombat.jbdiff.test/testData/one.data +++ /dev/null @@ -1 +0,0 @@ -1
\ No newline at end of file diff --git a/bundles/ie.wombat.jbdiff.test/testData/oneXhundredX.data b/bundles/ie.wombat.jbdiff.test/testData/oneXhundredX.data deleted file mode 100644 index bb1077fd5..000000000 --- a/bundles/ie.wombat.jbdiff.test/testData/oneXhundredX.data +++ /dev/null @@ -1 +0,0 @@ -0123456789X0123456789X0123456789X0123456789X0123456789X0123456789X0123456789X0123456789X0123456789X0123456789X
\ No newline at end of file diff --git a/bundles/ie.wombat.jbdiff.test/testData/onehundred.data b/bundles/ie.wombat.jbdiff.test/testData/onehundred.data deleted file mode 100644 index edd4e96b7..000000000 --- a/bundles/ie.wombat.jbdiff.test/testData/onehundred.data +++ /dev/null @@ -1 +0,0 @@ -0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
\ No newline at end of file diff --git a/bundles/ie.wombat.jbdiff.test/testData/onehundredX.data b/bundles/ie.wombat.jbdiff.test/testData/onehundredX.data deleted file mode 100644 index cb96be8dd..000000000 --- a/bundles/ie.wombat.jbdiff.test/testData/onehundredX.data +++ /dev/null @@ -1 +0,0 @@ -012345678901234567890123456789012345678901234567890X234567890123456789012345678901234567890123456789
\ No newline at end of file diff --git a/bundles/ie.wombat.jbdiff.test/testData/org.eclipse.pde.core_3.2.jar b/bundles/ie.wombat.jbdiff.test/testData/org.eclipse.pde.core_3.2.jar Binary files differdeleted file mode 100644 index f772f865e..000000000 --- a/bundles/ie.wombat.jbdiff.test/testData/org.eclipse.pde.core_3.2.jar +++ /dev/null diff --git a/bundles/ie.wombat.jbdiff.test/testData/org.eclipse.pde.core_3.3.jar b/bundles/ie.wombat.jbdiff.test/testData/org.eclipse.pde.core_3.3.jar Binary files differdeleted file mode 100644 index a78ea76fa..000000000 --- a/bundles/ie.wombat.jbdiff.test/testData/org.eclipse.pde.core_3.3.jar +++ /dev/null diff --git a/bundles/ie.wombat.jbdiff/.classpath b/bundles/ie.wombat.jbdiff/.classpath deleted file mode 100644 index 751c8f2e5..000000000 --- a/bundles/ie.wombat.jbdiff/.classpath +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="output" path="bin"/> -</classpath> diff --git a/bundles/ie.wombat.jbdiff/.project b/bundles/ie.wombat.jbdiff/.project deleted file mode 100644 index 76d444192..000000000 --- a/bundles/ie.wombat.jbdiff/.project +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>ie.wombat.jbdiff</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.ManifestBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.SchemaBuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.pde.PluginNature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> diff --git a/bundles/ie.wombat.jbdiff/.settings/org.eclipse.core.resources.prefs b/bundles/ie.wombat.jbdiff/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index d46233b2e..000000000 --- a/bundles/ie.wombat.jbdiff/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Wed Nov 14 12:49:16 EST 2007 -eclipse.preferences.version=1 -encoding/<project>=ISO-8859-1 diff --git a/bundles/ie.wombat.jbdiff/.settings/org.eclipse.jdt.core.prefs b/bundles/ie.wombat.jbdiff/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index f99d27198..000000000 --- a/bundles/ie.wombat.jbdiff/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,12 +0,0 @@ -#Tue Dec 18 11:43:17 EST 2007 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.4 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning -org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning -org.eclipse.jdt.core.compiler.source=1.3 diff --git a/bundles/ie.wombat.jbdiff/.settings/org.eclipse.pde.core.prefs b/bundles/ie.wombat.jbdiff/.settings/org.eclipse.pde.core.prefs deleted file mode 100644 index 950e19447..000000000 --- a/bundles/ie.wombat.jbdiff/.settings/org.eclipse.pde.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Thu Nov 01 14:00:53 CET 2007 -eclipse.preferences.version=1 -pluginProject.extensions=false -resolve.requirebundle=false diff --git a/bundles/ie.wombat.jbdiff/META-INF/MANIFEST.MF b/bundles/ie.wombat.jbdiff/META-INF/MANIFEST.MF deleted file mode 100644 index 7faa6485f..000000000 --- a/bundles/ie.wombat.jbdiff/META-INF/MANIFEST.MF +++ /dev/null @@ -1,11 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Jbdiff Plug-in -Bundle-SymbolicName: ie.wombat.jbdiff -Bundle-Version: 0.1.0.qualifier -Import-Package: org.osgi.framework;version="1.3.0" -Bundle-ActivationPolicy: lazy -Export-Package: ie.wombat.jbdiff -Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1, - J2SE-1.4 -Automatic-Module-Name: ie.wombat.jbdiff diff --git a/bundles/ie.wombat.jbdiff/about.html b/bundles/ie.wombat.jbdiff/about.html deleted file mode 100644 index bf09c26d6..000000000 --- a/bundles/ie.wombat.jbdiff/about.html +++ /dev/null @@ -1,50 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> -<head> - - - <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> - - - <title>About</title> -</head> - - -<body lang="EN-US"> - -<h3>About This Content</h3> - -<p>June 5, 2006</p> - -<h3>License</h3> - -<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). - Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the - Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available - at <a href="http://www.eclipse.org/org/documents/epl-v10.php">http://www.eclipse.org/legal/epl-v10.html</a>. - For purposes of the EPL, "Program" will mean the Content.</p> - -<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is - being redistributed by another party ("Redistributor") and different terms and conditions may - apply to your use of any object code in the Content. Check the Redistributor’s license - that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise - indicated below, the terms and conditions of the EPL still apply to any source code in the Content - and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p> - -<h3>Third Party Content</h3> - -<p>The Content includes items that have been sourced from third parties as set out below. If you - did not receive this Content directly from the Eclipse Foundation, the following is provided - for informational purposes only, and you should look to the Redistributor’s license for - terms and conditions of use.</p> - -<em> -<h4>ie.wombat.jbdiff </h4> - -<p>This library version is based on JBDiff (<a href="http://www.wombat.ie/software/jbdiff/downloads/">http://www.wombat.ie/software/jbdiff/downloads/</a>) which is also available under the OSI Approved :: BSD License (original) <a href="http://www.opensource.org/licenses/bsd-license.html">http://www.opensource.org/licenses/bsd-license.html</a><br /> - -</p> - -</em> -</body> -</html> diff --git a/bundles/ie.wombat.jbdiff/build.properties b/bundles/ie.wombat.jbdiff/build.properties deleted file mode 100644 index 34d2e4d2d..000000000 --- a/bundles/ie.wombat.jbdiff/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/bundles/ie.wombat.jbdiff/forceQualifierUpdate.txt b/bundles/ie.wombat.jbdiff/forceQualifierUpdate.txt deleted file mode 100644 index 56f1032a8..000000000 --- a/bundles/ie.wombat.jbdiff/forceQualifierUpdate.txt +++ /dev/null @@ -1,2 +0,0 @@ -# To force a version qualifier update add the bug here -Bug 403352 - Update all parent versions to match our build stream diff --git a/bundles/ie.wombat.jbdiff/pom.xml b/bundles/ie.wombat.jbdiff/pom.xml deleted file mode 100644 index 8491dd628..000000000 --- a/bundles/ie.wombat.jbdiff/pom.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.eclipse.equinox.p2</groupId> - <artifactId>rt.equinox.p2</artifactId> - <version>4.9.0-SNAPSHOT</version> - <relativePath>../..</relativePath> - </parent> - <groupId>ie.wombat.jbdiff</groupId> - <artifactId>ie.wombat.jbdiff</artifactId> - <version>0.1.0-SNAPSHOT</version> - <packaging>eclipse-plugin</packaging> -</project> diff --git a/bundles/ie.wombat.jbdiff/src/ie/wombat/jbdiff/JBDiff.java b/bundles/ie.wombat.jbdiff/src/ie/wombat/jbdiff/JBDiff.java deleted file mode 100644 index 711fbd425..000000000 --- a/bundles/ie.wombat.jbdiff/src/ie/wombat/jbdiff/JBDiff.java +++ /dev/null @@ -1,612 +0,0 @@ -/* - * Copyright (c) 2005, Joe Desbonnet, (jdesbonnet@gmail.com) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the <organization> nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package ie.wombat.jbdiff; - -import java.io.BufferedInputStream; -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.zip.GZIPOutputStream; - -/** - * Java Binary Diff utility. Based on bsdiff (v4.2) by Colin Percival (see - * http://www.daemonology.net/bsdiff/ ) and distributed under BSD license. - * - * <p> - * Running this on large files will probably require an increase of the default - * maximum heap size (use java -Xmx200m) - * </p> - * - * @author Joe Desbonnet, joe@galway.net - * - */ -public class JBDiff { - - // JBDiff extensions by Stefan.Liebig@compeople.de: - // - // - uses GZIP compressor to compress ALL of the blocks (ctrl,diff,extra). - // - added interfaces that allows using of JBDiff with streams and byte - // arrays. - -// private static final String VERSION = "jbdiff-0.1.0.1"; - - // This is ´jbdiff40´. - private static final byte[] MAGIC_BYTES = new byte[] { 0x6a, 0x62, 0x64, - 0x69, 0x66, 0x66, 0x34, 0x30 }; - - private final static void split(int[] I, int[] V, int start, int len, int h) { - - int i, j, k, x, tmp, jj, kk; - - if (len < 16) { - for (k = start; k < start + len; k += j) { - j = 1; - x = V[I[k] + h]; - for (i = 1; k + i < start + len; i++) { - if (V[I[k + i] + h] < x) { - x = V[I[k + i] + h]; - j = 0; - } - - if (V[I[k + i] + h] == x) { - tmp = I[k + j]; - I[k + j] = I[k + i]; - I[k + i] = tmp; - j++; - } - - } - - for (i = 0; i < j; i++) { - V[I[k + i]] = k + j - 1; - } - if (j == 1) { - I[k] = -1; - } - } - - return; - } - - x = V[I[start + len / 2] + h]; - jj = 0; - kk = 0; - for (i = start; i < start + len; i++) { - if (V[I[i] + h] < x) { - jj++; - } - if (V[I[i] + h] == x) { - kk++; - } - } - - jj += start; - kk += jj; - - i = start; - j = 0; - k = 0; - while (i < jj) { - if (V[I[i] + h] < x) { - i++; - } else if (V[I[i] + h] == x) { - tmp = I[i]; - I[i] = I[jj + j]; - I[jj + j] = tmp; - j++; - } else { - tmp = I[i]; - I[i] = I[kk + k]; - I[kk + k] = tmp; - k++; - } - - } - - while (jj + j < kk) { - if (V[I[jj + j] + h] == x) { - j++; - } else { - tmp = I[jj + j]; - I[jj + j] = I[kk + k]; - I[kk + k] = tmp; - k++; - } - - } - - if (jj > start) { - split(I, V, start, jj - start, h); - } - - for (i = 0; i < kk - jj; i++) { - V[I[jj + i]] = kk - 1; - } - - if (jj == kk - 1) { - I[jj] = -1; - } - - if (start + len > kk) { - split(I, V, kk, start + len - kk, h); - } - - } - - /** - * Fast suffix sporting. Larsson and Sadakane's qsufsort algorithm. See - * http://www.cs.lth.se/Research/Algorithms/Papers/jesper5.ps - * - * @param I - * @param V - * @param oldBuf - * @param oldsize - */ - private static void qsufsort(int[] I, int[] V, byte[] oldBuf, int oldsize) { - - // int oldsize = oldBuf.length; - int[] buckets = new int[256]; - - // No need to do that in Java. - // for ( int i = 0; i < 256; i++ ) { - // buckets[i] = 0; - // } - - for (int i = 0; i < oldsize; i++) { - buckets[oldBuf[i] & 0xff]++; - } - - for (int i = 1; i < 256; i++) { - buckets[i] += buckets[i - 1]; - } - - for (int i = 255; i > 0; i--) { - buckets[i] = buckets[i - 1]; - } - - buckets[0] = 0; - - for (int i = 0; i < oldsize; i++) { - I[++buckets[oldBuf[i] & 0xff]] = i; - } - - I[0] = oldsize; - for (int i = 0; i < oldsize; i++) { - V[i] = buckets[oldBuf[i] & 0xff]; - } - V[oldsize] = 0; - - for (int i = 1; i < 256; i++) { - if (buckets[i] == buckets[i - 1] + 1) { - I[buckets[i]] = -1; - } - } - - I[0] = -1; - - for (int h = 1; I[0] != -(oldsize + 1); h += h) { - int len = 0; - int i; - for (i = 0; i < oldsize + 1;) { - if (I[i] < 0) { - len -= I[i]; - i -= I[i]; - } else { - // if(len) I[i-len]=-len; - if (len != 0) { - I[i - len] = -len; - } - len = V[I[i]] + 1 - i; - split(I, V, i, len, h); - i += len; - len = 0; - } - - } - - if (len != 0) { - I[i - len] = -len; - } - } - - for (int i = 0; i < oldsize + 1; i++) { - I[V[i]] = i; - } - } - - /** - * Count the number of bytes that match in oldBuf (starting at offset - * oldOffset) and newBuf (starting at offset newOffset). - * - * @param oldBuf - * @param oldOffset - * @param newBuf - * @param newOffset - * @return - */ - private final static int matchlen(byte[] oldBuf, int oldSize, - int oldOffset, byte[] newBuf, int newSize, int newOffset) { - // int end = Math - // .min(oldBuf.length - oldOffset, newBuf.length - newOffset); - int end = Math.min(oldSize - oldOffset, newSize - newOffset); - for (int i = 0; i < end; i++) { - if (oldBuf[oldOffset + i] != newBuf[newOffset + i]) { - return i; - } - } - return end; - } - - private final static int search(int[] I, byte[] oldBuf, int oldSize, - byte[] newBuf, int newSize, int newBufOffset, int start, int end, - IntByRef pos) { - - if (end - start < 2) { - int x = matchlen(oldBuf, oldSize, I[start], newBuf, newSize, - newBufOffset); - int y = matchlen(oldBuf, oldSize, I[end], newBuf, newSize, - newBufOffset); - - if (x > y) { - pos.value = I[start]; - return x; - } else { - pos.value = I[end]; - return y; - } - } - - int x = start + (end - start) / 2; - if (Util.memcmp(oldBuf, oldSize, I[x], newBuf, newSize, newBufOffset) < 0) { - return search(I, oldBuf, oldSize, newBuf, newSize, newBufOffset, x, - end, pos); - } else { - return search(I, oldBuf, oldSize, newBuf, newSize, newBufOffset, - start, x, pos); - } - - } - - /** - * @param oldFile - * @param newFile - * @param diffFile - * @throws IOException - */ - public static void bsdiff(File oldFile, File newFile, File diffFile) - throws IOException { - InputStream oldInputStream = new BufferedInputStream( - new FileInputStream(oldFile)); - InputStream newInputStream = new BufferedInputStream( - new FileInputStream(newFile)); - OutputStream diffOutputStream = new FileOutputStream(diffFile); - - byte[] diffBytes = bsdiff(oldInputStream, (int) oldFile.length(), - newInputStream, (int) newFile.length()); - - diffOutputStream.write(diffBytes); - diffOutputStream.close(); - } - - /** - * @param oldInputStream - * @param oldsize - * @param newInputStream - * @param newsize - * @return - * @throws IOException - */ - public static byte[] bsdiff(InputStream oldInputStream, int oldsize, - InputStream newInputStream, int newsize) throws IOException { - - byte[] oldBuf = new byte[oldsize]; - - Util.readFromStream(oldInputStream, oldBuf, 0, oldsize); - oldInputStream.close(); - - byte[] newBuf = new byte[newsize]; - Util.readFromStream(newInputStream, newBuf, 0, newsize); - newInputStream.close(); - - return bsdiff(oldBuf, oldsize, newBuf, newsize); - } - - /** - * @param oldBuf - * @param oldsize - * @param newBuf - * @param newsize - * @return - * @throws IOException - */ - public static byte[] bsdiff(byte[] oldBuf, int oldsize, byte[] newBuf, - int newsize) throws IOException { - - int[] I = new int[oldsize + 1]; - qsufsort(I, new int[oldsize + 1], oldBuf, oldsize); - - // diff block - int dblen = 0; - byte[] db = new byte[newsize]; - - // extra block - int eblen = 0; - byte[] eb = new byte[newsize]; - - /* - * Diff file is composed as follows: - * - * Header (32 bytes) Data (from offset 32 to end of file) - * - * Header: Offset 0, length 8 bytes: file magic "jbdiff40" Offset 8, - * length 8 bytes: length of compressed ctrl block Offset 16, length 8 - * bytes: length of compressed diff block Offset 24, length 8 bytes: - * length of new file - * - * Data: 32 (length ctrlBlockLen): ctrlBlock (bzip2) 32+ctrlBlockLen - * (length diffBlockLen): diffBlock (bzip2) 32+ctrlBlockLen+diffBlockLen - * (to end of file): extraBlock (bzip2) - * - * ctrlBlock comprises a set of records, each record 12 bytes. A record - * comprises 3 x 32 bit integers. The ctrlBlock is not compressed. - */ - - ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); - DataOutputStream diffOut = new DataOutputStream(byteOut); - - /* - * Write as much of header as we have now. Size of ctrlBlock and - * diffBlock must be filled in later. - */ - diffOut.write(MAGIC_BYTES); - diffOut.writeLong(-1); // place holder for ctrlBlockLen - diffOut.writeLong(-1); // place holder for diffBlockLen - diffOut.writeLong(newsize); - diffOut.flush(); - - GZIPOutputStream bzip2Out = new GZIPOutputStream(diffOut); - DataOutputStream dataOut = new DataOutputStream(bzip2Out); - - int oldscore, scsc; - - int overlap, Ss, lens; - int i; - int scan = 0; - int len = 0; - int lastscan = 0; - int lastpos = 0; - int lastoffset = 0; - - IntByRef pos = new IntByRef(); - // int ctrlBlockLen = 0; - - while (scan < newsize) { - oldscore = 0; - - for (scsc = scan += len; scan < newsize; scan++) { - - len = search(I, oldBuf, oldsize, newBuf, newsize, scan, 0, - oldsize, pos); - - for (; scsc < scan + len; scsc++) { - if ((scsc + lastoffset < oldsize) - && (oldBuf[scsc + lastoffset] == newBuf[scsc])) { - oldscore++; - } - } - - if (((len == oldscore) && (len != 0)) || (len > oldscore + 8)) { - break; - } - - if ((scan + lastoffset < oldsize) - && (oldBuf[scan + lastoffset] == newBuf[scan])) { - oldscore--; - } - } - - if ((len != oldscore) || (scan == newsize)) { - int s = 0; - int Sf = 0; - int lenf = 0; - for (i = 0; (lastscan + i < scan) && (lastpos + i < oldsize);) { - if (oldBuf[lastpos + i] == newBuf[lastscan + i]) - s++; - i++; - if (s * 2 - i > Sf * 2 - lenf) { - Sf = s; - lenf = i; - } - } - - int lenb = 0; - if (scan < newsize) { - s = 0; - int Sb = 0; - for (i = 1; (scan >= lastscan + i) && (pos.value >= i); i++) { - if (oldBuf[pos.value - i] == newBuf[scan - i]) - s++; - if (s * 2 - i > Sb * 2 - lenb) { - Sb = s; - lenb = i; - } - } - } - - if (lastscan + lenf > scan - lenb) { - overlap = (lastscan + lenf) - (scan - lenb); - s = 0; - Ss = 0; - lens = 0; - for (i = 0; i < overlap; i++) { - if (newBuf[lastscan + lenf - overlap + i] == oldBuf[lastpos - + lenf - overlap + i]) { - s++; - } - if (newBuf[scan - lenb + i] == oldBuf[pos.value - lenb - + i]) { - s--; - } - if (s > Ss) { - Ss = s; - lens = i + 1; - } - } - - lenf += lens - overlap; - lenb -= lens; - } - - // ? byte casting introduced here -- might affect things - for (i = 0; i < lenf; i++) { - db[dblen + i] = (byte) (newBuf[lastscan + i] - oldBuf[lastpos - + i]); - } - - for (i = 0; i < (scan - lenb) - (lastscan + lenf); i++) { - eb[eblen + i] = newBuf[lastscan + lenf + i]; - } - - dblen += lenf; - eblen += (scan - lenb) - (lastscan + lenf); - - /* - * Write control block entry (3 x int) - */ - // diffOut.writeInt( lenf ); - // diffOut.writeInt( ( scan - lenb ) - ( lastscan + lenf ) ); - // diffOut.writeInt( ( pos[0] - lenb ) - ( lastpos + lenf ) ); - // ctrlBlockLen += 12; - dataOut.writeInt(lenf); - dataOut.writeInt((scan - lenb) - (lastscan + lenf)); - dataOut.writeInt((pos.value - lenb) - (lastpos + lenf)); - - lastscan = scan - lenb; - lastpos = pos.value - lenb; - lastoffset = pos.value - scan; - } // end if - } // end while loop - - dataOut.flush(); - bzip2Out.finish(); - - // now compressed ctrlBlockLen - int ctrlBlockLen = diffOut.size() - Util.HEADER_SIZE; - // System.err.println( "Diff: ctrlBlockLen=" + ctrlBlockLen ); - - // GZIPOutputStream gzOut; - - /* - * Write diff block - */ - // gzOut = new GZIPOutputStream( diffOut ); - bzip2Out = new GZIPOutputStream(diffOut); - bzip2Out.write(db, 0, dblen); - bzip2Out.finish(); - bzip2Out.flush(); - int diffBlockLen = diffOut.size() - ctrlBlockLen - Util.HEADER_SIZE; - // System.err.println( "Diff: diffBlockLen=" + diffBlockLen ); - - /* - * Write extra block - */ - // gzOut = new GZIPOutputStream( diffOut ); - bzip2Out = new GZIPOutputStream(diffOut); - bzip2Out.write(eb, 0, eblen); - bzip2Out.finish(); - bzip2Out.flush(); - // long extraBlockLen = diffOut.size() - diffBlockLen - ctrlBlockLen - - // HEADER_SIZE; - // System.err.println( "Diff: extraBlockLen=" + extraBlockLen ); - - diffOut.close(); - - /* - * Write missing header info. - */ - ByteArrayOutputStream byteHeaderOut = new ByteArrayOutputStream( - Util.HEADER_SIZE); - DataOutputStream headerOut = new DataOutputStream(byteHeaderOut); - headerOut.write(MAGIC_BYTES); - headerOut.writeLong(ctrlBlockLen); // place holder for ctrlBlockLen - headerOut.writeLong(diffBlockLen); // place holder for diffBlockLen - headerOut.writeLong(newsize); - headerOut.close(); - - // Copy header information into the diff - byte[] diffBytes = byteOut.toByteArray(); - byte[] headerBytes = byteHeaderOut.toByteArray(); - - System.arraycopy(headerBytes, 0, diffBytes, 0, headerBytes.length); - - return diffBytes; - // /* - // * Write missing header info. Need to reopen the file with - // RandomAccessFile - // * for this. - // */ - // RandomAccessFile diff = new RandomAccessFile( diffFile, "rw" ); - // diff.seek( 8 ); - // diff.writeLong( ctrlBlockLen ); // ctrlBlockLen (compressed) @offset - // 8 - // diff.writeLong( diffBlockLen ); // diffBlockLen (compressed) @offset - // 16 - // diff.close(); - } - - /** - * Run JBDiff from the command line. Params: oldfile newfile difffile. diff - * file will be created. - * - * @param arg - * @throws IOException - */ - public static void main(String[] arg) throws IOException { - - if (arg.length != 3) { - System.err - .println("usage example: java -Xmx200m ie.wombat.jbdiff.JBDiff oldfile newfile patchfile\n"); - return; - } - - File oldFile = new File(arg[0]); - File newFile = new File(arg[1]); - File diffFile = new File(arg[2]); - - bsdiff(oldFile, newFile, diffFile); - - } - - private static class IntByRef { - private int value; - } -} diff --git a/bundles/ie.wombat.jbdiff/src/ie/wombat/jbdiff/JBPatch.java b/bundles/ie.wombat.jbdiff/src/ie/wombat/jbdiff/JBPatch.java deleted file mode 100644 index 7f91ecf1b..000000000 --- a/bundles/ie.wombat.jbdiff/src/ie/wombat/jbdiff/JBPatch.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright (c) 2005, Joe Desbonnet, (jdesbonnet@gmail.com) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the <organization> nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */package ie.wombat.jbdiff; - -import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; -import java.io.DataInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.zip.GZIPInputStream; - -/** - * Java Binary patcher (based on bspatch by Colin Percival) - * - * @author Joe Desbonnet, joe@galway.net - */ -public class JBPatch { - - // JBPatch extensions by Stefan.Liebig@compeople.de: - // - // - uses GZIP compressor to compress ALL of the blocks (ctrl,diff,extra). - // - added an interface that allows using of JBPatch with streams and byte - // arrays - -// private static final String VERSION = "jbdiff-0.1.0"; - - /** - * Run JBPatch from the command line. Params: oldfile newfile patchfile. - * newfile will be created. - * - * @param arg - * @throws IOException - */ - public static void main(String[] arg) throws IOException { - - if (arg.length != 3) { - System.err - .println("usage example: java -Xmx200m ie.wombat.jbdiff.JBPatch oldfile newfile patchfile"); - } - - File oldFile = new File(arg[0]); - File newFile = new File(arg[1]); - File diffFile = new File(arg[2]); - - bspatch(oldFile, newFile, diffFile); - } - - /** - * @param oldFile - * @param newFile - * @param diffFile - * @throws IOException - */ - public static void bspatch(File oldFile, File newFile, File diffFile) - throws IOException { - InputStream oldInputStream = new BufferedInputStream( - new FileInputStream(oldFile)); - byte[] diffBytes = new byte[(int) diffFile.length()]; - InputStream diffInputStream = new FileInputStream(diffFile); - Util.readFromStream(diffInputStream, diffBytes, 0, diffBytes.length); - - byte[] newBytes = bspatch(oldInputStream, (int) oldFile.length(), - diffBytes); - - OutputStream newOutputStream = new FileOutputStream(newFile); - newOutputStream.write(newBytes); - newOutputStream.close(); - } - - /** - * @param oldInputStream - * @param diffInputStream - * @return - */ - public static byte[] bspatch(InputStream oldInputStream, int oldsize, - byte[] diffBytes) throws IOException { - /* - * Read in old file (file to be patched) to oldBuf - */ - // int oldsize = (int) oldFile.length(); - // byte[] oldBuf = new byte[oldsize + 1]; - byte[] oldBuf = new byte[oldsize]; - // InputStream oldIn = new FileInputStream( oldFile ); - Util.readFromStream(oldInputStream, oldBuf, 0, oldsize); - oldInputStream.close(); - // oldIn.close(); - - return JBPatch.bspatch(oldBuf, oldsize, diffBytes); - } - - /** - * @param oldBuf - * @param oldsize - * @param diffBytes - * @return - * @throws IOException - */ - public static byte[] bspatch(byte[] oldBuf, int oldsize, byte[] diffBytes) - throws IOException { - return bspatch(oldBuf, oldsize, diffBytes, diffBytes.length); - } - - /** - * @param oldBuf - * @param oldsize - * @param diffBuf - * @param diffSize - * @return - * @throws IOException - */ - public static byte[] bspatch(byte[] oldBuf, int oldsize, byte[] diffBuf, - int diffSize) throws IOException { - - DataInputStream diffIn = new DataInputStream(new ByteArrayInputStream( - diffBuf, 0, diffSize)); - - // skip headerMagic at header offset 0 (length 8 bytes) - diffIn.skip(8); - - // ctrlBlockLen after bzip2 compression at heater offset 8 (length 8 - // bytes) - long ctrlBlockLen = diffIn.readLong(); - - // diffBlockLen after bzip2 compression at header offset 16 (length 8 - // bytes) - long diffBlockLen = diffIn.readLong(); - - // size of new file at header offset 24 (length 8 bytes) - int newsize = (int) diffIn.readLong(); - - // System.err.println( "newsize=" + newsize ); - // System.err.println( "ctrlBlockLen=" + ctrlBlockLen ); - // System.err.println( "diffBlockLen=" + diffBlockLen ); - // System.err.println( "newsize=" + newsize ); - - InputStream in; - in = new ByteArrayInputStream(diffBuf, 0, diffSize); - in.skip(Util.HEADER_SIZE); - DataInputStream ctrlBlockIn = new DataInputStream(new GZIPInputStream( - in)); - - in = new ByteArrayInputStream(diffBuf, 0, diffSize); - in.skip(ctrlBlockLen + Util.HEADER_SIZE); - InputStream diffBlockIn = new GZIPInputStream(in); - - in = new ByteArrayInputStream(diffBuf, 0, diffSize); - in.skip(diffBlockLen + ctrlBlockLen + Util.HEADER_SIZE); - InputStream extraBlockIn = new GZIPInputStream(in); - - // byte[] newBuf = new byte[newsize + 1]; - byte[] newBuf = new byte[newsize]; - - int oldpos = 0; - int newpos = 0; - int[] ctrl = new int[3]; - // int nbytes; - while (newpos < newsize) { - - for (int i = 0; i <= 2; i++) { - // ctrl[i] = diffIn.readInt(); - ctrl[i] = ctrlBlockIn.readInt(); - // System.err.println (" ctrl[" + i + "]=" + ctrl[i]); - } - - if (newpos + ctrl[0] > newsize) { - throw new IOException("Corrupt patch."); - } - - /* - * Read ctrl[0] bytes from diffBlock stream - */ - - Util.readFromStream(diffBlockIn, newBuf, newpos, ctrl[0]); - - for (int i = 0; i < ctrl[0]; i++) { - if ((oldpos + i >= 0) && (oldpos + i < oldsize)) { - newBuf[newpos + i] += oldBuf[oldpos + i]; - } - } - - newpos += ctrl[0]; - oldpos += ctrl[0]; - - if (newpos + ctrl[1] > newsize) { - throw new IOException("Corrupt patch."); - } - - Util.readFromStream(extraBlockIn, newBuf, newpos, ctrl[1]); - - newpos += ctrl[1]; - oldpos += ctrl[2]; - } - - // TODO: Check if at end of ctrlIn - // TODO: Check if at the end of diffIn - // TODO: Check if at the end of extraIn - - // This check is not needed since the byte array has been allocated with - // this constraint! - // if ( newBuf.length - 1 != newsize ) { - // throw new IOException( "Corrupt patch." ); - // } - - ctrlBlockIn.close(); - diffBlockIn.close(); - extraBlockIn.close(); - diffIn.close(); - - return newBuf; - // OutputStream out = new FileOutputStream( newFile ); - // out.write( newBuf, 0, newBuf.length - 1 ); - // out.close(); - } -} diff --git a/bundles/ie.wombat.jbdiff/src/ie/wombat/jbdiff/LICENSE.txt b/bundles/ie.wombat.jbdiff/src/ie/wombat/jbdiff/LICENSE.txt deleted file mode 100644 index 8b8b4d503..000000000 --- a/bundles/ie.wombat.jbdiff/src/ie/wombat/jbdiff/LICENSE.txt +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (c) 2005, Joe Desbonnet (jdesbonnet@gmail.com). -* Based on a direct translation of bsdiff utility by Colin Percival -* and available at http://www.daemonology.net/bsdiff/ under the -* same license. - -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the <organization> nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/
\ No newline at end of file diff --git a/bundles/ie.wombat.jbdiff/src/ie/wombat/jbdiff/README.txt b/bundles/ie.wombat.jbdiff/src/ie/wombat/jbdiff/README.txt deleted file mode 100644 index 82356621e..000000000 --- a/bundles/ie.wombat.jbdiff/src/ie/wombat/jbdiff/README.txt +++ /dev/null @@ -1,51 +0,0 @@ -README file for JBDiff (Java Binary Diff) -Version: 0.1.1 -Release date: 1 Oct 2007 - -JBDiff (Java Binary Diff) utility is a Java translation of the bsdiff (v4.2) utility -by Colin Percival. See http://www.daemonology.net/bsdiff/ - -The file format is similar to, but currently not compatible with the bsdiff utility. -This is because bsdiff uses bzip2 for compression which is not available in the -standard Java libraries. Instead I use gzip (java.util.zip.*) - -The diff utility is very memory hungry. Attempting to diff very large files with -insufficient RAM may cause your computer to 'trash' (ie become unusably slow and may -require a reset to recover). Comparing two 20MB files will take approx 80 seconds -on a 2GHz Pentium 4 and will require a maximum heap size of at least 220 MBytes. The -maximum heap size can be specified using the -Xmx switch to the Java VM (see examples -below). The patch utility has more modest resource requirements. - -EXAMPLES: - -To compare old.bin with new.bin and produce diff file new-old.diff: - -java -Xmx200m -classpath jbdiff.jar ie.wombat.jbdiff.JBDiff old.bin new.bin new-old.diff - -To patch old.bin with new-old.diff to produce new.bin: - -java -Xmx200m -classpath jbdiff.jar ie.wombat.jbdiff.JBPatch old.bin new.bin new-old.diff - -TODO: - -This first release is a rather blind port of the bsdiff utility. A vast bulk of -the code ported to Java without any modification. There is scope -for optimization (the C bsdiff runs in approx 50% faster than JBDiff). - -Also it would be nice to be able to produce output that is compatible with bsdiff. -I need a bzip2 library for that. - -Any suggestions, feedback and bugs will be much appreciated. Please email -to joe@galway.net - -LICENSE: - -Now available under BSD license (previously GPL). - -CHANGES SINCE 0.1.0 RELEASE: - -Change of license from GPL v2 to BSD license. - -Joe Desbonnet -jdesbonnet@gmail.com -1 Oct 2007 diff --git a/bundles/ie.wombat.jbdiff/src/ie/wombat/jbdiff/Util.java b/bundles/ie.wombat.jbdiff/src/ie/wombat/jbdiff/Util.java deleted file mode 100644 index 54d5eaf8d..000000000 --- a/bundles/ie.wombat.jbdiff/src/ie/wombat/jbdiff/Util.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2005, Joe Desbonnet, (jdesbonnet@gmail.com) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the <organization> nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package ie.wombat.jbdiff; - -import java.io.IOException; -import java.io.InputStream; - -/** - * @author - * @author Joe Desbonnet, joe@galway.net - * - */ -public class Util { - - // JBDiff extensions by Stefan.Liebig@compeople.de: - // - // - introduced a HEADER_SIZE constant here - - /** - * Length of the diff file header. - */ - public static final int HEADER_SIZE = 32; - - /** - * Equiv of C library memcmp(). - * - * @param s1 - * @param s1offset - * @param s2 - * @param n - * @return - */ - /* - * public final static int memcmp(byte[] s1, int s1offset, byte[] s2, int - * s2offset, int n) { - * - * if ((s1offset + n) > s1.length) { n = s1.length - s1offset; } if - * ((s2offset + n) > s2.length) { n = s2.length - s2offset; } for (int i = - * 0; i < n; i++) { if (s1[i + s1offset] != s2[i + s2offset]) { return s1[i + - * s1offset] < s2[i + s2offset] ? -1 : 1; } } - * - * return 0; } - */ - - /** - * Equiv of C library memcmp(). - * - * @param s1 - * @param s1offset - * @param s2 - * @param n - * @return - */ - public final static int memcmp(byte[] s1, int s1Size, int s1offset, - byte[] s2, int s2Size, int s2offset) { - - int n = s1Size - s1offset; - - if (n > (s2Size - s2offset)) { - n = s2Size - s2offset; - } - for (int i = 0; i < n; i++) { - if (s1[i + s1offset] != s2[i + s2offset]) { - return s1[i + s1offset] < s2[i + s2offset] ? -1 : 1; - } - } - - return 0; - // int n = s1.length - s1offset; - // - // if (n > (s2.length - s2offset)) { - // n = s2.length - s2offset; - // } - // for (int i = 0; i < n; i++) { - // if (s1[i + s1offset] != s2[i + s2offset]) { - // return s1[i + s1offset] < s2[i + s2offset] ? -1 : 1; - // } - // } - // - // return 0; - } - - /** - * Read from input stream and fill the given buffer from the given offset up - * to length len. - * - * @param in - * @param buf - * @param offset - * @param len - * @throws IOException - */ - public static final void readFromStream(InputStream in, byte[] buf, - int offset, int len) throws IOException { - - int totalBytesRead = 0; - while (totalBytesRead < len) { - int bytesRead = in.read(buf, offset + totalBytesRead, len - - totalBytesRead); - if (bytesRead < 0) { - throw new IOException( - "Could not read expected number of bytes."); - } - totalBytesRead += bytesRead; - } - } - -} diff --git a/bundles/ie.wombat.jbdiff/src/ie/wombat/jbdiff/readme-more.txt b/bundles/ie.wombat.jbdiff/src/ie/wombat/jbdiff/readme-more.txt deleted file mode 100644 index dd65be179..000000000 --- a/bundles/ie.wombat.jbdiff/src/ie/wombat/jbdiff/readme-more.txt +++ /dev/null @@ -1,7 +0,0 @@ -This library version is based on JBDiff (http://www.wombat.ie/software/jbdiff/downloads/jbdiff-0.1.1.tar.gz) -which is also available under the OSI Approved :: BSD License (original) -http://www.opensource.org/licenses/bsd-license.html - -Version 0.1.0.1 - - Extended interface so that it is not only file based and uses GZIP compressor for all data structures. - diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.artifact.optimizers/META-INF/MANIFEST.MF index 0bf5d65c0..aa3c74647 100644 --- a/bundles/org.eclipse.equinox.p2.artifact.optimizers/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.artifact.optimizers/META-INF/MANIFEST.MF @@ -8,14 +8,12 @@ Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: org.eclipse.equinox.internal.p2.artifact.optimizers;x-friends:="org.eclipse.equinox.p2.artifact.processors", org.eclipse.equinox.internal.p2.artifact.optimizers.jardelta;x-internal:=true, - org.eclipse.equinox.internal.p2.artifact.optimizers.jbdiff;x-internal:=true, org.eclipse.equinox.internal.p2.artifact.optimizers.pack200;x-internal:=true Require-Bundle: org.eclipse.equinox.common, org.eclipse.equinox.p2.artifact.repository Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-ActivationPolicy: lazy -Import-Package: ie.wombat.jbdiff, - org.eclipse.equinox.app;version="1.0.0", +Import-Package: org.eclipse.equinox.app;version="1.0.0", org.eclipse.equinox.internal.p2.core.helpers, org.eclipse.equinox.internal.p2.metadata, org.eclipse.equinox.internal.p2.sar, diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/plugin.xml b/bundles/org.eclipse.equinox.p2.artifact.optimizers/plugin.xml index fb0e4f618..19b064544 100644 --- a/bundles/org.eclipse.equinox.p2.artifact.optimizers/plugin.xml +++ b/bundles/org.eclipse.equinox.p2.artifact.optimizers/plugin.xml @@ -13,12 +13,6 @@ </application> </extension> - <extension id="jbdiffoptimizer" point="org.eclipse.core.runtime.applications"> - <application> - <run class="org.eclipse.equinox.internal.p2.artifact.optimizers.jbdiff.Application"/> - </application> - </extension> - <extension id="Pack200Optimizer" point="org.eclipse.equinox.p2.artifact.repository.processingSteps"> <step class="org.eclipse.equinox.internal.p2.artifact.optimizers.pack200.Pack200OptimizerStep"/> </extension> @@ -27,12 +21,4 @@ <step class="org.eclipse.equinox.internal.p2.artifact.optimizers.jardelta.JarDeltaOptimizerStep"/> </extension> - <extension id="JBDiffStep" point="org.eclipse.equinox.p2.artifact.repository.processingSteps"> - <step class="org.eclipse.equinox.internal.p2.artifact.optimizers.jbdiff.JBDiffStep"/> - </extension> - - <extension id="JBDiffZipStep" point="org.eclipse.equinox.p2.artifact.repository.processingSteps"> - <step class="org.eclipse.equinox.internal.p2.artifact.optimizers.jbdiff.JBDiffZipStep"/> - </extension> - </plugin> diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/Application.java b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/Application.java deleted file mode 100644 index 5ccc054b2..000000000 --- a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/Application.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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 http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - ******************************************************************************/ -package org.eclipse.equinox.internal.p2.artifact.optimizers.jbdiff; - -import java.net.URI; -import java.util.Map; -import org.eclipse.equinox.app.IApplicationContext; -import org.eclipse.equinox.internal.p2.artifact.optimizers.OptimizerApplication; -import org.eclipse.equinox.p2.core.ProvisionException; -import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; -import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; - -/** - * The optimizer <code>Application</code> for JBDiff based optimizations. - */ -public class Application extends OptimizerApplication { - - private URI artifactRepositoryLocation; - private int width = 1; - private int depth = 1; - private boolean nosar; - - public Object start(IApplicationContext context) throws Exception { - Map<?, ?> args = context.getArguments(); - initializeFromArguments((String[]) args.get("application.args")); //$NON-NLS-1$ - IArtifactRepository repository = setupRepository(artifactRepositoryLocation); - new Optimizer(repository, width, depth, nosar).run(); - return null; - } - - private IArtifactRepository setupRepository(URI location) throws ProvisionException { - IArtifactRepositoryManager manager = getArtifactRepositoryManager(); - if (manager == null) - // TODO log here - return null; - return manager.loadRepository(location, null); - } - - public void initializeFromArguments(String[] args) throws Exception { - if (args == null) - return; - for (int i = 0; i < args.length; i++) { - // check for args without parameters (i.e., a flag arg) - // if (args[i].equals("-pack")) - // pack = true; - - if (args[i].equals("-nosar")) //$NON-NLS-1$ - nosar = true; - - // check for args with parameters. If we are at the last argument or - // if the next one has a '-' as the first character, then we can't have - // an arg with a param so continue. - if (i == args.length - 1 || args[i + 1].startsWith("-")) //$NON-NLS-1$ - continue; - String arg = args[++i]; - - if (args[i - 1].equalsIgnoreCase("-artifactRepository") || args[i - 1].equalsIgnoreCase("-ar")) //$NON-NLS-1$ //$NON-NLS-2$ - artifactRepositoryLocation = new URI(arg); - - if (args[i - 1].equalsIgnoreCase("-depth")) //$NON-NLS-1$ - depth = Integer.parseInt(arg); - - if (args[i - 1].equalsIgnoreCase("-width")) //$NON-NLS-1$ - width = Integer.parseInt(arg); - - } - } -} diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/JBDiffStep.java b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/JBDiffStep.java deleted file mode 100644 index 1a18338b6..000000000 --- a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/JBDiffStep.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 compeople AG 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * compeople AG (Stefan Liebig) - initial API and implementation - * IBM Corporation - ongoing development - *******************************************************************************/ -package org.eclipse.equinox.internal.p2.artifact.optimizers.jbdiff; - -import ie.wombat.jbdiff.JBDiff; -import java.io.*; -import org.eclipse.equinox.internal.p2.artifact.optimizers.AbstractDeltaStep; -import org.eclipse.equinox.internal.p2.core.helpers.FileUtils; -import org.eclipse.equinox.internal.p2.sar.DirectByteArrayOutputStream; -import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; -import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor; - -/** - * - */ -public class JBDiffStep extends AbstractDeltaStep { - - public JBDiffStep() { - super(); - } - - // TODO We need a different way of injecting the base artifacts. This approach forces - // the target and base to live in the same repo. Typical but not really required. - protected JBDiffStep(IArtifactRepository repository) { - super(repository); - } - - protected OutputStream createIncomingStream() throws IOException { - return new DirectByteArrayOutputStream(); - } - - protected void performProcessing() throws IOException { - DirectByteArrayOutputStream predecessor = fetchPredecessorBytes(new ArtifactDescriptor(key)); - DirectByteArrayOutputStream current = (DirectByteArrayOutputStream) incomingStream; - byte[] diff = JBDiff.bsdiff(predecessor.getBuffer(), predecessor.getBufferLength(), current.getBuffer(), current.getBufferLength()); - // free up the memory as soon as possible. - predecessor = null; - current = null; - incomingStream = null; - - // copy the result of the optimization to the destination. - FileUtils.copyStream(new ByteArrayInputStream(diff), true, getDestination(), false); - } - - private DirectByteArrayOutputStream fetchPredecessorBytes(ArtifactDescriptor artifactDescriptor) throws IOException { - DirectByteArrayOutputStream result = new DirectByteArrayOutputStream(); - setStatus(repository.getArtifact(artifactDescriptor, result, getProgressMonitor())); - if (!getStatus().isOK()) - throw (IOException) new IOException(getStatus().getMessage()).initCause(getStatus().getException()); - return result; - } -} diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/JBDiffZipStep.java b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/JBDiffZipStep.java deleted file mode 100644 index 98919ba51..000000000 --- a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/JBDiffZipStep.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 compeople AG 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * compeople AG (Stefan Liebig) - initial API and implementation - * IBM Corporation - ongoing development - *******************************************************************************/ -package org.eclipse.equinox.internal.p2.artifact.optimizers.jbdiff; - -import ie.wombat.jbdiff.JBDiff; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import org.eclipse.equinox.internal.p2.core.helpers.FileUtils; -import org.eclipse.equinox.internal.p2.sar.DirectByteArrayOutputStream; -import org.eclipse.equinox.internal.p2.sar.SarUtil; -import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; -import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor; - -public class JBDiffZipStep extends JBDiffStep { - - public JBDiffZipStep() { - super(); - } - - // TODO We need a different way of injecting the base artifacts. This approach forces - // the target and base to live in the same repo. Typical but not really required. - protected JBDiffZipStep(IArtifactRepository repository) { - super(repository); - } - - protected void performProcessing() throws IOException { - DirectByteArrayOutputStream sarredCurrent = new DirectByteArrayOutputStream(); - SarUtil.zipToSar(((DirectByteArrayOutputStream) incomingStream).getInputStream(), sarredCurrent); - incomingStream = null; - DirectByteArrayOutputStream predecessor = fetchPredecessorBytes(new ArtifactDescriptor(key)); - byte[] diff = JBDiff.bsdiff(predecessor.getBuffer(), predecessor.getBufferLength(), sarredCurrent.getBuffer(), sarredCurrent.getBufferLength()); - // free up the memory as soon as possible. - predecessor = null; - incomingStream = null; - sarredCurrent = null; - - // copy the result of the optimization to the destination. - FileUtils.copyStream(new ByteArrayInputStream(diff), true, getDestination(), false); - } - - private DirectByteArrayOutputStream fetchPredecessorBytes(ArtifactDescriptor artifactDescriptor) throws IOException { - DirectByteArrayOutputStream zippedPredecessor = new DirectByteArrayOutputStream(); - - setStatus(repository.getArtifact(artifactDescriptor, zippedPredecessor, getProgressMonitor())); - if (!getStatus().isOK()) - throw (IOException) new IOException(getStatus().getMessage()).initCause(getStatus().getException()); - - DirectByteArrayOutputStream result = new DirectByteArrayOutputStream(); - SarUtil.zipToSar(zippedPredecessor.getInputStream(), result); - return result; - } - -} diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/Optimizer.java b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/Optimizer.java deleted file mode 100644 index 994e0f7cf..000000000 --- a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/jbdiff/Optimizer.java +++ /dev/null @@ -1,280 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 compeople AG 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * compeople AG (Stefan Liebig) - initial API and implementation - * IBM Corporation - ongoing development - *******************************************************************************/ -package org.eclipse.equinox.internal.p2.artifact.optimizers.jbdiff; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.*; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.equinox.internal.p2.artifact.optimizers.VersionlessArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStep; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepHandler; -import org.eclipse.equinox.p2.core.ProvisionException; -import org.eclipse.equinox.p2.metadata.IArtifactKey; -import org.eclipse.equinox.p2.query.IQueryResult; -import org.eclipse.equinox.p2.repository.artifact.*; -import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor; -import org.eclipse.equinox.p2.repository.artifact.spi.ProcessingStepDescriptor; - -public class Optimizer { - - private IArtifactRepository repository; - private int width; - private int depth; - private boolean nosar; - - private static final String JBPATCH_STEP_ID = "org.eclipse.equinox.p2.repository.JBPatchStep"; //$NON-NLS-1$ - private static final String JBPATCH_STEP_ZIP_ID = "org.eclipse.equinox.p2.repository.JBPatchZipStep"; //$NON-NLS-1$ - - private static final Comparator<IArtifactDescriptor> ARTIFACT_DESCRIPTOR_VERSION_COMPARATOR = new ArtifactDescriptorVersionComparator(); - private static final Comparator<IArtifactKey> ARTIFACT_KEY_VERSION_COMPARATOR = new ArtifactKeyVersionComparator(); - - /** - * This optimizer performs delta generation based on (currently) jbdiff. - * The optimization can be controlled with the ´width´ and the ´depth´ parameter. - * ´width´ defines for how many ´related´ artifact keys a delta should be generated, - * starting from the most up-to-date. - * ´depth´ defines to how many predecessor a delta should be generated. - * - * With AK(c-v) : AK - artifact key, c - artifact id, v - artifact version - * the ´repository content´ can be viewed a two dimensional array, where the - * artifact keys for the same component are in order of their version: - * <pre><code> - * w=1 w=2 - * | | - * | +------.------------+ d=2 - * | | +----.---+ d=1 | - * | | | | | v - * [ v | | v v v - * [ AK(x,2.0) AK(x,1.5) AK(x,1.1) ] - * [ AK(y,2.0) AK(y,1.9) ] - * [ AK(z,2.0) AK(z,1.5) AK(z,1.3) AK(z,1.0) ] - * ] - * </code></pre> - * E.g: with a ´width´ of one and a ´depth´ of two the optimizer would - * create two deltas for component ´x´ from 1.5 to 2.0 and from 1.1 to 2.0. - * - * @param repository - * @param width - * @param depth - * @param nosar - */ - public Optimizer(IArtifactRepository repository, int width, int depth, boolean nosar) { - this.repository = repository; - this.width = width; - this.depth = depth; - this.nosar = nosar; - } - - public void run() { - System.out.println("Starting delta (jbdiff) optimizations (width=" + width + ", depth=" + depth + ", nosar=" + nosar + ")"); - IQueryResult<IArtifactKey> queryResult = repository.query(ArtifactKeyQuery.ALL_KEYS, null); - IArtifactKey[][] keys = getSortedRelatedArtifactKeys(queryResult); - for (int i = 0; i < keys.length; i++) { - if (keys[i].length < 2) - // Nothing to diff here! - continue; - int minWidth = Math.min(width, keys[i].length); - for (int j = 0; j < minWidth; j++) { - IArtifactKey key = keys[i][j]; - boolean isArchive = key.getClassifier().equals("plugin"); //$NON-NLS-1$ - String proposedStrategy = isArchive && !nosar ? JBPATCH_STEP_ZIP_ID : JBPATCH_STEP_ID; - optimize(keys[i], key, proposedStrategy); - } - } - System.out.println("Done."); - - } - - private void optimize(IArtifactKey[] keys, IArtifactKey key, String proposedStrategy) throws OutOfMemoryError { - boolean retry; - do { - retry = false; - try { - IArtifactDescriptor[] descriptors = repository.getArtifactDescriptors(key); - IArtifactDescriptor complete = null; - for (int k = 0; k < descriptors.length; k++) { - IArtifactDescriptor descriptor = descriptors[k]; - if (isCanonical(descriptor)) - complete = descriptor; - else if (isOptimized(descriptor, proposedStrategy)) { - proposedStrategy = null; - break; - } - } - if (proposedStrategy != null && complete != null) - optimize(complete, proposedStrategy, keys); - } catch (OutOfMemoryError e) { - if (JBPATCH_STEP_ID.equals(proposedStrategy)) - throw e; - proposedStrategy = JBPATCH_STEP_ID; - System.out.println("Retry with " + proposedStrategy); - retry = true; - } - } while (retry); - } - - /** - * This method retrieves a list of list of IArtifactKeys. The artifact keys in the - * list of artifact keys are all ´strongly related´ to each other such that are - * equal but not considering the versions. This list is sorted such that the - * newer versions are first in the list.<p> - * With AK(c-v) : AK - artifact key, c - artifact id, v - artifact version - * the result is than, e.g. - * <pre><code> - * [ - * [ AK(x,2.0) AK(x,1.5) AK(x,1.1) ] - * [ AK(y,2.0) AK(y,1.9) ] - * [ AK(z,2.0) AK(z,1.5) AK(z,1.3) AK(z,1.0) ] - * ] - * </code></pre> - * @param artifactKeys - * @return the sorted artifact keys - */ - private IArtifactKey[][] getSortedRelatedArtifactKeys(IQueryResult<IArtifactKey> artifactKeys) { - Map<IArtifactKey, List<IArtifactKey>> map = new HashMap<IArtifactKey, List<IArtifactKey>>(); - for (Iterator<IArtifactKey> iter = artifactKeys.iterator(); iter.hasNext();) { - IArtifactKey nxt = iter.next(); - IArtifactKey freeKey = new VersionlessArtifactKey(nxt); - List<IArtifactKey> values = map.get(freeKey); - if (values == null) { - values = new ArrayList<IArtifactKey>(); - map.put(freeKey, values); - } - values.add(nxt); - } - IArtifactKey[][] lists = new IArtifactKey[map.size()][]; - int i = 0; - for (List<IArtifactKey> artifactKeyList : map.values()) { - IArtifactKey[] relatedArtifactKeys = artifactKeyList.toArray(new IArtifactKey[artifactKeyList.size()]); - Arrays.sort(relatedArtifactKeys, ARTIFACT_KEY_VERSION_COMPARATOR); - lists[i++] = relatedArtifactKeys; - } - int candidates = 0; - for (int ii = 0; ii < lists.length; ii++) { - for (int jj = 0; jj < lists[ii].length; jj++) { - System.out.println(lists[ii][jj] + ", "); - } - System.out.println(""); - if (lists[ii].length > 1) - candidates++; - } - System.out.println("Candidates found: " + candidates); - return lists; - } - - private void optimize(IArtifactDescriptor complete, String strategy, IArtifactKey[] relatedArtifactKeys) { - System.out.println("Optimizing " + complete); - - IArtifactDescriptor[] descriptors = getSortedCompletePredecessors(complete.getArtifactKey(), relatedArtifactKeys); - - int minDepth = Math.min(depth, descriptors.length); - for (int i = 0; i < minDepth; i++) { - - System.out.println("\t with " + strategy + " against " + descriptors[i].getArtifactKey()); - String predecessorData = descriptors[i].getArtifactKey().toExternalForm(); - ArtifactDescriptor newDescriptor = new ArtifactDescriptor(complete); - IProcessingStepDescriptor patchStep = new ProcessingStepDescriptor(strategy, predecessorData, true); - IProcessingStepDescriptor[] steps = new IProcessingStepDescriptor[] {patchStep}; - newDescriptor.setProcessingSteps(steps); - newDescriptor.setProperty(IArtifactDescriptor.FORMAT, strategy); - OutputStream repositoryStream = null; - try { - repositoryStream = repository.getOutputStream(newDescriptor); - - // Add in all the processing steps needed to optimize (e.g., pack200, ...) - ProcessingStep diffStep = getProcessingStep(strategy); - diffStep.initialize(repository.getProvisioningAgent(), patchStep, newDescriptor); - ProcessingStepHandler handler = new ProcessingStepHandler(); - OutputStream destination = handler.link(new ProcessingStep[] {diffStep}, repositoryStream, null); - - // Do the actual work by asking the repo to get the artifact and put it in the destination. - IStatus status = repository.getArtifact(complete, destination, new NullProgressMonitor()); - if (!status.isOK()) { - System.out.println("Getting the artifact is not ok."); //$NON-NLS-1$ - System.out.println(status); - } - } catch (ProvisionException e) { - System.out.println("Skipping optimization of: " + descriptors[i].getArtifactKey()); //$NON-NLS-1$ - System.out.println(e.getMessage()); - e.printStackTrace(); - } finally { - if (repositoryStream != null) - try { - repositoryStream.close(); - IStatus status = ProcessingStepHandler.checkStatus(repositoryStream); - if (!status.isOK()) { - System.out.println("Skipping optimization of: " + descriptors[i].getArtifactKey()); //$NON-NLS-1$ - System.out.println(status.toString()); - } - } catch (IOException e) { - System.out.println("Skipping optimization of: " + descriptors[i].getArtifactKey()); //$NON-NLS-1$ - System.out.println(e.getMessage()); - e.printStackTrace(); - } - } - } - } - - private ProcessingStep getProcessingStep(String strategy) { - if (strategy.equals(JBPATCH_STEP_ID)) - return new JBDiffStep(repository); - return new JBDiffZipStep(repository); - } - - private IArtifactDescriptor[] getSortedCompletePredecessors(IArtifactKey artifactKey, IArtifactKey[] relatedArtifactKeys) { - // get all artifact keys - List<IArtifactDescriptor> completeDescriptors = new ArrayList<IArtifactDescriptor>(relatedArtifactKeys.length); - for (int i = 0; i < relatedArtifactKeys.length; i++) { - // if we find ´our self´ skip - if (relatedArtifactKeys[i].equals(artifactKey)) - continue; - // look for a complete artifact descriptor of the current key - IArtifactDescriptor[] descriptors = repository.getArtifactDescriptors(relatedArtifactKeys[i]); - for (int j = 0; j < descriptors.length; j++) { - if (isCanonical(descriptors[j])) { - completeDescriptors.add(descriptors[j]); - break; - } - } - } - - IArtifactDescriptor[] completeSortedDescriptors = completeDescriptors.toArray(new IArtifactDescriptor[completeDescriptors.size()]); - // Sort, so to allow a depth lookup! - Arrays.sort(completeSortedDescriptors, ARTIFACT_DESCRIPTOR_VERSION_COMPARATOR); - return completeSortedDescriptors; - } - - private boolean isOptimized(IArtifactDescriptor descriptor, String stepId) { - if (descriptor.getProcessingSteps().length != 1) - return false; - return stepId.equals(descriptor.getProcessingSteps()[0].getProcessorId()); - } - - private boolean isCanonical(IArtifactDescriptor descriptor) { - // TODO length != 0 is not necessarily an indicator for not being complete! - return descriptor.getProcessingSteps().length == 0; - } - - static final class ArtifactDescriptorVersionComparator implements Comparator<IArtifactDescriptor> { - public int compare(IArtifactDescriptor artifactDescriptor0, IArtifactDescriptor artifactDescriptor1) { - return -1 * artifactDescriptor0.getArtifactKey().getVersion().compareTo(artifactDescriptor1.getArtifactKey().getVersion()); - } - } - - static final class ArtifactKeyVersionComparator implements Comparator<IArtifactKey> { - public int compare(IArtifactKey artifactKey0, IArtifactKey artifactKey1) { - return -1 * artifactKey0.getVersion().compareTo(artifactKey1.getVersion()); - } - } -} diff --git a/bundles/org.eclipse.equinox.p2.artifact.processors/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.artifact.processors/META-INF/MANIFEST.MF index 30c284123..aa28a13ec 100644 --- a/bundles/org.eclipse.equinox.p2.artifact.processors/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.artifact.processors/META-INF/MANIFEST.MF @@ -7,14 +7,12 @@ Bundle-Activator: org.eclipse.equinox.internal.p2.artifact.processors.Activator Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: org.eclipse.equinox.internal.p2.artifact.processors;x-internal:=true, - org.eclipse.equinox.internal.p2.artifact.processors.jardelta;x-internal:=true, - org.eclipse.equinox.internal.p2.artifact.processors.jbdiff;x-internal:=true + org.eclipse.equinox.internal.p2.artifact.processors.jardelta;x-internal:=true Require-Bundle: org.eclipse.equinox.common, org.eclipse.equinox.p2.artifact.repository Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-ActivationPolicy: lazy -Import-Package: ie.wombat.jbdiff, - org.eclipse.equinox.internal.p2.artifact.optimizers, +Import-Package: org.eclipse.equinox.internal.p2.artifact.optimizers, org.eclipse.equinox.internal.p2.core.helpers, org.eclipse.equinox.internal.p2.sar, org.eclipse.equinox.p2.core;version="[2.0.0,3.0.0)", diff --git a/bundles/org.eclipse.equinox.p2.artifact.processors/plugin.xml b/bundles/org.eclipse.equinox.p2.artifact.processors/plugin.xml index 2b083618c..cf1ebf12f 100644 --- a/bundles/org.eclipse.equinox.p2.artifact.processors/plugin.xml +++ b/bundles/org.eclipse.equinox.p2.artifact.processors/plugin.xml @@ -6,14 +6,4 @@ id="org.eclipse.equinox.p2.processing.JarDeltaPatchStep"> <step class="org.eclipse.equinox.internal.p2.artifact.processors.jardelta.JarDeltaProcessorStep"/> </extension> - <extension - point="org.eclipse.equinox.p2.artifact.repository.processingSteps" - id="org.eclipse.equinox.p2.processing.JBPatchStep"> - <step class="org.eclipse.equinox.internal.p2.artifact.processors.jbdiff.JBPatchStep"/> - </extension> - <extension - point="org.eclipse.equinox.p2.artifact.repository.processingSteps" - id="org.eclipse.equinox.p2.processing.JBPatchZipStep"> - <step class="org.eclipse.equinox.internal.p2.artifact.processors.jbdiff.JBPatchZipStep"/> - </extension> </plugin> diff --git a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jbdiff/JBPatchStep.java b/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jbdiff/JBPatchStep.java deleted file mode 100644 index 5a4a4ea17..000000000 --- a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jbdiff/JBPatchStep.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 compeople AG 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * compeople AG (Stefan Liebig) - initial API and implementation - * IBM Corporation - ongoing development - *******************************************************************************/ -package org.eclipse.equinox.internal.p2.artifact.processors.jbdiff; - -import ie.wombat.jbdiff.JBPatch; -import java.io.*; -import org.eclipse.equinox.internal.p2.artifact.processors.AbstractDeltaProcessorStep; -import org.eclipse.equinox.internal.p2.core.helpers.FileUtils; -import org.eclipse.equinox.internal.p2.sar.DirectByteArrayOutputStream; -import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor; - -/** - * The JBPatchStep patches a JBDiff based data. - */ -public class JBPatchStep extends AbstractDeltaProcessorStep { - - public JBPatchStep() { - super(); - } - - protected OutputStream createIncomingStream() throws IOException { - return new DirectByteArrayOutputStream(); - } - - protected void performProcessing() throws IOException { - DirectByteArrayOutputStream predecessor = fetchPredecessorBytes(new ArtifactDescriptor(key)); - DirectByteArrayOutputStream current = (DirectByteArrayOutputStream) incomingStream; - byte[] result = JBPatch.bspatch(predecessor.getBuffer(), predecessor.getBufferLength(), current.getBuffer(), current.getBufferLength()); - // free up the memory as soon as possible. - predecessor = null; - current = null; - incomingStream = null; - - // copy the result of the optimization to the destination. - FileUtils.copyStream(new ByteArrayInputStream(result), true, getDestination(), false); - } - - private DirectByteArrayOutputStream fetchPredecessorBytes(ArtifactDescriptor artifactDescriptor) throws IOException { - DirectByteArrayOutputStream result = new DirectByteArrayOutputStream(); - setStatus(repository.getArtifact(artifactDescriptor, result, getProgressMonitor())); - if (!getStatus().isOK()) - throw (IOException) new IOException(getStatus().getMessage()).initCause(getStatus().getException()); - return result; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jbdiff/JBPatchZipStep.java b/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jbdiff/JBPatchZipStep.java deleted file mode 100644 index f65358ca2..000000000 --- a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/jbdiff/JBPatchZipStep.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 compeople AG 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * compeople AG (Stefan Liebig) - initial API and implementation - * IBM Corporation - ongoing development - *******************************************************************************/ -package org.eclipse.equinox.internal.p2.artifact.processors.jbdiff; - -import ie.wombat.jbdiff.JBPatch; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import org.eclipse.equinox.internal.p2.sar.DirectByteArrayOutputStream; -import org.eclipse.equinox.internal.p2.sar.SarUtil; -import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor; - -/** - * The <code>JBPatchZipStep</code> patches a JBDiff based diff of zips/jars. - */ -public class JBPatchZipStep extends JBPatchStep { - - public JBPatchZipStep() { - super(); - } - - protected void performProcessing() throws IOException { - DirectByteArrayOutputStream predecessor = fetchPredecessorBytes(new ArtifactDescriptor(key)); - DirectByteArrayOutputStream current = (DirectByteArrayOutputStream) incomingStream; - byte[] result = JBPatch.bspatch(predecessor.getBuffer(), predecessor.getBufferLength(), current.getBuffer(), current.getBufferLength()); - // free up the memory as soon as possible. - predecessor = null; - current = null; - incomingStream = null; - - // copy the result of the optimization to the destination. - SarUtil.sarToZip(new ByteArrayInputStream(result), true, getDestination(), false); - } - - private DirectByteArrayOutputStream fetchPredecessorBytes(ArtifactDescriptor artifactDescriptor) throws IOException { - DirectByteArrayOutputStream zippedPredecessor = new DirectByteArrayOutputStream(); - setStatus(repository.getArtifact(artifactDescriptor, zippedPredecessor, getProgressMonitor())); - if (!getStatus().isOK()) - throw (IOException) new IOException(getStatus().getMessage()).initCause(getStatus().getException()); - - DirectByteArrayOutputStream result = new DirectByteArrayOutputStream(); - SarUtil.zipToSar(zippedPredecessor.getInputStream(), result); - return result; - } - -}
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.tests.reconciler.product/reconciler.product b/bundles/org.eclipse.equinox.p2.tests.reconciler.product/reconciler.product index 42bc85c1e..9a98304d8 100644 --- a/bundles/org.eclipse.equinox.p2.tests.reconciler.product/reconciler.product +++ b/bundles/org.eclipse.equinox.p2.tests.reconciler.product/reconciler.product @@ -24,7 +24,6 @@ <plugins> <plugin id="com.ibm.icu"/> - <plugin id="ie.wombat.jbdiff"/> <plugin id="javax.annotation"/> <plugin id="javax.inject"/> <plugin id="javax.xml"/> diff --git a/bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF index 52d576d36..70231344b 100644 --- a/bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.equinox.p2.tests;singleton:=true -Bundle-Version: 1.7.100.qualifier +Bundle-Version: 1.7.200.qualifier Bundle-ClassPath: . Bundle-Activator: org.eclipse.equinox.p2.tests.TestActivator Bundle-Vendor: %providerName diff --git a/bundles/org.eclipse.equinox.p2.tests/pom.xml b/bundles/org.eclipse.equinox.p2.tests/pom.xml index 7698f8876..c62828f44 100644 --- a/bundles/org.eclipse.equinox.p2.tests/pom.xml +++ b/bundles/org.eclipse.equinox.p2.tests/pom.xml @@ -16,7 +16,7 @@ <groupId>org.eclipse.equinox</groupId> <artifactId>org.eclipse.equinox.p2.tests</artifactId> - <version>1.7.100-SNAPSHOT</version> + <version>1.7.200-SNAPSHOT</version> <packaging>eclipse-test-plugin</packaging> <properties> |