Removing Pack200 support.
It has been removed from the JDK for some time now. People still relying on it will have to stick to an older version of Getdown.
This commit is contained in:
@@ -56,23 +56,15 @@ public class Resource implements Comparable<Resource>
|
|||||||
int read;
|
int read;
|
||||||
|
|
||||||
boolean isZip = isJar(target) || isZip(target); // jar is a zip too
|
boolean isZip = isJar(target) || isZip(target); // jar is a zip too
|
||||||
boolean isPacked200Jar = isPacked200Jar(target);
|
|
||||||
|
|
||||||
// if this is a jar, we need to compute the digest in a "timestamp and file order" agnostic
|
// if this is a jar, we need to compute the digest in a "timestamp and file order" agnostic
|
||||||
// manner to properly correlate jardiff patched jars with their unpatched originals
|
// manner to properly correlate jardiff patched jars with their unpatched originals
|
||||||
if (isPacked200Jar || isZip){
|
if (isZip){
|
||||||
File tmpJarFile = null;
|
File tmpJarFile = null;
|
||||||
ZipFile zip = null;
|
ZipFile zip = null;
|
||||||
try {
|
try {
|
||||||
// if this is a compressed zip file, uncompress it to compute the zip file digest
|
// if this is a compressed zip file, uncompress it to compute the zip file digest
|
||||||
if (isPacked200Jar){
|
zip = new ZipFile(target);
|
||||||
tmpJarFile = new File(target.getPath() + ".tmp");
|
|
||||||
tmpJarFile.deleteOnExit();
|
|
||||||
FileUtil.unpackPacked200Jar(target, tmpJarFile);
|
|
||||||
zip = new ZipFile(tmpJarFile);
|
|
||||||
} else{
|
|
||||||
zip = new ZipFile(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<? extends ZipEntry> entries = Collections.list(zip.entries());
|
List<? extends ZipEntry> entries = Collections.list(zip.entries());
|
||||||
Collections.sort(entries, ENTRY_COMP);
|
Collections.sort(entries, ENTRY_COMP);
|
||||||
@@ -140,16 +132,6 @@ public class Resource implements Comparable<Resource>
|
|||||||
return path.endsWith(".jar") || path.endsWith(".jar_new");
|
return path.endsWith(".jar") || path.endsWith(".jar_new");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether {@code file} is a {@code jar.pack} file.
|
|
||||||
*/
|
|
||||||
public static boolean isPacked200Jar (File file)
|
|
||||||
{
|
|
||||||
String path = file.getName();
|
|
||||||
return path.endsWith(".jar.pack") || path.endsWith(".jar.pack_new") ||
|
|
||||||
path.endsWith(".jar.pack.gz") || path.endsWith(".jar.pack.gz_new");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a resource with the supplied remote URL and local path.
|
* Creates a resource with the supplied remote URL and local path.
|
||||||
*/
|
*/
|
||||||
@@ -163,14 +145,9 @@ public class Resource implements Comparable<Resource>
|
|||||||
|
|
||||||
_attrs = attrs;
|
_attrs = attrs;
|
||||||
_isZip = isJar(local) || isZip(local);
|
_isZip = isJar(local) || isZip(local);
|
||||||
_isPacked200Jar = isPacked200Jar(local);
|
|
||||||
boolean unpack = attrs.contains(Attr.UNPACK);
|
boolean unpack = attrs.contains(Attr.UNPACK);
|
||||||
if (unpack && _isZip) {
|
if (unpack && _isZip) {
|
||||||
_unpacked = _local.getParentFile();
|
_unpacked = _local.getParentFile();
|
||||||
} else if(unpack && _isPacked200Jar) {
|
|
||||||
String dotJar = ".jar", lname = _local.getName();
|
|
||||||
String uname = lname.substring(0, lname.lastIndexOf(dotJar) + dotJar.length());
|
|
||||||
_unpacked = new File(_local.getParent(), uname);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,15 +298,11 @@ public class Resource implements Comparable<Resource>
|
|||||||
public void unpack () throws IOException
|
public void unpack () throws IOException
|
||||||
{
|
{
|
||||||
// sanity check
|
// sanity check
|
||||||
if (!_isZip && !_isPacked200Jar) {
|
if (!_isZip) {
|
||||||
throw new IOException("Requested to unpack non-jar file '" + _local + "'.");
|
throw new IOException("Requested to unpack non-jar file '" + _local + "'.");
|
||||||
}
|
}
|
||||||
if (_isZip) {
|
try (ZipFile jar = new ZipFile(_local)) {
|
||||||
try (ZipFile jar = new ZipFile(_local)) {
|
FileUtil.unpackJar(jar, _unpacked, _attrs.contains(Attr.CLEAN));
|
||||||
FileUtil.unpackJar(jar, _unpacked, _attrs.contains(Attr.CLEAN));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
FileUtil.unpackPacked200Jar(_local, _unpacked);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -393,7 +366,7 @@ public class Resource implements Comparable<Resource>
|
|||||||
protected URL _remote;
|
protected URL _remote;
|
||||||
protected File _local, _localNew, _marker, _unpacked;
|
protected File _local, _localNew, _marker, _unpacked;
|
||||||
protected EnumSet<Attr> _attrs;
|
protected EnumSet<Attr> _attrs;
|
||||||
protected boolean _isZip, _isPacked200Jar;
|
protected boolean _isZip;
|
||||||
|
|
||||||
/** Used to sort the entries in a jar file. */
|
/** Used to sort the entries in a jar file. */
|
||||||
protected static final Comparator<ZipEntry> ENTRY_COMP = new Comparator<ZipEntry>() {
|
protected static final Comparator<ZipEntry> ENTRY_COMP = new Comparator<ZipEntry>() {
|
||||||
|
|||||||
@@ -167,23 +167,6 @@ public final class FileUtil
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Unpacks a pack200 packed jar file from {@code packedJar} into {@code target}.
|
|
||||||
* If {@code packedJar} has a {@code .gz} extension, it will be gunzipped first.
|
|
||||||
*/
|
|
||||||
public static void unpackPacked200Jar (File packedJar, File target) throws IOException
|
|
||||||
{
|
|
||||||
try (InputStream packJarIn = new FileInputStream(packedJar);
|
|
||||||
JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(target))) {
|
|
||||||
boolean gz = (packedJar.getName().endsWith(".gz") ||
|
|
||||||
packedJar.getName().endsWith(".gz_new"));
|
|
||||||
try (InputStream packJarIn2 = (gz ? new GZIPInputStream(packJarIn) : packJarIn)) {
|
|
||||||
Pack200.Unpacker unpacker = Pack200.newUnpacker();
|
|
||||||
unpacker.unpack(packJarIn2, jarOut);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies the given {@code source} file to the given {@code target}.
|
* Copies the given {@code source} file to the given {@code target}.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user