Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update #2

Merged
merged 2 commits into from
Sep 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ task shrinkJar(type: proguard.gradle.ProGuardTask, dependsOn: jar) {
task shrinkOutput(type: Jar, dependsOn: shrinkJar) {
classifier = 'shrunk'
from zipTree(shrinkJar.obfuscatedJar)
manifest { attributes 'Main-Class': 'cpw.mods.fml.installer.SimpleInstaller' }
manifest { attributes 'Main-Class': 'net.minecraftforge.installer.SimpleInstaller' }
}

artifacts {
Expand All @@ -80,7 +80,7 @@ artifacts {
jar {
classifier = 'thin'
exclude 'argo/**'
manifest { attributes 'Main-Class': 'cpw.mods.fml.installer.SimpleInstaller' }
manifest { attributes 'Main-Class': 'net.minecraftforge.installer.SimpleInstaller' }
}

uploadArchives {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cpw.mods.fml.installer;
package net.minecraftforge.installer;

import java.io.File;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cpw.mods.fml.installer;
package net.minecraftforge.installer;

import java.io.File;

Expand Down Expand Up @@ -60,6 +60,7 @@ public File getLocalPath(File base)
public String getExt() { return ext; }
public String getMemo() { return memo; }
public void setMemo(String v){ memo = v; }
@Override
public String toString()
{
if (getMemo() != null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cpw.mods.fml.installer;
package net.minecraftforge.installer;

import java.io.BufferedOutputStream;
import java.io.BufferedWriter;
Expand Down Expand Up @@ -72,26 +72,26 @@ public boolean run(File target)
int progress = 3;

File versionJsonFile = new File(versionTarget,VersionInfo.getVersionTarget()+".json");

if (!VersionInfo.isInheritedJson())
{
File clientJarFile = new File(versionTarget, VersionInfo.getVersionTarget()+".jar");
File minecraftJarFile = VersionInfo.getMinecraftFile(versionRootDir);

try
{
boolean delete = false;
monitor.setNote("Considering minecraft client jar");
monitor.setProgress(1);

if (!minecraftJarFile.exists())
{
minecraftJarFile = File.createTempFile("minecraft_client", ".jar");
delete = true;
monitor.setNote(String.format("Downloading minecraft client version %s", VersionInfo.getMinecraftVersion()));
String clientUrl = String.format(DownloadUtils.VERSION_URL_CLIENT.replace("{MCVER}", VersionInfo.getMinecraftVersion()));
System.out.println(" Temp File: " + minecraftJarFile.getAbsolutePath());

if (!DownloadUtils.downloadFileEtag("minecraft server", minecraftJarFile, clientUrl))
{
minecraftJarFile.delete();
Expand All @@ -103,7 +103,7 @@ public boolean run(File target)
}
monitor.setProgress(2);
}

if (VersionInfo.getStripMetaInf())
{
monitor.setNote("Copying and filtering minecraft client jar");
Expand All @@ -116,7 +116,7 @@ public boolean run(File target)
Files.copy(minecraftJarFile, clientJarFile);
monitor.setProgress(3);
}

if (delete)
{
minecraftJarFile.delete();
Expand Down Expand Up @@ -288,6 +288,7 @@ public boolean isPathValid(File targetDir)
}


@Override
public String getFileError(File targetDir)
{
if (targetDir.exists())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cpw.mods.fml.installer;
package net.minecraftforge.installer;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -50,6 +50,7 @@ public static int downloadInstalledLibraries(String jsonMarker, File librariesDi
if (library.isArrayNode("checksums"))
{
checksums = Lists.newArrayList(Lists.transform(library.getArrayNode("checksums"), new Function<JsonNode, String>() {
@Override
public String apply(JsonNode node)
{
return node.getText();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cpw.mods.fml.installer;
package net.minecraftforge.installer;

import java.io.File;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cpw.mods.fml.installer;
package net.minecraftforge.installer;

public interface IMonitor {
void setMaximum(int max);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cpw.mods.fml.installer;
package net.minecraftforge.installer;

import java.io.File;
import javax.swing.Icon;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cpw.mods.fml.installer;
package net.minecraftforge.installer;

import java.awt.Color;
import java.awt.Desktop;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cpw.mods.fml.installer;
package net.minecraftforge.installer;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -42,20 +42,21 @@ public void stop() {
fStop = System.currentTimeMillis();
fIsRunning = false;
}


@Override
public String toString(){ return length() + " ms"; }
public long length() { return fStop - fStart; }
private long fStart;
private long fStop;

private boolean fIsRunning;
}

public static void main(String[] args) throws IOException
{
if (args.length < 1)
{
System.out.println("Usage: java cpw.mods.fml.installer.LibraryPacker <path1> [path2...]");
System.out.println("Usage: java net.minecraftforge.installer.LibraryPacker <path1> [path2...]");
System.out.println("This program will walk the supplied paths recursivly and create compressed versions of any .jar file they find.");
return;
}
Expand All @@ -65,7 +66,7 @@ public static void main(String[] args) throws IOException
walk(new File(path));
}
}

private static void walk(File path) throws IOException
{
if (path.isDirectory())
Expand Down Expand Up @@ -108,13 +109,13 @@ private static byte[] compress(File path) throws IOException
System.out.println("");
return xzed;
}

private static byte[] checksum(byte[] raw, File path) throws IOException
{
JarInputStream in = new JarInputStream(new ByteArrayInputStream(raw));

StringBuffer checksums = new StringBuffer();

JarEntry entry = in.getNextJarEntry();
while (entry != null)
{
Expand All @@ -125,15 +126,16 @@ private static byte[] checksum(byte[] raw, File path) throws IOException
entry = in.getNextJarEntry();
}
in.close();

return checksums.toString().getBytes(Charset.forName("UTF-8"));
}

private static final OutputStream NULL_OUT = new OutputStream()
{
@Override
public void write(int b) throws IOException{}
};

private static byte[] pack(byte[] data, File path) throws IOException
{
JarInputStream in = new JarInputStream(new ByteArrayInputStream(data))
Expand All @@ -150,19 +152,19 @@ public ZipEntry getNextEntry() throws IOException
}
};
ByteArrayOutputStream out = new ByteArrayOutputStream();

Packer packer = Pack200.newPacker();

SortedMap<String, String> props = packer.properties();
props.put(Packer.EFFORT, "9");
props.put(Packer.KEEP_FILE_ORDER, Packer.TRUE);
props.put(Packer.UNKNOWN_ATTRIBUTE, Packer.PASS);

final PrintStream err = new PrintStream(System.err);
System.setErr(new PrintStream(NULL_OUT));
packer.pack(in, out);
System.setErr(err);

in.close();
out.close();

Expand Down Expand Up @@ -197,11 +199,11 @@ private static byte[] unpack(byte[] data, File path) throws IOException

return unpacked;
}

private static byte[] xz(byte[] data, byte[] checksums, File path) throws IOException
{
ByteArrayOutputStream out = new ByteArrayOutputStream();

LZMA2Options options = new LZMA2Options();
options.setPreset(8);
XZOutputStream xz = new XZOutputStream(out, options);
Expand Down Expand Up @@ -230,12 +232,12 @@ private static void decompress(File path, byte[] data, List<String> checksum) th
File output = new File(path.getAbsolutePath() + ".unpacked.test");

DownloadUtils.unpackLibrary(new File(path.getAbsolutePath() + ".unpacked.test"), data);

DownloadUtils.validateJar(output, Files.toByteArray(output), CHECKSUMS);

t.stop();
System.out.println(" Decompress: " + t.toString());
}


}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cpw.mods.fml.installer;
package net.minecraftforge.installer;

import java.net.URL;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cpw.mods.fml.installer;
package net.minecraftforge.installer;

import java.io.File;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cpw.mods.fml.installer;
package net.minecraftforge.installer;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cpw.mods.fml.installer;
package net.minecraftforge.installer;

import java.io.File;
import java.io.FileOutputStream;
Expand Down