def main(mcp_dir): print 'Using mcp dir: %s' % mcp_dir print 'Using base dir: %s' % base_dir sys.path.append(mcp_dir) os.chdir(mcp_dir) reobf = os.path.join(mcp_dir, 'reobf', 'minecraft') try: pass shutil.rmtree(reobf) except OSError: pass print("Recompiling...") from runtime.mcp import recompile_side, reobfuscate_side from runtime.commands import Commands, CLIENT commands = Commands(None, verify=True) recompile_side(commands, CLIENT) print("Reobfuscating...") commands.creatergcfg(reobf=True, keep_lvt=True, keep_generics=True, srg_names=False) reobfuscate_side(commands, CLIENT) create_install(mcp_dir)
def main(mcp_dir): print 'Using mcp dir: %s' % mcp_dir print 'Using base dir: %s' % base_dir print("Refreshing dependencies...") download_deps( mcp_dir, False ) sys.path.append(mcp_dir) os.chdir(mcp_dir) reobf = os.path.join(mcp_dir,'reobf','minecraft') try: pass shutil.rmtree(reobf) except OSError: pass # Update Minecrift version minecraft_java_file = os.path.join(mcp_dir,'src','minecraft','net','minecraft','client','Minecraft.java') if os.path.exists(minecraft_java_file): print "Updating Minecraft.java with Minecrift version: [Minecrift %s %s] %s" % ( minecrift_version_num, minecrift_build, minecraft_java_file ) replacelineinfile( minecraft_java_file, "public final String minecriftVerString", " public final String minecriftVerString = \"Minecrift %s %s\";\n" % (minecrift_version_num, minecrift_build) ); print("Recompiling...") from runtime.mcp import recompile_side, reobfuscate_side from runtime.commands import Commands, CLIENT commands = Commands(None, verify=True) recompile_side( commands, CLIENT) print("Reobfuscating...") commands.creatergcfg(reobf=True, keep_lvt=True, keep_generics=True, srg_names=False) reobfuscate_side( commands, CLIENT ) create_install( mcp_dir )
def main(mcp_dir): print 'Using mcp dir: %s' % mcp_dir print 'Using base dir: %s' % base_dir print("Refreshing dependencies...") download_deps(mcp_dir, False) sys.path.append(mcp_dir) os.chdir(mcp_dir) reobf = os.path.join(mcp_dir, 'reobf', 'minecraft') try: pass shutil.rmtree(reobf) except OSError: pass # Read Minecrift lib versions jRiftPom = os.path.join(base_dir, 'JRift', 'JRift', 'pom.xml') jRiftLibraryPom = os.path.join(base_dir, 'JRift', 'JRiftLibrary', 'pom.xml') jRiftVer = readpomversion(jRiftPom) print 'JRift: %s' % jRiftVer jRiftLibraryVer = readpomversion(jRiftLibraryPom) print 'JRiftLibrary: %s' % jRiftLibraryVer # Update Minecrift version minecraft_java_file = os.path.join(mcp_dir, 'src', 'minecraft', 'net', 'minecraft', 'client', 'Minecraft.java') if os.path.exists(minecraft_java_file): print "Updating Minecraft.java with Vivecraft version: [Vivecraft %s %s] %s" % ( minecrift_version_num, minecrift_build, minecraft_java_file) replacelineinfile( minecraft_java_file, "public final String minecriftVerString", " public final String minecriftVerString = \"Vivecraft %s %s\";\n" % (minecrift_version_num, minecrift_build)) print("Recompiling...") from runtime.mcp import recompile_side, reobfuscate_side from runtime.commands import Commands, CLIENT commands = Commands(None, verify=True) recompile_side(commands, CLIENT) print("Reobfuscating...") commands.creatergcfg(reobf=True, keep_lvt=True, keep_generics=True, srg_names=False) reobfuscate_side(commands, CLIENT) create_install(mcp_dir)
def main(): print("Obtaining version information from git") cmd = "git describe --long --match='[^(jenkins)]*'" try: process = subprocess.Popen(cmdsplit(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1) vers, _ = process.communicate() except OSError: print("Git not found") vers = "v1.0-0-deadbeef" (major, minor, rev, githash) = re.match("v(\d+).(\d+)-(\d+)-(.*)", vers).groups() (mcpversion, mcversion, mcserverversion) = re.match( "[.\w]+ \(data: ([.\w]+), client: ([.\w.]+), server: ([.\w.]+)\)", Commands.fullversion()).groups() with open("version.properties", "w") as f: f.write("%s=%s\n" % ("CompactSolars.build.major.number", major)) f.write("%s=%s\n" % ("CompactSolars.build.minor.number", minor)) f.write("%s=%s\n" % ("CompactSolars.build.revision.number", rev)) f.write("%s=%s\n" % ("CompactSolars.build.githash", githash)) f.write("%s=%s\n" % ("CompactSolars.build.mcpversion", mcpversion)) f.write("%s=%s\n" % ("CompactSolars.build.mcversion", mcversion)) print("Version information: CompactSolars %s.%s.%s using MCP %s for %s" % (major, minor, rev, mcpversion, mcversion))
def recompile(conffile, only_client, only_server): errorcode = 0 try: commands = Commands(conffile, verify=True) # client or server process_client = True process_server = True if only_client and not only_server: process_server = False if only_server and not only_client: process_client = False if process_client: try: recompile_side(commands, CLIENT) except CalledProcessError: errorcode = 2 pass if process_server: try: recompile_side(commands, SERVER) except CalledProcessError: errorcode = 3 pass except Exception: # pylint: disable-msg=W0703 logging.exception('FATAL ERROR') sys.exit(1)
def main(): print("Obtaining version information from git") cmd = "git describe --long --match='[^(jenkins)]*'" try: process = subprocess.Popen(cmdsplit(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1) vers, _ = process.communicate() except OSError: print("Git not found") vers = "v1.0-0-deadbeef" (major, minor, rev, githash) = re.match("v(\d+).(\d+)-(\d+)-(.*)", vers).groups() (mcpversion, mcclientversion, mcserverversion) = re.match( "[.\w]+ \(data: ([.\w]+), client: ([.\w.]+), server: ([.\w.]+)\)", Commands.fullversion() ).groups() with open("fmlversion.properties", "w") as f: f.write("%s=%s\n" % ("fmlbuild.major.number", major)) f.write("%s=%s\n" % ("fmlbuild.minor.number", minor)) f.write("%s=%s\n" % ("fmlbuild.revision.number", rev)) f.write("%s=%s\n" % ("fmlbuild.githash", githash)) f.write("%s=%s\n" % ("fmlbuild.mcpversion", mcpversion)) f.write("%s=%s\n" % ("fmlbuild.mcclientversion", mcclientversion)) f.write("%s=%s\n" % ("fmlbuild.mcserverversion", mcserverversion)) print( "Version information: FML %s.%s.%s using MCP %s for c:%s, s:%s" % (major, minor, rev, mcpversion, mcclientversion, mcserverversion) )
def main(mcp_dir): print 'Using mcp dir: %s' % mcp_dir print 'Using base dir: %s' % base_dir sys.path.append(mcp_dir) os.chdir(mcp_dir) reobf = os.path.join(mcp_dir,'reobf','minecraft') try: pass shutil.rmtree(reobf) except OSError: pass print("Recompiling...") from runtime.mcp import recompile_side, reobfuscate_side from runtime.commands import Commands, CLIENT commands = Commands(None, verify=True) recompile_side( commands, CLIENT) print("Reobfuscating...") commands.creatergcfg(reobf=True, keep_lvt=True, keep_generics=True, srg_names=False) reobfuscate_side( commands, CLIENT ) create_install( mcp_dir )
def build_forge_dev(mcp_dir, forge_dir, fml_dir, build_num=0): version = load_version(build_num) print '=================================== Build %d.%d.%d.%d Start =================================' % ( version['major'], version['minor'], version['revision'], version['build']) src_dir = os.path.join(mcp_dir, 'src') if os.path.isdir(src_dir): shutil.rmtree(src_dir) sys.path.append(fml_dir) sys.path.append(os.path.join(fml_dir, 'install')) from fml import copytree print 'src_work -> src' copytree(os.path.join(mcp_dir, 'src_work'), src_dir) print '\nCopying Client Code' copytree(os.path.join(forge_dir, 'client'), os.path.join(src_dir, 'minecraft'), -1) print '\nCopying Common Code' copytree(os.path.join(forge_dir, 'common'), os.path.join(src_dir, 'minecraft'), -1) print inject_version( os.path.join( src_dir, 'minecraft/net/minecraftforge/common/ForgeVersion.java'.replace( '/', os.sep)), build_num) error_level = 0 try: sys.path.append(mcp_dir) from runtime.commands import Commands, CLIENT, SERVER, CalledProcessError from runtime.mcp import recompile_side os.chdir(mcp_dir) reset_logger() commands = Commands(None, verify=True) try: recompile_side(commands, CLIENT) except CalledProcessError as e: error_level = 1 pass reset_logger() os.chdir(forge_dir) except SystemExit, e: if not e.code == 0: print 'Recompile Exception: %d ' % e.code error_level = e.code
def main(): print("Obtaining version information from git") # get mod version try: process = subprocess.Popen(cmd_describe, bufsize= -1, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) git_tagstring, _ = process.communicate() except OSError as e: print("Git not found.") print(" type: " + str(type(e))) print(" " + str(e).decode("cp932").encode(encoding='utf-8')) print("----------") git_tagstring = dummy_version_string print("tag : " + git_tagstring) print("pattern: " + pattern_gittag) (major, minor, build, githash) = re.match(pattern_gittag, git_tagstring).groups() # get mcp/minecraft version fullversion = Commands.fullversion() print("fullver: " + fullversion) print("pattern: " + pattern_mcp_commands_fullversion) (mcpversion, mcversion, mcserverversion) = re.match(pattern_mcp_commands_fullversion, fullversion).groups() # output with open(version_properties_filename, "w") as f: f.write("###################################################\n#\n") f.write("# version.properties\n") f.write("#\n") f.write("# create: " + str(datetime.datetime.now()) + "\n") f.write("#\n") f.write("###################################################\n") f.write("%s=%s\n" % (mod_id + ".version", "%s.%s.%s.%s" % (major, minor, build, mod_rev_number))) f.write("%s=%s\n" % (mod_id + ".version.major", major)) f.write("%s=%s\n" % (mod_id + ".version.minor", minor)) f.write("%s=%s\n" % (mod_id + ".version.build", build)) f.write("%s=%s\n" % (mod_id + ".version.revision", mod_rev_number)) f.write("%s=%s\n" % (mod_id + ".version.githash", githash)) f.write("\n") f.write("%s=%s\n" % ("mod.version", "%s.%s.%s.%s" % (major, minor, build, mod_rev_number))) f.write("%s=%s\n" % ("mcmod.info.version", "%s.%s.%s #%s" % (major, minor, build, mod_rev_number))) f.write("%s=%s\n" % ("minecraft.version", mcversion)) f.write("%s=%s\n" % ("mcp.version", mcpversion)) f.write("%s=%s\n" % ("fml.build.number", fml_build_number)) f.write("#[EOF]") print(" \n") print("Version information: " + mod_id + " %s.%s.%s #%s using MCP %s for Minecraft %s" % (major, minor, build, mod_rev_number, mcpversion, mcversion))
def main(): print("Obtaining version information from git") cmd = "git describe --long --match='[^(jenkins)]*'" try: process = subprocess.Popen(cmdsplit(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1) vers, _ = process.communicate() except OSError: print("Git not found") vers = "v1.0-0-deadbeef" (major, minor, rev, githash) = re.match("v(\d+).(\d+)-(\d+)-(.*)", vers).groups() (mcpversion, mcclientversion, mcserverversion) = re.match( "[.\w]+ \(data: ([.\w]+), client: ([.\w.]+), server: ([.\w.]+)\)", Commands.fullversion()).groups() if os.getenv("GIT_BRANCH") is None: cmd = "git rev-parse --abbrev-ref HEAD" try: process = subprocess.Popen(cmdsplit(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1) branch, _ = process.communicate() branch = branch.strip() except OSError: print("Git not found") branch = "master" else: branch = os.getenv("GIT_BRANCH").rpartition('/')[2] if branch == 'HEAD': branch = "master" with open("fmlversion.properties", "w") as f: f.write("%s=%s\n" % ("fmlbuild.major.number", major)) f.write("%s=%s\n" % ("fmlbuild.minor.number", minor)) f.write("%s=%s\n" % ("fmlbuild.revision.number", rev)) f.write("%s=%s\n" % ("fmlbuild.githash", githash)) f.write("%s=%s\n" % ("fmlbuild.mcpversion", mcpversion)) f.write("%s=%s\n" % ("fmlbuild.mcversion", mcclientversion)) f.write("%s=%s\n" % ("fmlbuild.branch", branch)) print( "Version information: FML %s.%s.%s (%s) using MCP %s for minecraft %s" % (major, minor, rev, branch, mcpversion, mcclientversion))
def main(mcp_dir): print 'Using mcp dir: %s' % mcp_dir print 'Using base dir: %s' % base_dir print("Refreshing dependencies...") download_deps( mcp_dir, False ) sys.path.append(mcp_dir) os.chdir(mcp_dir) reobf = os.path.join(mcp_dir,'reobf','minecraft') srg = os.path.join(mcp_dir,'class','srg') obf = os.path.join(mcp_dir,'class','obf') from runtime.commands import reallyrmtree reallyrmtree(reobf) reallyrmtree(srg) reallyrmtree(obf) # Update Minecrift version minecraft_java_file = os.path.join(mcp_dir,'src','minecraft','net','minecraft','client','Minecraft.java') if os.path.exists(minecraft_java_file): print "Updating Minecraft.java with Vivecraft version: [Vivecraft %s %s] %s" % ( minecrift_version_num, minecrift_build, minecraft_java_file ) replacelineinfile( minecraft_java_file, "public final String minecriftVerString", " public final String minecriftVerString = \"Vivecraft %s %s\";\n" % (minecrift_version_num, minecrift_build) ); print("Recompiling...") from runtime.mcp import recompile_side, reobfuscate_side from runtime.commands import Commands, CLIENT commands = Commands(None, verify=True) recompile_side( commands, CLIENT) print("Reobfuscating...") commands.creatergcfg(reobf=True, keep_lvt=True, keep_generics=True, srg_names=True) reobfuscate_side( commands, CLIENT , srg_names=True) try: pass shutil.move(reobf, srg) except OSError: quit commands.creatergcfg(reobf=True, keep_lvt=True, keep_generics=True, srg_names=False) reobfuscate_side( commands, CLIENT ) try: pass shutil.move(reobf, obf) except OSError: quit create_install( mcp_dir )
def main(): print("Obtaining version information from git") cmd = "git describe --long --match='[^(jenkins)]*'" try: process = subprocess.Popen(cmdsplit(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1) vers, _ = process.communicate() except OSError: print("Git not found") vers = "v1.0-0-deadbeef" (major, minor, rev, githash) = re.match("v(\d+).(\d+)-(\d+)-(.*)", vers).groups() (mcpversion, mcclientversion, mcserverversion) = re.match( "[.\w]+ \(data: ([.\w]+), client: ([.\w.]+), server: ([.\w.]+)\)", Commands.fullversion() ).groups() if os.getenv("GIT_BRANCH") is None: cmd = "git rev-parse --abbrev-ref HEAD" try: process = subprocess.Popen(cmdsplit(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1) branch, _ = process.communicate() branch = branch.strip() except OSError: print("Git not found") branch = "master" else: branch = os.getenv("GIT_BRANCH").rpartition("/")[2] if branch == "HEAD": branch = "master" with open("fmlversion.properties", "w") as f: f.write("%s=%s\n" % ("fmlbuild.major.number", major)) f.write("%s=%s\n" % ("fmlbuild.minor.number", minor)) f.write("%s=%s\n" % ("fmlbuild.revision.number", rev)) f.write("%s=%s\n" % ("fmlbuild.githash", githash)) f.write("%s=%s\n" % ("fmlbuild.mcpversion", mcpversion)) f.write("%s=%s\n" % ("fmlbuild.mcversion", mcclientversion)) f.write("%s=%s\n" % ("fmlbuild.branch", branch)) print( "Version information: FML %s.%s.%s (%s) using MCP %s for minecraft %s" % (major, minor, rev, branch, mcpversion, mcclientversion) )
def getVersion(): from runtime.commands import Commands Commands._version_config = os.path.join(mcp_dir, Commands._version_config) print("Obtaining version information from git") execCmd("git checkout master") # Get tags from the master branch try: vers = execCmd("git describe --long --match='[^(jenkins)]*'") except OSError: print("Git not found") vers = "v1.0-0-deadbeef" execCmd("git checkout %s" % branch) (major, minor, info, rev, githash) = re.match("v(\d+).(\d+)(-.*)?-(\d+)-(.*)", vers).groups() if not info: info = "" (mcpversion, mcversion, mcserverversion) = re.match( "[.\w]+ \(data: ([.\w]+), client: ([.\w.]+), server: ([.\w.]+)\)", Commands.fullversion()).groups() global verData verData = { "build.major.number": major, "build.minor.number": minor, "build.info": info, "build.revision.number": rev, "build.number": os.getenv('BUILD_NUMBER', 1), "githash": githash, "mcpversion": mcpversion, "mcversion": mcversion, } print("Version information: Boxes %s.%s.%s%s using MCP %s for %s" % (major, minor, rev, info, mcpversion, mcversion))
def main(mcp_dir): print 'Using mcp dir: %s' % mcp_dir print 'Using base dir: %s' % base_dir sys.path.append(mcp_dir) os.chdir(mcp_dir) reobf = os.path.join(mcp_dir,'reobf','minecraft') try: pass shutil.rmtree(reobf) except OSError: pass print("Recompiling...") from runtime.mcp import recompile_side, reobfuscate_side from runtime.commands import Commands, CLIENT commands = Commands(None, verify=True) recompile_side( commands, CLIENT) print("Reobfuscating...") commands.creatergcfg(reobf=True, keep_lvt=True, keep_generics=True, srg_names=False) reobfuscate_side( commands, CLIENT ) print("Creating Installer...") in_mem_zip = StringIO.StringIO() with zipfile.ZipFile( in_mem_zip,'w', zipfile.ZIP_DEFLATED) as zipout: for abs_path, _, filelist in os.walk(reobf, followlinks=True): arc_path = os.path.relpath( abs_path, reobf ).replace('\\','/').replace('.','')+'/' for cur_file in fnmatch.filter(filelist, '*.class'): if cur_file=='blk.class': #skip SoundManager continue in_file= os.path.join(abs_path,cur_file) arcname = arc_path + cur_file zipout.write(in_file, arcname) os.chdir( base_dir ) in_mem_zip.seek(0) json_str = "" mc_ver ="1.6.2" if os.getenv("RELEASE_VERSION"): version = os.getenv("RELEASE_VERSION") elif os.getenv("BUILD_NUMBER"): version = "b"+os.getenv("BUILD_NUMBER") else: version = "LOCAL" version = mc_ver+"-"+version json_id = "minecrift-"+version lib_id = "com.mtbs3d:minecrift:"+version with open(os.path.join("installer",mc_ver+".json"),"rb") as f: json_obj = json.load(f) time = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S-05:00") json_obj["id"] = json_id json_obj["time"] = time json_obj["releaseTime"] = time json_obj["libraries"].insert(0,{"name":lib_id}) #Insert at beginning json_obj["libraries"].append({"name":"net.minecraft:Minecraft:"+mc_ver}) #Insert at end json_str = json.dumps( json_obj, indent=1 ) installer_id = json_id+"-installer" installer = os.path.join( installer_id+".jar" ) shutil.copy( os.path.join("installer","installer.jar"), installer ) with zipfile.ZipFile( installer,'a', zipfile.ZIP_DEFLATED) as install_out: #append to installer.jar install_out.writestr( "version.json", json_str ) install_out.writestr( "version.jar", in_mem_zip.read() ) install_out.writestr( "version", json_id+":"+version ) print("Creating Installer exe...") with open( os.path.join("installer","launch4j.xml"),"r" ) as inlaunch: with open( "launch4j.xml", "w" ) as outlaunch: outlaunch.write( inlaunch.read().replace("installer",installer_id)) subprocess.Popen( cmdsplit("java -jar \"%s\" \"%s\""% ( os.path.join( base_dir,"installer","launch4j","launch4j.jar"), os.path.join( base_dir, "launch4j.xml"))), cwd=os.path.join(base_dir,"installer","launch4j"), bufsize=-1).communicate() os.unlink( "launch4j.xml" )
except SystemExit, e: print 'Decompile Exception: %d ' % e.code raise e if not os.path.isdir(src_dir): print 'Something went wrong, src folder not found at: %s' % src_dir sys.exit(1) #cleanup_source cleanup_source(src_dir) merge_client_server(mcp_dir) os.chdir(mcp_dir) commands = Commands(verify=True) updatemd5_side(mcp_dir, commands, CLIENT) updatemd5_side(mcp_dir, commands, SERVER) reset_logger() os.chdir(fml_dir) def updatemd5_side(mcp_dir, commands, side): sys.path.append(mcp_dir) from runtime.mcp import recompile_side, updatemd5_side from runtime.commands import SIDE_NAME recomp = recompile_side(commands, side) if recomp: commands.logger.info('> Generating %s md5s', SIDE_NAME[side])
line = line.replace('@Mod(', '') line = line.replace(')', '') line = line.strip() fields = line.split(', ') for field in fields: pair = field.split('=') if (pair[0] == 'modid'): modid = pair[1] elif (pair[0] == 'name'): modname = pair[1] elif (pair[0] == 'version'): version = pair[1] print '================ Compiling Battlegear ===================' os.chdir(mcpDir) c = Commands() recompile_side(c, CLIENT) print '================ Creating coremod jar ===================' os.chdir(defaultWD) coremod_dir = os.path.join('mods', 'battlegear2', 'coremod') coremod_bin = os.path.join(mcpDir, 'bin', 'minecraft', coremod_dir) core_jar = zipfile.ZipFile( os.path.join( distDir, generateJarName('M&B Battlegear2 - Core', mcVersion, version)), 'w')
def getVersion(): from runtime.commands import Commands Commands._version_config = os.path.join(mcp_dir,Commands._version_config) print("Obtaining version information from git") execCmd("git checkout master") # Get tags from the master branch try: vers = execCmd("git describe --long --match='[^(jenkins)]*'") except OSError: print("Git not found") vers="v1.0-0-deadbeef" execCmd("git checkout %s" % branch) (major,minor,info,rev,githash)=re.match("v(\d+).(\d+)(-.*)?-(\d+)-(.*)",vers).groups() if not info: info="" (mcpversion,mcversion,mcserverversion) = re.match("[.\w]+ \(data: ([.\w]+), client: ([.\w.]+), server: ([.\w.]+)\)",Commands.fullversion()).groups() global verData verData = { "build.major.number": major, "build.minor.number": minor, "build.info": info, "build.revision.number": rev, "build.number": os.getenv('BUILD_NUMBER', 1), "githash": githash, "mcpversion": mcpversion, "mcversion": mcversion, } print("Version information: Boxes %s.%s.%s%s using MCP %s for %s" % (major, minor, rev, info, mcpversion, mcversion))
def main(): print("Obtaining version information from git") cmd = "git describe --long --match='[^(jenkins)]*'" try: process = subprocess.Popen(cmdsplit(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1) vers, _ = process.communicate() except OSError: print("Git not found") vers="v1.0-0-deadbeef" (major,minor,info,rev,githash)=re.match("v(\d+).(\d+)(-.*)?-(\d+)-(.*)",vers).groups() if not info: info="" (mcpversion,mcversion,mcserverversion) = re.match("[.\w]+ \(data: ([.\w]+), client: ([.\w.]+), server: ([.\w.]+)\)",Commands.fullversion()).groups() with open("version.properties","w") as f: f.write("%s=%s\n" %("Boxes.build.major.number",major)) f.write("%s=%s\n" %("Boxes.build.minor.number",minor)) f.write("%s=%s\n" %("Boxes.build.info",info)) f.write("%s=%s\n" %("Boxes.build.revision.number",rev)) f.write("%s=%s\n" %("Boxes.build.githash",githash)) f.write("%s=%s\n" %("Boxes.build.mcpversion",mcpversion)) f.write("%s=%s\n" %("Boxes.build.mcversion",mcversion)) for dirname, dirnames, filenames in os.walk('libs'): for fn in filenames: m = re.match(r'^(.*)-.*-(\d*\.\d*\.\d*\.\d*)-.*\.jar', fn) if m is not None: f.write("%s.version=%s\n" %(m.group(1), m.group(2))) print("Version information: Boxes %s.%s.%s%s using MCP %s for %s" % (major, minor, rev, info, mcpversion, mcversion))
def create_install(mcp_dir): print "Creating Installer..." srg = os.path.join(mcp_dir, 'class', 'srg') obf = os.path.join(mcp_dir, 'class', 'obf') resources = os.path.join(base_dir, "resources") patches = os.path.join(base_dir, 'patches') #use the java that mcp uses for compiling the installer and invoking launch4j dir = os.path.abspath(mcp_dir) sys.path.append(dir) os.chdir(dir) from runtime.commands import Commands commands = Commands(None, verify=True) print "java is " + commands.cmdjavac os.chdir("..") # in_mem_zip = StringIO.StringIO() with zipfile.ZipFile(in_mem_zip, 'w', zipfile.ZIP_DEFLATED) as zipout: vanilla = parse_srg_classnames( os.path.join(mcp_dir, "conf", "joined.srg")) for abs_path, _, filelist in os.walk(obf, followlinks=True): arc_path = os.path.relpath(abs_path, obf).replace( '\\', '/').replace('.', '') + '/' for cur_file in fnmatch.filter(filelist, '*.class'): #print arc_path + cur_file flg = False if not 'vivecraft' in (arc_path + cur_file).lower( ) and not 'jopenvr' in arc_path and not 'minecraftforge' in arc_path and not 'VR' in cur_file: #these misbehave when loaded in this jar, do some magic. flg = True ok = False v = (arc_path + cur_file).replace( '/', '\\').split('$')[0].replace('.class', '') cur_file_parent = cur_file.split('$')[0].replace( '.class', '') + '.class' if cur_file_parent in vanilla: v = vanilla[cur_file_parent].replace('/', '\\') for patch_path, _, patchlist in os.walk(patches, followlinks=True): for patch in fnmatch.filter(patchlist, '*.patch'): p = patch_path + '\\' + patch if v in p: #print 'Found ' + v + ' ' + p ok = True break if not ok: print "WARNING: Skipping unexpected file with no patch " + arc_path + cur_file_parent + ' (' + v + ')' continue if "blaze3d" in arc_path: flg = True in_file = os.path.join(abs_path, cur_file) arcname = arc_path + cur_file if flg: arcname = arc_path.replace('/', '.') + cur_file.replace( '.class', '.clazz') zipout.write(in_file, arcname.strip('.')) for abs_path, _, filelist in os.walk(srg, followlinks=True): arc_path = os.path.relpath(abs_path, srg).replace( '\\', '/').replace('.', '') + '/' for cur_file in fnmatch.filter(filelist, '*.class'): #print arc_path + cur_file flg = False if not 'vivecraft' in (arc_path + cur_file).lower( ) and not 'jopenvr' in arc_path and not 'minecraftforge' in arc_path and not 'VR' in cur_file: #these misbehave when loaded in this jar, do some magic. flg = True ok = False v = (arc_path + cur_file).replace( '/', '\\').split('$')[0].replace('.class', '') cur_file_parent = cur_file.split('$')[0].replace( '.class', '') + '.class' if cur_file_parent in vanilla: v = vanilla[cur_file_parent].replace('/', '\\') for patch_path, _, patchlist in os.walk(patches, followlinks=True): for patch in fnmatch.filter(patchlist, '*.patch'): p = patch_path + '\\' + patch if v in p: #print 'Found ' + v + ' ' + p ok = True break if not ok: print "WARNING: Skipping unexpected file with no patch " + arc_path + cur_file_parent + ' (' + v + ')' continue if "blaze3d" in arc_path: flg = True in_file = os.path.join(abs_path, cur_file) arcname = "/srg/" + arc_path + cur_file if flg: arcname = "/srg/" + arc_path + cur_file.replace( '.class', '.clsrg') zipout.write(in_file, arcname.strip('.')) print "Checking Resources..." for a, b, c in os.walk(resources): print a arc_path = os.path.relpath(a, resources).replace( '\\', '/').replace('.', '') + '/' for cur_file in c: print "Adding resource %s..." % cur_file in_file = os.path.join(a, cur_file) arcname = arc_path + cur_file zipout.write(in_file, arcname) print "Packaging mappings..." zipout.write(os.path.join(mcp_dir, "conf", "joined.srg"), "mappings/vivecraft/joined.srg") zipout.write( os.path.join(base_dir, "installer", "cpw.mods.modlauncher.api.ITransformationService"), "META-INF/services/cpw.mods.modlauncher.api.ITransformationService" ) os.chdir(base_dir) in_mem_zip.seek(0) if os.getenv("RELEASE_VERSION"): version = os.getenv("RELEASE_VERSION") elif os.getenv("BUILD_NUMBER"): version = "b" + os.getenv("BUILD_NUMBER") else: version = minecrift_build version = minecrift_version_num + "-" + version # Replace version info in installer.java print "Updating installer versions..." installer_java_file = os.path.join("installer", "Installer.java") replacelineinfile( installer_java_file, "private static final String PROJECT_NAME", " private static final String PROJECT_NAME = \"%s\";\n" % project_name) replacelineinfile( installer_java_file, "private static final String MINECRAFT_VERSION", " private static final String MINECRAFT_VERSION = \"%s\";\n" % mc_version) replacelineinfile( installer_java_file, "private static final String MC_VERSION", " private static final String MC_VERSION = \"%s\";\n" % minecrift_version_num) replacelineinfile( installer_java_file, "private static final String MC_MD5", " private static final String MC_MD5 = \"%s\";\n" % mc_file_md5) replacelineinfile( installer_java_file, "private static final String OF_FILE_NAME", " private static final String OF_FILE_NAME = \"%s\";\n" % of_file_name) replacelineinfile( installer_java_file, "private static final String OF_MD5", " private static final String OF_MD5 = \"%s\";\n" % of_file_md5) replacelineinfile( installer_java_file, "private static final String OF_VERSION_EXT", " private static final String OF_VERSION_EXT = \"%s\";\n" % of_file_extension) replacelineinfile( installer_java_file, "private static String FORGE_VERSION", " private static String FORGE_VERSION = \"%s\";\n" % forge_version) replacelineinfile( installer_java_file, "private static final String HOMEPAGE_LINK", " private static final String HOMEPAGE_LINK = \"%s\";\n" % homepage) replacelineinfile( installer_java_file, "private static final String DONATION_LINK", " private static final String DONATION_LINK = \"%s\";\n" % donation) replacelineinfile( installer_java_file, "private static final boolean ALLOW_FORGE_INSTALL", " private static final boolean ALLOW_FORGE_INSTALL = %s;\n" % str(allow_forge).lower()) replacelineinfile( installer_java_file, "private static final boolean DEFAULT_FORGE_INSTALL", " private static final boolean DEFAULT_FORGE_INSTALL= %s;\n" % str(forge_default).lower()) replacelineinfile( installer_java_file, "private static final boolean ALLOW_KATVR_INSTALL", " private static final boolean ALLOW_KATVR_INSTALL = %s;\n" % str(allow_katvr).lower()) replacelineinfile( installer_java_file, "private static final boolean ALLOW_KIOSK_INSTALL", " private static final boolean ALLOW_KIOSK_INSTALL = %s;\n" % str(allow_kiosk).lower()) replacelineinfile( installer_java_file, "private static final boolean ALLOW_ZGC_INSTALL", " private static final boolean ALLOW_ZGC_INSTALL = %s;\n" % str(allow_zgc).lower()) replacelineinfile( installer_java_file, "private static final boolean ALLOW_HRTF_INSTALL", " private static final boolean ALLOW_HRTF_INSTALL = %s;\n" % str(allow_hrtf).lower()) replacelineinfile( installer_java_file, "private static final boolean PROMPT_REMOVE_HRTF", " private static final boolean PROMPT_REMOVE_HRTF = %s;\n" % str(allow_remove_hrtf).lower()) # Build installer.java print "Recompiling Installer.java..." subprocess.Popen( cmdsplit(commands.cmdjavac + " -source 1.8 -target 1.8 \"%s\"" % os.path.join(base_dir, installer_java_file)), cwd=os.path.join(base_dir, "installer"), bufsize=-1).communicate() artifact_id = "vivecraft-" + version installer_id = artifact_id + "-installer" installer = os.path.join(installer_id + ".jar") shutil.copy(os.path.join("installer", "installer.jar"), installer) with zipfile.ZipFile( installer, 'a', zipfile.ZIP_DEFLATED) as install_out: #append to installer.jar # Add newly compiled class files for dirName, subdirList, fileList in os.walk("installer"): for afile in fileList: if os.path.isfile(os.path.join( dirName, afile)) and afile.endswith('.class'): relpath = os.path.relpath(dirName, "installer") print "Adding %s..." % os.path.join(relpath, afile) install_out.write(os.path.join(dirName, afile), os.path.join(relpath, afile)) # Add json files install_out.writestr( "version.json", process_json("", version, minecrift_version_num, "", of_file_name + "_LIB")) install_out.writestr( "version-forge.json", process_json("-forge", version, minecrift_version_num, forge_version, of_file_name + "_LIB")) install_out.writestr( "version-multimc.json", process_json("-multimc", version, minecrift_version_num, "", of_file_name + "_LIB")) install_out.writestr( "version-multimc-forge.json", process_json("-multimc-forge", version, minecrift_version_num, "", of_file_name + "_LIB")) # Add version jar - this contains all the changed files (effectively minecrift.jar). A mix # of obfuscated and non-obfuscated files. install_out.writestr("version.jar", in_mem_zip.read()) # Add the version info install_out.writestr("version", artifact_id + ":" + version) print("Creating Installer exe...") with open(os.path.join("installer", "launch4j.xml"), "r") as inlaunch: with open(os.path.join("installer", "launch4j", "launch4j.xml"), "w") as outlaunch: outlaunch.write(inlaunch.read().replace("installer", installer_id)) print("Invoking launch4j...") subprocess.Popen(cmdsplit( commands.cmdjava + " -jar \"%s\" \"%s\"" % (os.path.join(base_dir, "installer", "launch4j", "launch4j.jar"), os.path.join(base_dir, "installer", "launch4j", "launch4j.xml"))), cwd=os.path.join(base_dir, "installer", "launch4j"), bufsize=-1).communicate() os.unlink(os.path.join(base_dir, "installer", "launch4j", "launch4j.xml"))