Commit Graph

185 Commits

Author SHA1 Message Date
md_5
2d06f11347 Refactor downloader into FileLocator and optimize for speed. 2013-04-20 14:00:29 +10:00
md_5
6ea97c26c8 Remove obsolete inheritance providers and globalise verbose setting 2013-04-20 13:33:50 +10:00
md_5
132584eda4 Refactor some of the inheritance providers. 2013-04-20 13:31:42 +10:00
md_5
d846476686 Refactor mapping writers 2013-04-20 13:17:15 +10:00
md_5
1ed5c500b0 Refactor and rename transform classes 2013-04-20 13:08:32 +10:00
md_5
b3934893e0 Rewrite Jar class. 2013-04-20 12:41:16 +10:00
md_5
73b1cfd81c Refactor a few classes into packages. 2013-04-20 12:19:18 +10:00
md_5
3a7ef779bf Update POM & depends 2013-04-20 12:07:55 +10:00
md_5
a318ec4ce6 Quick code format in preparation for repackage. 2013-04-20 12:01:28 +10:00
Agaricus
41244d37e1 Add support for \-style paths in remote mapping file downloads 2013-03-22 11:07:35 -07:00
Agaricus
ef37d9f8e6 Improve exception message on noncomparable jars
Show the mismatched number of symbols
2013-03-16 10:11:47 -07:00
md_5
1b86fa2de3 Reverse-mergecommit 43688dd80b 2013-03-11 16:30:19 +11:00
md_5
43688dd80b Feed in the original ClassReader to ensure the constant pool is not excessively mangled. 2013-03-11 16:10:46 +11:00
Agaricus
44434e8e1b Fix command return status on error 2013-03-10 18:20:19 -07:00
Agaricus
374cb129e2 Add loading of numeric "srg" names from MCP directory
Normally, loadMappingsDir() loads:

    obf -> num -> pkgmcp

but with numericSrgNames, it loads:

    pkgmcp -> num

where:

obf = obfuscated "notch" names
num = numeric "srg" names
pkgmcp = descriptive "csv" names

This implementation could probably be improved further.

Compatibility Note: --numeric used to load these mappings:

    obf -> num

that is, ignoring the fields/methods.csv. But this turned out not to
be too useful. You can still get this mapping with ignoreCsv=true, but
now numericSrgNames and --numeric loads the much more useful mapping:

    pkgmcp -> num

Useful for targetting FML runtime deobfuscation.
2013-03-10 13:45:51 -07:00
Agaricus
65ba1c8053 Add method descriptor to JarMappingLoadTransformer
Again, not used by CSVMappingTransformer, but could be used by other
transformation classes to be written.
2013-03-10 11:40:27 -07:00
Agaricus
f91c319a8b Add class name to JarMappingLoadTransformer field/method
Not used by CSVMappingTransformer, since the CSVs only contain:
    func_###,newname
    field_###,newname
with no class name, but it could be used by other load transformers.
2013-03-10 11:32:08 -07:00
md_5
f7f4290098 [maven-release-plugin] prepare for next development iteration 2013-03-09 18:07:50 +11:00
md_5
d7974083ee [maven-release-plugin] prepare release SpecialSource-1.4 2013-03-09 18:07:39 +11:00
Agaricus
1e3c04f7f1 Add support for access map '**' pattern to match all symbols
Classes, fields, and methods. Also add some documentation of
this ever-expanding file format.
2013-03-08 20:35:36 -08:00
Agaricus
47036ad5a8 Add convenient alias to private visibility
Since AccessMap never downgrades visibility, 'private' in AT is
effectively equivalent to 'no change'. Useful in case you want to
change other flags but not the visibility. Accept '*' as private.
2013-03-08 18:48:19 -08:00
Agaricus
4eacd3ef15 Add support for loading single AT patterns in AccessMap
In addition to filenames and URLs, loadAccessTransformer(String) now
accepts the literal "pattern:" followed by an access transformer line.
Useful for adding individual transformations without a new _at.cfg.
2013-03-08 18:42:21 -08:00
Agaricus
0f3edc778e Rework access map to never decrease visibility
Now will only upgrade, from private->default->protected->public.
Useful for modifying access with wildcards, e.g. classname.* protected
to change all fields in the class to protected -- except those which
are already public. This matches FML's access transformer behavior.
2013-03-08 12:41:59 -08:00
Agaricus
1b9c9f239a Fix NPE when reflection remapping is used without access map 2013-03-07 20:54:58 -08:00
Agaricus
3ae83a6b81 Add support for access modifier mapping
Allows for easily changing arbitrary symbol access flags. Supports
FML *_at.cfg access transformer file format loading in AccessMap.
Multiple AT's can be merged together and applied simultaneously
from the remapper 'preprocessor' class. Symbol visibility, final,
as well as any Java access flag can be set or cleared with +/-.
2013-03-07 19:57:29 -08:00
md_5
6ba34dbfee [maven-release-plugin] prepare for next development iteration 2013-03-07 16:24:26 +11:00
md_5
0cf67b4345 [maven-release-plugin] prepare release SpecialSource-1.3 2013-03-07 16:24:13 +11:00
Agaricus
e6addcde3b Exclude signature files (.DSA, .SF) from remapped jar
The remapped jar is altered and will fail to validate against
the included signatures from the original jar, if any. Normally
not a problem, you can compile against the remapped jar as a library
with no errors. However, when loading the jar from Maven (hit with
the Forge jar), signature validation will fail. Stripping the
signature files fixes this.
2013-03-03 16:23:47 -08:00
Agaricus
3decd36620 Add support for remapping jar mods with multiple --in-jar
You can now pass multiple filenames to --in-jar, and the files
in the subsequent jars will overwrite those in the previous. This
allows remapping "jar mods", which are distributed as an archive of
a subset of files against a reference jar. For example, Forge
overwrites base classes in Minecraft. Example usage:

