2012-12-04 02:15:38 +00:00
|
|
|
import os, os.path, sys, zipfile
|
2012-08-01 23:35:35 +00:00
|
|
|
import shutil, glob, fnmatch
|
2012-12-04 02:15:38 +00:00
|
|
|
from optparse import OptionParser
|
2012-08-01 23:35:35 +00:00
|
|
|
|
|
|
|
forge_dir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
|
2012-08-15 06:57:16 +00:00
|
|
|
from forge import apply_forge_patches
|
2012-08-01 23:35:35 +00:00
|
|
|
|
|
|
|
def main():
|
|
|
|
print '=================================== Setup Start ================================='
|
2012-12-04 02:15:38 +00:00
|
|
|
|
|
|
|
parser = OptionParser()
|
|
|
|
parser.add_option('-m', '--mcp-dir', action='store', dest='mcp_dir', help='Path to download/extract MCP to', default=None)
|
|
|
|
parser.add_option('-n', '--no-extract', action='store_true', dest='no_extract', help='Do not attempt to extract FML zip files', default=False)
|
|
|
|
options, _ = parser.parse_args()
|
|
|
|
|
|
|
|
fml_dir = os.path.join(forge_dir, 'fml')
|
|
|
|
mcp_dir = os.path.join(forge_dir, 'mcp')
|
|
|
|
|
|
|
|
if not options.mcp_dir is None:
|
|
|
|
mcp_dir = os.path.abspath(options.mcp_dir)
|
|
|
|
elif os.path.isfile(os.path.join('..', 'runtime', 'commands.py')):
|
|
|
|
mcp_dir = os.path.abspath('..')
|
|
|
|
|
|
|
|
src_dir = os.path.join(mcp_dir, 'src')
|
|
|
|
|
|
|
|
setup_fml(mcp_dir, fml_dir, options.no_extract)
|
2012-08-01 23:35:35 +00:00
|
|
|
|
|
|
|
base_dir = os.path.join(mcp_dir, 'src_base')
|
|
|
|
work_dir = os.path.join(mcp_dir, 'src_work')
|
|
|
|
|
|
|
|
if os.path.isdir(base_dir):
|
|
|
|
shutil.rmtree(base_dir)
|
|
|
|
if os.path.isdir(work_dir):
|
|
|
|
shutil.rmtree(work_dir)
|
|
|
|
|
|
|
|
print 'Setting up source directories'
|
|
|
|
shutil.copytree(src_dir, base_dir)
|
|
|
|
shutil.copytree(src_dir, work_dir)
|
|
|
|
|
|
|
|
print 'Applying forge patches'
|
2012-08-04 07:55:17 +00:00
|
|
|
apply_forge_patches(os.path.join(forge_dir, 'fml'), mcp_dir, forge_dir, work_dir, False)
|
2012-08-01 23:35:35 +00:00
|
|
|
|
|
|
|
print '=================================== Setup Finished ================================='
|
|
|
|
|
2012-12-04 02:15:38 +00:00
|
|
|
def setup_fml(mcp_dir, fml_dir, dont_extract=False):
|
2012-08-01 23:35:35 +00:00
|
|
|
print 'Setting up Forge ModLoader'
|
2012-12-04 02:15:38 +00:00
|
|
|
if not dont_extract:
|
|
|
|
fml = glob.glob(os.path.join(forge_dir, 'fml-src-*.zip'))
|
|
|
|
if not len(fml) == 1:
|
|
|
|
if len(fml) == 0:
|
|
|
|
print 'Missing FML source zip, should be named fml-src-*.zip inside your forge folder, obtain it from the repo'
|
|
|
|
else:
|
|
|
|
print 'To many FML source zips found, we should only have one. Check the Forge Git for the latest FML version supported'
|
|
|
|
sys.exit(1)
|
2012-08-01 23:35:35 +00:00
|
|
|
|
2012-12-04 02:15:38 +00:00
|
|
|
if os.path.isdir(fml_dir):
|
|
|
|
shutil.rmtree(fml_dir)
|
|
|
|
|
|
|
|
print 'Extracting: %s' % os.path.basename(fml[0])
|
2012-08-01 23:35:35 +00:00
|
|
|
|
2012-12-04 02:15:38 +00:00
|
|
|
zf = zipfile.ZipFile(fml[0])
|
|
|
|
zf.extractall(forge_dir)
|
|
|
|
zf.close()
|
2012-08-01 23:35:35 +00:00
|
|
|
|
2012-08-04 07:55:17 +00:00
|
|
|
sys.path.append(fml_dir)
|
|
|
|
from install import fml_main
|
2012-08-15 06:57:16 +00:00
|
|
|
fml_main(fml_dir, mcp_dir, True)
|
2012-08-01 23:35:35 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2012-04-06 13:10:11 +00:00
|
|
|
main()
|