* FileUtil: Try to handle lack of unpack200 support more gracefully

* Update: Select old update URL if no unpack200 available
This commit is contained in:
zzz
2010-06-16 13:29:41 +00:00
parent 266eb8307c
commit 1202d09966
7 changed files with 51 additions and 6 deletions

View File

@ -27,6 +27,7 @@ run I2P for the first time.
To run I2P explicitly:
(*nix): sh i2prouter start
(win*): I2P.exe
(Platforms unsupported by the wrapper - PPC, ARM, etc): sh runplain.sh
To stop the router (gracefully):
lynx http://localhost:7657/configservice.jsp ("Shutdown gracefully")

View File

@ -2,6 +2,7 @@ I2P source installation instructions
Prerequisites to build from source:
Java SDK (preferably Sun) 1.5.0 or higher (1.6 recommended)
The SDK must have Pack200 support (java.util.jar.Pack200)
Apache Ant 1.7.0 or higher
Optional, For multilanguage support: The xgettext, msgfmt, and msgmerge tools installed
from the GNU gettext package http://www.gnu.org/software/gettext/

View File

@ -1,5 +1,6 @@
Prerequisites to build from source:
Java SDK (preferably Sun) 1.5.0 or higher (1.6 recommended)
The SDK must have Pack200 support (java.util.jar.Pack200)
Apache Ant 1.7.0 or higher
Optional, For multilanguage support: The xgettext, msgfmt, and msgmerge tools installed
from the GNU gettext package http://www.gnu.org/software/gettext/

View File

@ -43,15 +43,34 @@ public class ConfigUpdateHandler extends FormHandler {
public static final String PROP_UPDATE_URL = "router.updateURL";
/**
* Changed as of release 0.7.14 from .sud to .su2
* Update hosts must maintain both for several releases
* Changed as of release 0.8 to support both .sud and .su2
* Some JVMs (IcedTea) don't have pack200
* Update hosts must maintain both
*/
public static final String DEFAULT_UPDATE_URL =
private static final String PACK200_URLS =
"http://echelon.i2p/i2p/i2pupdate.su2\r\n" +
"http://stats.i2p/i2p/i2pupdate.su2\r\n" +
"http://www.i2p2.i2p/_static/i2pupdate.su2\r\n" +
"http://update.postman.i2p/i2pupdate.su2" ;
private static final String NO_PACK200_URLS =
"http://echelon.i2p/i2p/i2pupdate.sud\r\n" +
"http://stats.i2p/i2p/i2pupdate.sud\r\n" +
"http://www.i2p2.i2p/_static/i2pupdate.sud\r\n" +
"http://update.postman.i2p/i2pupdate.sud" ;
public static final String DEFAULT_UPDATE_URL;
static {
String foo;
try {
Class.forName("java.util.jar.Pack200", false, ClassLoader.getSystemClassLoader());
foo = PACK200_URLS;
} catch (ClassNotFoundException cnfe) {
foo = NO_PACK200_URLS;
}
DEFAULT_UPDATE_URL = foo;
}
public static final String PROP_TRUSTED_KEYS = "router.trustedUpdateKeys";

View File

@ -133,9 +133,16 @@ public class FileUtil {
}
in.close();
} catch (IOException ioe) {
System.err.println("ERROR: Error extracting the zip entry (" + entry.getName() + "]");
System.err.println("ERROR: Error extracting the zip entry (" + entry.getName() + ')');
if (ioe.getMessage() != null && ioe.getMessage().indexOf("CAFED00D") >= 0)
System.err.println("This may be caused by a packed library that requires Java 1.6, your Java version is: " +
System.getProperty("java.version"));
ioe.printStackTrace();
return false;
} catch (Exception e) { // ClassNotFoundException but compiler not happy with that
System.err.println("ERROR: Error unpacking the zip entry (" + entry.getName() +
"), your JVM does not support unpack200");
return false;
}
}
}
@ -170,6 +177,7 @@ public class FileUtil {
byte buf[] = new byte[16*1024];
zip = new ZipFile(zipfile);
Enumeration entries = zip.entries();
boolean p200TestRequired = true;
while (entries.hasMoreElements()) {
ZipEntry entry = (ZipEntry)entries.nextElement();
if (entry.getName().indexOf("..") != -1) {
@ -179,6 +187,16 @@ public class FileUtil {
if (entry.isDirectory()) {
// noop
} else {
if (p200TestRequired &&
(entry.getName().endsWith(".jar.pack") || entry.getName().endsWith(".war.pack"))) {
try {
Class.forName("java.util.jar.Pack200", false, ClassLoader.getSystemClassLoader());
} catch (Exception e) { // ClassNotFoundException but compiler not happy with that
System.err.println("ERROR: Zip verify failed, your JVM does not support unpack200");
return false;
}
p200TestRequired = false;
}
try {
InputStream in = zip.getInputStream(entry);
int read = 0;

View File

@ -1,3 +1,8 @@
2010-06-16 zzz
* Console: Sort countries with selected locale
* FileUtil: Try to handle lack of unpack200 support more gracefully
* Update: Select old update URL if no unpack200 available
2010-06-13 zzz
* Console: Add some divs for languages to news and readmes
* HTTP Proxy: Pass different User Agent to outproxy

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 1;
public final static long BUILD = 2;
/** for example "-test" */
public final static String EXTRA = "";