java -jar target/SpecialSource-1.3-SNAPSHOT-shaded.jar --in-jar http://assets.minecraft.net/1_4_7/minecraft_server.jar --in-jar http://files.minecraftforge.net/minecraftforge/minecraftforge-universal-1.4.7-6.6.2.534.zip --out-jar /tmp/n/test.jar --srg-in https://raw.github.com/MinecraftForge/FML/master/conf/
2013-03-03 10:41:28 -08:00
Agaricus
9fcbdce6e7 Refactor Jar resource access and entry list
* Add getResource(), extracted from getClass()
* Remove getInputStream(), using getResource() instead
* Change getEntries() to getEntryNames(), hiding JarEntry
* Store filename for getFilename()
2013-03-02 19:04:10 -08:00
Agaricus
61270b1259 Privatize Jar file and main members; replace with accessors 2013-03-02 16:22:21 -08:00
Agaricus
fd908cb405 Fix missing class transformer on reversed mapping directory loading
Loading mappings from directories, with the 'reverse' option, would
not account for repackaging on field names. Add missing transform.
2013-03-02 15:19:07 -08:00
Agaricus
cc5391a5cf Add caching for remotely downloaded resources
Mappings or jars downloaded from http URLs given to --srg-in or
--in-jar, --first-jar, --second-jar, will be cached locally in
a temporary directory, and reused on subsequent invocations if
present. The cache can be invalidated with --force-redownload.
2013-03-01 20:53:03 -08:00
Agaricus
5b979a4da3 Save downloaded files to non-random temporary filenames
Fixes repeated downloads filling up your disk.
2013-03-01 20:30:42 -08:00
Agaricus
a6e18b0665 Move loadMappings() dir/file logic to JarMapping
Instead of in the command-line interface.. this allows
other code providing an interface to SpecialSource to
easily pass user-supplied options for loading mappings.
2013-03-01 19:10:06 -08:00
Agaricus
91803d03ea Add support for remote --first-jar/--second-jar
Example:
java -jar target/SpecialSource-1.3-SNAPSHOT-shaded.jar --first-jar http://assets.minecraft.net/1_4_7/minecraft_server.jar --second-jar http://repo.bukkit.org/content/groups/public/org/bukkit/minecraft-server/1.4.7/minecraft-server-1.4.7.jar
2013-02-28 20:18:11 -08:00
Agaricus
308d1b4413 Add --numeric-srg option for using srg names (vs csv) on MCP dirs
Normally, --srg-in on a directory will load joined.srg or
client.srg and server.srg, translated through fields.csv,
methods.csv, and packages.csv, if available. --numeric will
ignore fields.csv and methods.csv, remapping the jar to
the numeric "srg" names instead of descriptive "csv" names.
(packages.csv will still be used if it exists; if you want
flat packaging then specify joined.srg to --srg-in directly.)
2013-02-27 21:56:07 -08:00
Agaricus
e36a60a078 Add support for remote --srg-in mappings
Mappings can now be downloaded from remote URLs. Both
individual .srgs and directories of .srg/.csv are supported.
Examples:

java -jar target/SpecialSource-1.3-SNAPSHOT-shaded.jar --in-jar http://assets.minecraft.net/1_4_7/minecraft_server.jar --out-jar /tmp/net.jar --srg-in https://raw.github.com/MinecraftForge/FML/master/conf/joined.srg
java -jar target/SpecialSource-1.3-SNAPSHOT-shaded.jar --in-jar http://assets.minecraft.net/1_4_7/minecraft_server.jar --out-jar /tmp/net2.jar --srg-in https://raw.github.com/MinecraftForge/FML/master/conf/
2013-02-27 21:37:02 -08:00
Agaricus
e99d3c7ef4 Update date to 2012-2013 2013-02-27 21:18:22 -08:00
Agaricus
1000ba60cf Add support for remote --in-jar URLs
You can now provide an HTTP URL to --in-jar and
it will be downloaded to a temporary file before
remapping. Example:

java -jar target/SpecialSource-1.3-SNAPSHOT-shaded.jar --in-jar http://assets.minecraft.net/1_4_7/minecraft_server.jar --out-jar /tmp/net.jar --srg-in ../MinecraftForge/mcp/conf/
2013-02-27 21:11:47 -08:00
Agaricus
262ec1b82e Remove support for reading packaged.srg
packaged.srg is created by FML/MCP from joined.srg
and packages.csv. Now that we support reading packages.csv,
remove support for packaged.srg; one fewer codepath.
2013-02-27 18:34:26 -08:00
Agaricus
888aecfe22 Add support for packages.csv mappings
If packages.csv is found in a mapping directory, the
classes in .srg will be mapped through it. This is an
alternative to reading packages.srg, which isn't present
in the FML distribution (only joined.srg+packages.csv).
2013-02-27 13:35:32 -08:00
Agaricus
ea80a4eb91 Fix 'ZipException: invalid entry compressed size' mapping non-ASCII text files
When remapping Minecraft + Forge, was failing with:

Exception in thread "main" java.util.zip.ZipException: invalid entry compressed size (expected 13048 but got 13084 bytes)
  at java.util.zip.ZipOutputStream.closeEntry(ZipOutputStream.java:248)
    at java.util.zip.ZipOutputStream.finish(ZipOutputStream.java:343)
    at java.util.zip.DeflaterOutputStream.close(DeflaterOutputStream.java:238)
    at java.util.zip.ZipOutputStream.close(ZipOutputStream.java:360)
    at net.md_5.specialsource.JarRemapper.remapJar(JarRemapper.java:141)
    at net.md_5.specialsource.SpecialSource.main(SpecialSource.java:220)

Full details: https://gist.github.com/agaricusb/5036166

To fix this, we always create a JarEntry. Explanation from:
http://javahowto.blogspot.com/2011/07/how-to-programmatically-copy-jar-files.html

It usually occurs when text file entries in the source jar file contain some non-ASCII characters such as ^I ^Z ^D ^C. Some common files are META-INF/COPYRIGHT.html, META-INF/LICENSE.txt, etc, probably because these files were created in a non-ASCII editor but saved as text files. Open them in vi or vim to see these offending characters. To avoid this type of ZipException, always create a new JarEntry with the same name, and pass it to putNextEntry() method. Do not pass the existing jar entry from the source jar file to putNextEntry() method.
2013-02-25 21:42:44 -08:00
Agaricus
cadc0ef588 Remove deprecated 2013-02-22 18:24:46 -08:00
Agaricus
16a1c725dc Add reverse and output shade relocation flags
Removed the ^/@-style input specifications, in favor of
command-line options (which apply to all mappings loaded):

--in-shade-relocation: applies to srg-in input names
--out-shade-relocation: applies to srg-in output names
--reverse: reverses srg-in input/output names

Output shading relocation is useful if remapping through
--srg-in obf2cb.srg, and you want versioned names to match CB.
2013-02-21 21:32:05 -08:00
Agaricus
49e2b341c0 Disable reading .srg 'PK:' mappings for now
Example from packaged.srg:

PK: . net/minecraft/src
PK: com com
PK: net net
PK: net/minecraft net/minecraft
PK: net/minecraft/client net/minecraft/client
PK: net/minecraft/server net/minecraft/server

SpecialSource package remaps currently are class prefix matches,
taking precedence over class remaps. So net->net would match all
net.* classes when using reversed MCP (for reobfuscation), causing
no classes to remap. However the current behavior is useful for MCPC+,
remapping entire package hierarchies. Probably both behaviors should be
supported at some point, but until they are, disabling .srg PK:.
2013-02-21 20:31:17 -08:00
Agaricus
44de5cb247 Add support for loading mappings in reverse
--srg-in ^filename will load the mappings as if they were reversed.

This is a decoration on the filename instead of a separate command-
line option flag so it can apply to the particular mapping file,
when loading multiple mappings simultaneously.
2013-02-21 20:25:04 -08:00
Agaricus
87a5874745 Read fields/methods.csv for MCP directory mapping loading
You can now specify an MCP config directory with --srg-in and
the .srg will be loaded along with the fields.csv and methods.csv
mappings, providing descriptive "csv" names instead of the
numeric "srg" names. Example usage:

java -jar target/SpecialSource-1.3-SNAPSHOT-shaded.jar --in-jar ../jars/minecraft_server-147.jar --srg-in ../MinecraftForge/mcp/conf/ --out-jar /tmp/minecraft-server-pkgmcp.jar

For compiling mods against the minecraft-server-pkgmcp.jar
as a library, an alternative to recompiling all of Minecraft
by using MCP (much faster, like compiling Bukkit plugins).

Note: if the fields.csv and methods.csv are not present, the
numeric "srg" names will be loaded instead.
2013-02-20 22:02:24 -08:00
Agaricus
7ab477500c Fix incomplete shade relocation of .srg files
.csrg OK
2013-02-20 20:39:54 -08:00
Agaricus
f643febd34 Refactor ShadeRelocationSimulator into JarMappingInputTransformer
JarMappings loaded from disk are now transformed through a
JarMappingInputTransformer interface, which can arbitrarily
transform classes on loading. Currently only implemented
by ShadeRelocationSimulator.
2013-02-20 20:26:50 -08:00