fix: reformat code

This commit is contained in:
Sefa Eyeoglu 2022-02-19 00:16:11 +01:00
parent a9ebc59353
commit f65b2666a0
No known key found for this signature in database
GPG Key ID: C10411294912A422
20 changed files with 352 additions and 217 deletions

View File

@ -7,18 +7,20 @@ from metautil import *
PMC_DIR = os.environ["PMC_DIR"] PMC_DIR = os.environ["PMC_DIR"]
#with open(PMC_DIR + '/index.json', 'r', encoding='utf-8') as index:
#packages = PolyMCPackageIndex(json.load(index))
#for entry in packages.packages: # with open(PMC_DIR + '/index.json', 'r', encoding='utf-8') as index:
#print (entry) # packages = PolyMCPackageIndex(json.load(index))
# for entry in packages.packages:
# print (entry)
class DownloadType(Enum): class DownloadType(Enum):
NORMAL = 1 NORMAL = 1
FORGE_XZ = 2 FORGE_XZ = 2
class DownloadEntry: class DownloadEntry:
def __init__(self, url : str, kind : DownloadType, name : GradleSpecifier): def __init__(self, url: str, kind: DownloadType, name: GradleSpecifier):
self.name = name self.name = name
self.url = url self.url = url
self.kind = kind self.kind = kind
@ -41,19 +43,21 @@ class DownloadEntry:
def __repr__(self): def __repr__(self):
return "DownloadEntry('" + self.toString() + "')" return "DownloadEntry('" + self.toString() + "')"
class MojangLibrary (JsonObject):
class MojangLibrary(JsonObject):
extract = ObjectProperty(MojangLibraryExtractRules, exclude_if_none=True, default=None) extract = ObjectProperty(MojangLibraryExtractRules, exclude_if_none=True, default=None)
name = GradleSpecifierProperty(required = True) name = GradleSpecifierProperty(required=True)
downloads = ObjectProperty(MojangLibraryDownloads, exclude_if_none=True, default=None) downloads = ObjectProperty(MojangLibraryDownloads, exclude_if_none=True, default=None)
natives = DictProperty(StringProperty, exclude_if_none=True, default=None) natives = DictProperty(StringProperty, exclude_if_none=True, default=None)
rules = ListProperty(MojangRule, exclude_if_none=True, default=None) rules = ListProperty(MojangRule, exclude_if_none=True, default=None)
class PolyMCLibrary (MojangLibrary):
class PolyMCLibrary(MojangLibrary):
url = StringProperty(exclude_if_none=True, default=None) url = StringProperty(exclude_if_none=True, default=None)
mmcHint = StringProperty(name="MMC-hint", exclude_if_none=True, default=None) # this is supposed to be MMC-hint! mmcHint = StringProperty(name="MMC-hint", exclude_if_none=True, default=None) # this is supposed to be MMC-hint!
def GetLibraryDownload (library : PolyMCLibrary): def GetLibraryDownload(library: PolyMCLibrary):
if library.natives: if library.natives:
raise Exception('Natives are not handled yet') raise Exception('Natives are not handled yet')
@ -69,7 +73,6 @@ def GetLibraryDownload (library : PolyMCLibrary):
if url.endswith('.zip'): if url.endswith('.zip'):
name.extension = 'zip' name.extension = 'zip'
if library.downloads: if library.downloads:
url = library.downloads.artifact.url url = library.downloads.artifact.url
else: else:
@ -80,6 +83,7 @@ def GetLibraryDownload (library : PolyMCLibrary):
return DownloadEntry(url, kind, name) return DownloadEntry(url, kind, name)
with open(PMC_DIR + '/net.minecraftforge/index.json', 'r', encoding='utf-8') as forgeIndex: with open(PMC_DIR + '/net.minecraftforge/index.json', 'r', encoding='utf-8') as forgeIndex:
forgeVersions = PolyMCVersionIndex(json.load(forgeIndex)) forgeVersions = PolyMCVersionIndex(json.load(forgeIndex))

View File

@ -7,14 +7,17 @@ class FabricInstallerArguments(JsonObject):
common = ListProperty(StringProperty) common = ListProperty(StringProperty)
server = ListProperty(StringProperty) server = ListProperty(StringProperty)
class FabricInstallerLaunchwrapper(JsonObject): class FabricInstallerLaunchwrapper(JsonObject):
tweakers = ObjectProperty(FabricInstallerArguments, required=True) tweakers = ObjectProperty(FabricInstallerArguments, required=True)
class FabricInstallerLibraries(JsonObject): class FabricInstallerLibraries(JsonObject):
client = ListProperty(PolyMCLibrary) client = ListProperty(PolyMCLibrary)
common = ListProperty(PolyMCLibrary) common = ListProperty(PolyMCLibrary)
server = ListProperty(PolyMCLibrary) server = ListProperty(PolyMCLibrary)
class FabricInstallerDataV1(JsonObject): class FabricInstallerDataV1(JsonObject):
version = IntegerProperty(required=True) version = IntegerProperty(required=True)
libraries = ObjectProperty(FabricInstallerLibraries, required=True) libraries = ObjectProperty(FabricInstallerLibraries, required=True)
@ -22,6 +25,7 @@ class FabricInstallerDataV1(JsonObject):
arguments = ObjectProperty(FabricInstallerArguments, required=False) arguments = ObjectProperty(FabricInstallerArguments, required=False)
launchwrapper = ObjectProperty(FabricInstallerLaunchwrapper, required=False) launchwrapper = ObjectProperty(FabricInstallerLaunchwrapper, required=False)
class FabricJarInfo(JsonObject): class FabricJarInfo(JsonObject):
releaseTime = ISOTimestampProperty() releaseTime = ISOTimestampProperty()
size = IntegerProperty() size = IntegerProperty()

View File

@ -67,12 +67,13 @@ class ForgeVersion:
if not majorVersionStr.isnumeric(): if not majorVersionStr.isnumeric():
return False return False
#majorVersion = int(majorVersionStr) # majorVersion = int(majorVersionStr)
#if majorVersion >= 37: # if majorVersion >= 37:
# return False # return False
return True return True
class ForgeFile(JsonObject): class ForgeFile(JsonObject):
classifier = StringProperty(required=True) classifier = StringProperty(required=True)
hash = StringProperty(required=True) hash = StringProperty(required=True)
@ -82,7 +83,9 @@ class ForgeFile(JsonObject):
return "%s-%s-%s.%s" % ("forge", longversion, self.classifier, self.extension) return "%s-%s-%s.%s" % ("forge", longversion, self.classifier, self.extension)
def url(self, longversion): def url(self, longversion):
return "https://files.minecraftforge.net/maven/net/minecraftforge/forge/%s/%s" % (longversion, self.filename(longversion)) return "https://files.minecraftforge.net/maven/net/minecraftforge/forge/%s/%s" % (
longversion, self.filename(longversion))
class ForgeEntry(JsonObject): class ForgeEntry(JsonObject):
longversion = StringProperty(required=True) longversion = StringProperty(required=True)
@ -94,15 +97,18 @@ class ForgeEntry(JsonObject):
recommended = BooleanProperty() recommended = BooleanProperty()
files = DictProperty(ForgeFile) files = DictProperty(ForgeFile)
class ForgeMcVersionInfo(JsonObject): class ForgeMcVersionInfo(JsonObject):
latest = StringProperty() latest = StringProperty()
recommended = StringProperty() recommended = StringProperty()
versions = ListProperty(StringProperty()) versions = ListProperty(StringProperty())
class DerivedForgeIndex(JsonObject): class DerivedForgeIndex(JsonObject):
versions = DictProperty(ForgeEntry) versions = DictProperty(ForgeEntry)
by_mcversion = DictProperty(ForgeMcVersionInfo) by_mcversion = DictProperty(ForgeMcVersionInfo)
''' '''
FML library mappings - these are added to legacy Forge versions because Forge no longer can download these FML library mappings - these are added to legacy Forge versions because Forge no longer can download these
by itself - the locations have changed and some of this has to be rehosted on PolyMC servers. by itself - the locations have changed and some of this has to be rehosted on PolyMC servers.
@ -185,30 +191,35 @@ fmlLibsMapping["1.5.2"] = [
"modList":"none" "modList":"none"
}, },
''' '''
class ForgeInstallerProfileInstallSection(JsonObject): class ForgeInstallerProfileInstallSection(JsonObject):
profileName = StringProperty(required = True) profileName = StringProperty(required=True)
target = StringProperty(required = True) target = StringProperty(required=True)
path = GradleSpecifierProperty(required = True) path = GradleSpecifierProperty(required=True)
version = StringProperty(required = True) version = StringProperty(required=True)
filePath = StringProperty(required = True) filePath = StringProperty(required=True)
welcome = StringProperty(required = True) welcome = StringProperty(required=True)
minecraft = StringProperty(required = True) minecraft = StringProperty(required=True)
logo = StringProperty(required = True) logo = StringProperty(required=True)
mirrorList = StringProperty(required = True) mirrorList = StringProperty(required=True)
modList = StringProperty(exclude_if_none=True, default=None) modList = StringProperty(exclude_if_none=True, default=None)
class ForgeLibrary (MojangLibrary):
class ForgeLibrary(MojangLibrary):
url = StringProperty(exclude_if_none=True) url = StringProperty(exclude_if_none=True)
serverreq = BooleanProperty(exclude_if_none=True, default=None) serverreq = BooleanProperty(exclude_if_none=True, default=None)
clientreq = BooleanProperty(exclude_if_none=True, default=None) clientreq = BooleanProperty(exclude_if_none=True, default=None)
checksums = ListProperty(StringProperty) checksums = ListProperty(StringProperty)
comment = StringProperty() comment = StringProperty()
class ForgeVersionFile (MojangVersionFile):
libraries = ListProperty(ForgeLibrary, exclude_if_none=True, default=None) # overrides Mojang libraries class ForgeVersionFile(MojangVersionFile):
libraries = ListProperty(ForgeLibrary, exclude_if_none=True, default=None) # overrides Mojang libraries
inheritsFrom = StringProperty() inheritsFrom = StringProperty()
jar = StringProperty() jar = StringProperty()
''' '''
"optionals": [ "optionals": [
{ {
@ -224,7 +235,9 @@ class ForgeVersionFile (MojangVersionFile):
} }
] ]
''' '''
class ForgeOptional (JsonObject):
class ForgeOptional(JsonObject):
name = StringProperty() name = StringProperty()
client = BooleanProperty() client = BooleanProperty()
server = BooleanProperty() server = BooleanProperty()
@ -235,24 +248,29 @@ class ForgeOptional (JsonObject):
artifact = GradleSpecifierProperty() artifact = GradleSpecifierProperty()
maven = StringProperty() maven = StringProperty()
class ForgeInstallerProfile(JsonObject): class ForgeInstallerProfile(JsonObject):
install = ObjectProperty(ForgeInstallerProfileInstallSection, required = True) install = ObjectProperty(ForgeInstallerProfileInstallSection, required=True)
versionInfo = ObjectProperty(ForgeVersionFile, required = True) versionInfo = ObjectProperty(ForgeVersionFile, required=True)
optionals = ListProperty(ForgeOptional) optionals = ListProperty(ForgeOptional)
class ForgeLegacyInfo(JsonObject): class ForgeLegacyInfo(JsonObject):
releaseTime = ISOTimestampProperty() releaseTime = ISOTimestampProperty()
size = IntegerProperty() size = IntegerProperty()
sha256 = StringProperty() sha256 = StringProperty()
sha1 = StringProperty() sha1 = StringProperty()
class ForgeLegacyInfoList(JsonObject): class ForgeLegacyInfoList(JsonObject):
number = DictProperty(ForgeLegacyInfo) number = DictProperty(ForgeLegacyInfo)
class DataSpec(JsonObject): class DataSpec(JsonObject):
client = StringProperty() client = StringProperty()
server = StringProperty() server = StringProperty()
class ProcessorSpec(JsonObject): class ProcessorSpec(JsonObject):
jar = StringProperty() jar = StringProperty()
classpath = ListProperty(StringProperty) classpath = ListProperty(StringProperty)
@ -260,6 +278,7 @@ class ProcessorSpec(JsonObject):
outputs = DictProperty(StringProperty) outputs = DictProperty(StringProperty)
sides = ListProperty(StringProperty, exclude_if_none=True, default=None) sides = ListProperty(StringProperty, exclude_if_none=True, default=None)
# Note: This is only used in one version (1.12.2-14.23.5.2851) and we don't even use the installer profile in it. # Note: This is only used in one version (1.12.2-14.23.5.2851) and we don't even use the installer profile in it.
# It's here just so it parses and we can continue... # It's here just so it parses and we can continue...
class ForgeInstallerProfileV1_5(JsonObject): class ForgeInstallerProfileV1_5(JsonObject):
@ -279,6 +298,7 @@ class ForgeInstallerProfileV1_5(JsonObject):
libraries = ListProperty(MojangLibrary) libraries = ListProperty(MojangLibrary)
mirrorList = StringProperty(exclude_if_none=True, default=None) mirrorList = StringProperty(exclude_if_none=True, default=None)
class ForgeInstallerProfileV2(JsonObject): class ForgeInstallerProfileV2(JsonObject):
_comment = ListProperty(StringProperty) _comment = ListProperty(StringProperty)
spec = IntegerProperty() spec = IntegerProperty()
@ -296,6 +316,7 @@ class ForgeInstallerProfileV2(JsonObject):
mirrorList = StringProperty(exclude_if_none=True, default=None) mirrorList = StringProperty(exclude_if_none=True, default=None)
serverJarPath = StringProperty(exclude_if_none=True, default=None) serverJarPath = StringProperty(exclude_if_none=True, default=None)
class InstallerInfo(JsonObject): class InstallerInfo(JsonObject):
sha1hash = StringProperty() sha1hash = StringProperty()
sha256hash = StringProperty() sha256hash = StringProperty()

View File

@ -9,17 +9,22 @@ loaderVersions = []
intermediaryRecommended = [] intermediaryRecommended = []
intermediaryVersions = [] intermediaryVersions = []
def mkdirs(path): def mkdirs(path):
if not os.path.exists(path): if not os.path.exists(path):
os.makedirs(path) os.makedirs(path)
mkdirs(PMC_DIR + "/net.fabricmc.fabric-loader") mkdirs(PMC_DIR + "/net.fabricmc.fabric-loader")
mkdirs(PMC_DIR + "/net.fabricmc.intermediary") mkdirs(PMC_DIR + "/net.fabricmc.intermediary")
def loadJarInfo(mavenKey): def loadJarInfo(mavenKey):
with open(UPSTREAM_DIR + "/fabric/jars/" + mavenKey.replace(":", ".") + ".json", 'r', encoding='utf-8') as jarInfoFile: with open(UPSTREAM_DIR + "/fabric/jars/" + mavenKey.replace(":", ".") + ".json", 'r',
encoding='utf-8') as jarInfoFile:
return FabricJarInfo(json.load(jarInfoFile)) return FabricJarInfo(json.load(jarInfoFile))
def processLoaderVersion(loaderVersion, it, loaderData): def processLoaderVersion(loaderVersion, it, loaderData):
verStable = it["stable"] verStable = it["stable"]
if (len(loaderRecommended) < 1) and verStable: if (len(loaderRecommended) < 1) and verStable:
@ -41,6 +46,7 @@ def processLoaderVersion(loaderVersion, it, loaderData):
version.libraries.append(loaderLib) version.libraries.append(loaderLib)
loaderVersions.append(version) loaderVersions.append(version)
def processIntermediaryVersion(it): def processIntermediaryVersion(it):
intermediaryRecommended.append(it["version"]) intermediaryRecommended.append(it["version"])
versionJarInfo = loadJarInfo(it["maven"]) versionJarInfo = loadJarInfo(it["maven"])
@ -55,11 +61,13 @@ def processIntermediaryVersion(it):
version.libraries.append(mappingLib) version.libraries.append(mappingLib)
intermediaryVersions.append(version) intermediaryVersions.append(version)
with open(UPSTREAM_DIR + "/fabric/meta-v2/loader.json", 'r', encoding='utf-8') as loaderVersionIndexFile: with open(UPSTREAM_DIR + "/fabric/meta-v2/loader.json", 'r', encoding='utf-8') as loaderVersionIndexFile:
loaderVersionIndex = json.load(loaderVersionIndexFile) loaderVersionIndex = json.load(loaderVersionIndexFile)
for it in loaderVersionIndex: for it in loaderVersionIndex:
version = it["version"] version = it["version"]
with open(UPSTREAM_DIR + "/fabric/loader-installer-json/" + version + ".json", 'r', encoding='utf-8') as loaderVersionFile: with open(UPSTREAM_DIR + "/fabric/loader-installer-json/" + version + ".json", 'r',
encoding='utf-8') as loaderVersionFile:
ldata = json.load(loaderVersionFile) ldata = json.load(loaderVersionFile)
ldata = FabricInstallerDataV1(ldata) ldata = FabricInstallerDataV1(ldata)
processLoaderVersion(version, it, ldata) processLoaderVersion(version, it, ldata)
@ -74,7 +82,7 @@ for version in loaderVersions:
with open(outFilepath, 'w') as outfile: with open(outFilepath, 'w') as outfile:
json.dump(version.to_json(), outfile, sort_keys=True, indent=4) json.dump(version.to_json(), outfile, sort_keys=True, indent=4)
sharedData = PolyMCSharedPackageData(uid = 'net.fabricmc.fabric-loader', name = 'Fabric Loader') sharedData = PolyMCSharedPackageData(uid='net.fabricmc.fabric-loader', name='Fabric Loader')
sharedData.recommended = loaderRecommended sharedData.recommended = loaderRecommended
sharedData.description = "Fabric Loader is a tool to load Fabric-compatible mods in game environments." sharedData.description = "Fabric Loader is a tool to load Fabric-compatible mods in game environments."
sharedData.projectUrl = "https://fabricmc.net" sharedData.projectUrl = "https://fabricmc.net"
@ -86,7 +94,7 @@ for version in intermediaryVersions:
with open(outFilepath, 'w') as outfile: with open(outFilepath, 'w') as outfile:
json.dump(version.to_json(), outfile, sort_keys=True, indent=4) json.dump(version.to_json(), outfile, sort_keys=True, indent=4)
sharedData = PolyMCSharedPackageData(uid = 'net.fabricmc.intermediary', name = 'Intermediary Mappings') sharedData = PolyMCSharedPackageData(uid='net.fabricmc.intermediary', name='Intermediary Mappings')
sharedData.recommended = intermediaryRecommended sharedData.recommended = intermediaryRecommended
sharedData.description = "Intermediary mappings allow using Fabric Loader with mods for Minecraft in a more compatible manner." sharedData.description = "Intermediary mappings allow using Fabric Loader with mods for Minecraft in a more compatible manner."
sharedData.projectUrl = "https://fabricmc.net" sharedData.projectUrl = "https://fabricmc.net"

View File

@ -8,11 +8,15 @@ from metautil import *
PMC_DIR = os.environ["PMC_DIR"] PMC_DIR = os.environ["PMC_DIR"]
UPSTREAM_DIR = os.environ["UPSTREAM_DIR"] UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
def eprint(*args, **kwargs): def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs) print(*args, file=sys.stderr, **kwargs)
# Contruct a set of libraries out of a Minecraft version file, for filtering. # Contruct a set of libraries out of a Minecraft version file, for filtering.
mcVersionCache = {} mcVersionCache = {}
def loadMcVersionFilter(version): def loadMcVersionFilter(version):
if version in mcVersionCache: if version in mcVersionCache:
return mcVersionCache[version] return mcVersionCache[version]
@ -24,11 +28,14 @@ def loadMcVersionFilter(version):
mcVersionCache[version] = libSet mcVersionCache[version] = libSet
return libSet return libSet
''' '''
Match a library coordinate to a set of library coordinates. Match a library coordinate to a set of library coordinates.
* Block those that pass completely. * Block those that pass completely.
* For others, block those with lower versions than in the set. * For others, block those with lower versions than in the set.
''' '''
def shouldIgnoreArtifact(libSet, match): def shouldIgnoreArtifact(libSet, match):
for ver in libSet: for ver in libSet:
if ver.group == match.group and ver.artifact == match.artifact and ver.classifier == match.classifier: if ver.group == match.group and ver.artifact == match.artifact and ver.classifier == match.classifier:
@ -45,8 +52,9 @@ def shouldIgnoreArtifact(libSet, match):
# No match found in the set - we need to keep this # No match found in the set - we need to keep this
return False return False
def versionFromProfile(profile, version): def versionFromProfile(profile, version):
result = PolyMCVersionFile({"name":"Forge", "version":version.rawVersion, "uid":"net.minecraftforge" }) result = PolyMCVersionFile({"name": "Forge", "version": version.rawVersion, "uid": "net.minecraftforge"})
mcversion = profile.install.minecraft mcversion = profile.install.minecraft
result.requires = [DependencyEntry(uid='net.minecraft', equals=mcversion)] result.requires = [DependencyEntry(uid='net.minecraft', equals=mcversion)]
result.mainClass = profile.versionInfo.mainClass result.mainClass = profile.versionInfo.mainClass
@ -85,16 +93,17 @@ def versionFromProfile(profile, version):
ourLib.url = "https://maven.minecraftforge.net/" ourLib.url = "https://maven.minecraftforge.net/"
else: else:
ourLib.url = forgeLib.url ourLib.url = forgeLib.url
#if forgeLib.checksums and len(forgeLib.checksums) == 2: # if forgeLib.checksums and len(forgeLib.checksums) == 2:
# ourLib.mmcHint = "forge-pack-xz" # ourLib.mmcHint = "forge-pack-xz"
libs.append(ourLib) libs.append(ourLib)
result.libraries = libs result.libraries = libs
result.order = 5 result.order = 5
return result return result
def versionFromModernizedInstaller(installerVersion : MojangVersionFile, version: ForgeVersion):
def versionFromModernizedInstaller(installerVersion: MojangVersionFile, version: ForgeVersion):
eprint("Generating Modernized Forge %s." % version.longVersion) eprint("Generating Modernized Forge %s." % version.longVersion)
result = PolyMCVersionFile({"name":"Forge", "version":version.rawVersion, "uid":"net.minecraftforge" }) result = PolyMCVersionFile({"name": "Forge", "version": version.rawVersion, "uid": "net.minecraftforge"})
mcversion = version.mcversion mcversion = version.mcversion
result.requires = [DependencyEntry(uid='net.minecraft', equals=mcversion)] result.requires = [DependencyEntry(uid='net.minecraft', equals=mcversion)]
result.mainClass = installerVersion.mainClass result.mainClass = installerVersion.mainClass
@ -146,8 +155,9 @@ def versionFromModernizedInstaller(installerVersion : MojangVersionFile, version
result.order = 5 result.order = 5
return result return result
def versionFromLegacy(version, legacyinfo : ForgeLegacyInfo):
result = PolyMCVersionFile({"name":"Forge", "version":version.rawVersion, "uid":"net.minecraftforge" }) def versionFromLegacy(version, legacyinfo: ForgeLegacyInfo):
result = PolyMCVersionFile({"name": "Forge", "version": version.rawVersion, "uid": "net.minecraftforge"})
mcversion = version.mcversion_sane mcversion = version.mcversion_sane
result.requires = [DependencyEntry(uid='net.minecraft', equals=mcversion)] result.requires = [DependencyEntry(uid='net.minecraft', equals=mcversion)]
result.releaseTime = legacyinfo.releaseTime result.releaseTime = legacyinfo.releaseTime
@ -160,8 +170,8 @@ def versionFromLegacy(version, legacyinfo : ForgeLegacyInfo):
classifier = "universal" classifier = "universal"
else: else:
classifier = "client" classifier = "client"
coord = GradleSpecifier("net.minecraftforge:forge:%s:%s" % (version.longVersion,classifier)) coord = GradleSpecifier("net.minecraftforge:forge:%s:%s" % (version.longVersion, classifier))
mainmod = PolyMCLibrary(name = coord) mainmod = PolyMCLibrary(name=coord)
mainmod.downloads = MojangLibraryDownloads() mainmod.downloads = MojangLibraryDownloads()
mainmod.downloads.artifact = MojangArtifact() mainmod.downloads.artifact = MojangArtifact()
mainmod.downloads.artifact.path = None mainmod.downloads.artifact.path = None
@ -171,9 +181,11 @@ def versionFromLegacy(version, legacyinfo : ForgeLegacyInfo):
result.jarMods = [mainmod] result.jarMods = [mainmod]
return result return result
def versionFromBuildSystemInstaller(installerVersion : MojangVersionFile, installerProfile: ForgeInstallerProfileV2, version: ForgeVersion):
def versionFromBuildSystemInstaller(installerVersion: MojangVersionFile, installerProfile: ForgeInstallerProfileV2,
version: ForgeVersion):
eprint("Generating Forge %s." % version.longVersion) eprint("Generating Forge %s." % version.longVersion)
result = PolyMCVersionFile({"name":"Forge", "version":version.rawVersion, "uid":"net.minecraftforge" }) result = PolyMCVersionFile({"name": "Forge", "version": version.rawVersion, "uid": "net.minecraftforge"})
result.requires = [DependencyEntry(uid='net.minecraft', equals=version.mcversion_sane)] result.requires = [DependencyEntry(uid='net.minecraft', equals=version.mcversion_sane)]
result.mainClass = "io.github.zekerzhayard.forgewrapper.installer.Main" result.mainClass = "io.github.zekerzhayard.forgewrapper.installer.Main"
@ -183,10 +195,12 @@ def versionFromBuildSystemInstaller(installerVersion : MojangVersionFile, instal
# load the locally cached installer file info and use it to add the installer entry in the json # load the locally cached installer file info and use it to add the installer entry in the json
with open(UPSTREAM_DIR + "/forge/installer_info/%s.json" % version.longVersion, 'r', encoding='utf-8') as f: with open(UPSTREAM_DIR + "/forge/installer_info/%s.json" % version.longVersion, 'r', encoding='utf-8') as f:
installerInfo = InstallerInfo(json.load(f)) installerInfo = InstallerInfo(json.load(f))
InstallerLib = PolyMCLibrary(name=GradleSpecifier("net.minecraftforge:forge:%s:installer" % (version.longVersion))) InstallerLib = PolyMCLibrary(
name=GradleSpecifier("net.minecraftforge:forge:%s:installer" % (version.longVersion)))
InstallerLib.downloads = MojangLibraryDownloads() InstallerLib.downloads = MojangLibraryDownloads()
InstallerLib.downloads.artifact = MojangArtifact() InstallerLib.downloads.artifact = MojangArtifact()
InstallerLib.downloads.artifact.url = "https://files.minecraftforge.net/maven/%s" % (InstallerLib.name.getPath()) InstallerLib.downloads.artifact.url = "https://files.minecraftforge.net/maven/%s" % (
InstallerLib.name.getPath())
InstallerLib.downloads.artifact.sha1 = installerInfo.sha1hash InstallerLib.downloads.artifact.sha1 = installerInfo.sha1hash
InstallerLib.downloads.artifact.size = installerInfo.size InstallerLib.downloads.artifact.size = installerInfo.size
mavenLibs.append(InstallerLib) mavenLibs.append(InstallerLib)
@ -206,61 +220,61 @@ def versionFromBuildSystemInstaller(installerVersion : MojangVersionFile, instal
result.mavenFiles = mavenLibs result.mavenFiles = mavenLibs
libraries = [] libraries = []
#wrapperLib = PolyMCLibrary(name=GradleSpecifier("io.github.zekerzhayard:ForgeWrapper:1.4.1")) # wrapperLib = PolyMCLibrary(name=GradleSpecifier("io.github.zekerzhayard:ForgeWrapper:1.4.1"))
#wrapperLib.downloads = MojangLibraryDownloads() # wrapperLib.downloads = MojangLibraryDownloads()
#wrapperLib.downloads.artifact = MojangArtifact() # wrapperLib.downloads.artifact = MojangArtifact()
#wrapperLib.downloads.artifact.url = "https://meta.polymc.org/maven/%s" % (wrapperLib.name.getPath()) # wrapperLib.downloads.artifact.url = "https://meta.polymc.org/maven/%s" % (wrapperLib.name.getPath())
#wrapperLib.downloads.artifact.sha1 = "82f01de97e29ba34be9fc628084b6d10ce2235c5" # wrapperLib.downloads.artifact.sha1 = "82f01de97e29ba34be9fc628084b6d10ce2235c5"
#wrapperLib.downloads.artifact.size = 14351 # wrapperLib.downloads.artifact.size = 14351
#libraries.append(wrapperLib) # libraries.append(wrapperLib)
#wrapperLib = PolyMCLibrary(name=GradleSpecifier("io.github.zekerzhayard:ForgeWrapper:1.4.2")) # wrapperLib = PolyMCLibrary(name=GradleSpecifier("io.github.zekerzhayard:ForgeWrapper:1.4.2"))
#wrapperLib.downloads = MojangLibraryDownloads() # wrapperLib.downloads = MojangLibraryDownloads()
#wrapperLib.downloads.artifact = MojangArtifact() # wrapperLib.downloads.artifact = MojangArtifact()
#wrapperLib.downloads.artifact.url = "https://meta.polymc.org/maven/%s" % (wrapperLib.name.getPath()) # wrapperLib.downloads.artifact.url = "https://meta.polymc.org/maven/%s" % (wrapperLib.name.getPath())
#wrapperLib.downloads.artifact.sha1 = "79ff9c1530e8743450c5c3ebc6e07b535437aa6e" # wrapperLib.downloads.artifact.sha1 = "79ff9c1530e8743450c5c3ebc6e07b535437aa6e"
#wrapperLib.downloads.artifact.size = 22346 # wrapperLib.downloads.artifact.size = 22346
#libraries.append(wrapperLib) # libraries.append(wrapperLib)
#wrapperLib = PolyMCLibrary(name=GradleSpecifier("io.github.zekerzhayard:ForgeWrapper:1.5.1")) # wrapperLib = PolyMCLibrary(name=GradleSpecifier("io.github.zekerzhayard:ForgeWrapper:1.5.1"))
#wrapperLib.downloads = MojangLibraryDownloads() # wrapperLib.downloads = MojangLibraryDownloads()
#wrapperLib.downloads.artifact = MojangArtifact() # wrapperLib.downloads.artifact = MojangArtifact()
#wrapperLib.downloads.artifact.url = "https://meta.polymc.org/maven/%s" % (wrapperLib.name.getPath()) # wrapperLib.downloads.artifact.url = "https://meta.polymc.org/maven/%s" % (wrapperLib.name.getPath())
#wrapperLib.downloads.artifact.sha1 = "90104e9aaa8fbedf6c3d1f6d0b90cabce080b5a9" # wrapperLib.downloads.artifact.sha1 = "90104e9aaa8fbedf6c3d1f6d0b90cabce080b5a9"
#wrapperLib.downloads.artifact.size = 29892 # wrapperLib.downloads.artifact.size = 29892
#libraries.append(wrapperLib) # libraries.append(wrapperLib)
#wrapperLib = PolyMCLibrary(name=GradleSpecifier("io.github.zekerzhayard:ForgeWrapper:1.5.3")) # wrapperLib = PolyMCLibrary(name=GradleSpecifier("io.github.zekerzhayard:ForgeWrapper:1.5.3"))
#wrapperLib.downloads = MojangLibraryDownloads() # wrapperLib.downloads = MojangLibraryDownloads()
#wrapperLib.downloads.artifact = MojangArtifact() # wrapperLib.downloads.artifact = MojangArtifact()
#wrapperLib.downloads.artifact.url = "https://meta.polymc.org/maven/%s" % (wrapperLib.name.getPath()) # wrapperLib.downloads.artifact.url = "https://meta.polymc.org/maven/%s" % (wrapperLib.name.getPath())
#wrapperLib.downloads.artifact.sha1 = "2b0e06937349a209dbb90dca6381258daa456ad7" # wrapperLib.downloads.artifact.sha1 = "2b0e06937349a209dbb90dca6381258daa456ad7"
#wrapperLib.downloads.artifact.size = 30486 # wrapperLib.downloads.artifact.size = 30486
#libraries.append(wrapperLib) # libraries.append(wrapperLib)
#wrapperLib = PolyMCLibrary(name=GradleSpecifier("io.github.zekerzhayard:ForgeWrapper:1.5.4")) # wrapperLib = PolyMCLibrary(name=GradleSpecifier("io.github.zekerzhayard:ForgeWrapper:1.5.4"))
#wrapperLib.downloads = MojangLibraryDownloads() # wrapperLib.downloads = MojangLibraryDownloads()
#wrapperLib.downloads.artifact = MojangArtifact() # wrapperLib.downloads.artifact = MojangArtifact()
#wrapperLib.downloads.artifact.url = "https://meta.polymc.org/maven/%s" % (wrapperLib.name.getPath()) # wrapperLib.downloads.artifact.url = "https://meta.polymc.org/maven/%s" % (wrapperLib.name.getPath())
#wrapperLib.downloads.artifact.sha1 = "e97805af76d4c1cebb753132eadbabd92e67a17b" # wrapperLib.downloads.artifact.sha1 = "e97805af76d4c1cebb753132eadbabd92e67a17b"
#wrapperLib.downloads.artifact.size = 34299 # wrapperLib.downloads.artifact.size = 34299
#libraries.append(wrapperLib) # libraries.append(wrapperLib)
#wrapperLib = PolyMCLibrary(name=GradleSpecifier("io.github.zekerzhayard:ForgeWrapper:pmc1")) # wrapperLib = PolyMCLibrary(name=GradleSpecifier("io.github.zekerzhayard:ForgeWrapper:pmc1"))
#wrapperLib.downloads = MojangLibraryDownloads() # wrapperLib.downloads = MojangLibraryDownloads()
#wrapperLib.downloads.artifact = MojangArtifact() # wrapperLib.downloads.artifact = MojangArtifact()
#wrapperLib.downloads.artifact.url = "https://meta.polymc.org/maven/%s" % (wrapperLib.name.getPath()) # wrapperLib.downloads.artifact.url = "https://meta.polymc.org/maven/%s" % (wrapperLib.name.getPath())
#wrapperLib.downloads.artifact.sha1 = "e8e0fe708742ecf15ab4af55ae8227fa4349362d" # wrapperLib.downloads.artifact.sha1 = "e8e0fe708742ecf15ab4af55ae8227fa4349362d"
#wrapperLib.downloads.artifact.size = 34628 # wrapperLib.downloads.artifact.size = 34628
#libraries.append(wrapperLib) # libraries.append(wrapperLib)
#wrapperLib = PolyMCLibrary(name=GradleSpecifier("io.github.zekerzhayard:ForgeWrapper:1.5.5")) # wrapperLib = PolyMCLibrary(name=GradleSpecifier("io.github.zekerzhayard:ForgeWrapper:1.5.5"))
#wrapperLib.downloads = MojangLibraryDownloads() # wrapperLib.downloads = MojangLibraryDownloads()
#wrapperLib.downloads.artifact = MojangArtifact() # wrapperLib.downloads.artifact = MojangArtifact()
#wrapperLib.downloads.artifact.url = "https://meta.polymc.org/maven/%s" % (wrapperLib.name.getPath()) # wrapperLib.downloads.artifact.url = "https://meta.polymc.org/maven/%s" % (wrapperLib.name.getPath())
#wrapperLib.downloads.artifact.sha1 = "566dfd60aacffaa02884614835f1151d36f1f985" # wrapperLib.downloads.artifact.sha1 = "566dfd60aacffaa02884614835f1151d36f1f985"
#wrapperLib.downloads.artifact.size = 34331 # wrapperLib.downloads.artifact.size = 34331
#libraries.append(wrapperLib) # libraries.append(wrapperLib)
wrapperLib = PolyMCLibrary(name=GradleSpecifier("io.github.zekerzhayard:ForgeWrapper:pmc2")) wrapperLib = PolyMCLibrary(name=GradleSpecifier("io.github.zekerzhayard:ForgeWrapper:pmc2"))
wrapperLib.downloads = MojangLibraryDownloads() wrapperLib.downloads = MojangLibraryDownloads()
@ -347,26 +361,26 @@ legacyVersions = [
for id, entry in remoteVersionlist.versions.items(): for id, entry in remoteVersionlist.versions.items():
if entry.mcversion == None: if entry.mcversion == None:
eprint ("Skipping %s with invalid MC version" % id) eprint("Skipping %s with invalid MC version" % id)
continue continue
version = ForgeVersion(entry) version = ForgeVersion(entry)
if version.url() == None: if version.url() == None:
eprint ("Skipping %s with no valid files" % id) eprint("Skipping %s with no valid files" % id)
continue continue
eprint ("Processing Forge %s" % version.rawVersion) eprint("Processing Forge %s" % version.rawVersion)
versionElements = version.rawVersion.split('.') versionElements = version.rawVersion.split('.')
if len(versionElements) < 1: if len(versionElements) < 1:
eprint ("Skipping version %s with not enough version elements" % (id)) eprint("Skipping version %s with not enough version elements" % (id))
continue continue
majorVersionStr = versionElements[0] majorVersionStr = versionElements[0]
if not majorVersionStr.isnumeric(): if not majorVersionStr.isnumeric():
eprint ("Skipping version %s with non-numeric major version %s" % (id, majorVersionStr)) eprint("Skipping version %s with non-numeric major version %s" % (id, majorVersionStr))
continue continue
majorVersion = int(majorVersionStr) majorVersion = int(majorVersionStr)
#if majorVersion >= 37: # if majorVersion >= 37:
# eprint ("Skipping unsupported major version %d (%s)" % (majorVersion, id)) # eprint ("Skipping unsupported major version %d (%s)" % (majorVersion, id))
# continue # continue
@ -375,7 +389,7 @@ for id, entry in remoteVersionlist.versions.items():
# If we do not have the corresponding Minecraft version, we ignore it # If we do not have the corresponding Minecraft version, we ignore it
if not os.path.isfile(PMC_DIR + "/net.minecraft/%s.json" % version.mcversion_sane): if not os.path.isfile(PMC_DIR + "/net.minecraft/%s.json" % version.mcversion_sane):
eprint ("Skipping %s with no corresponding Minecraft version %s" % (id, version.mcversion_sane)) eprint("Skipping %s with no corresponding Minecraft version %s" % (id, version.mcversion_sane))
continue continue
outVersion = None outVersion = None
@ -399,7 +413,7 @@ for id, entry in remoteVersionlist.versions.items():
# If we do not have the Forge json, we ignore this version # If we do not have the Forge json, we ignore this version
if not os.path.isfile(profileFilepath): if not os.path.isfile(profileFilepath):
eprint ("Skipping %s with missing profile json" % id) eprint("Skipping %s with missing profile json" % id)
continue continue
with open(profileFilepath, 'r', encoding='utf-8') as profileFile: with open(profileFilepath, 'r', encoding='utf-8') as profileFile:
profile = ForgeInstallerProfile(json.load(profileFile)) profile = ForgeInstallerProfile(json.load(profileFile))
@ -421,9 +435,9 @@ for id, entry in remoteVersionlist.versions.items():
recommendedVersions.sort() recommendedVersions.sort()
print ('Recommended versions:', recommendedVersions) print('Recommended versions:', recommendedVersions)
sharedData = PolyMCSharedPackageData(uid = 'net.minecraftforge', name = "Forge") sharedData = PolyMCSharedPackageData(uid='net.minecraftforge', name="Forge")
sharedData.projectUrl = 'https://www.minecraftforge.net/forum/' sharedData.projectUrl = 'https://www.minecraftforge.net/forum/'
sharedData.recommended = recommendedVersions sharedData.recommended = recommendedVersions
sharedData.write() sharedData.write()

View File

@ -3,13 +3,16 @@ from liteloaderutil import *
PMC_DIR = os.environ["PMC_DIR"] PMC_DIR = os.environ["PMC_DIR"]
UPSTREAM_DIR = os.environ["UPSTREAM_DIR"] UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
# load the locally cached version list # load the locally cached version list
def loadLiteloaderJson(): def loadLiteloaderJson():
with open(UPSTREAM_DIR + "/liteloader/versions.json", 'r', encoding='utf-8') as f: with open(UPSTREAM_DIR + "/liteloader/versions.json", 'r', encoding='utf-8') as f:
return LiteloaderIndex(json.load(f)) return LiteloaderIndex(json.load(f))
remoteVersionlist = loadLiteloaderJson() remoteVersionlist = loadLiteloaderJson()
def processArtefacts(mcVersion, liteloader, notSnapshots): def processArtefacts(mcVersion, liteloader, notSnapshots):
versions = [] versions = []
lookup = {} lookup = {}
@ -39,7 +42,7 @@ def processArtefacts(mcVersion, liteloader, notSnapshots):
lib.url = "http://repo.liteloader.com/" lib.url = "http://repo.liteloader.com/"
liteloaderLib = PolyMCLibrary( liteloaderLib = PolyMCLibrary(
name=GradleSpecifier("com.mumfrey:liteloader:%s" % version.version), name=GradleSpecifier("com.mumfrey:liteloader:%s" % version.version),
url = "http://dl.liteloader.com/versions/" url="http://dl.liteloader.com/versions/"
) )
if not notSnapshots: if not notSnapshots:
liteloaderLib.mmcHint = "always-stale" liteloaderLib.mmcHint = "always-stale"
@ -50,6 +53,7 @@ def processArtefacts(mcVersion, liteloader, notSnapshots):
latest = lookup[latestVersion] latest = lookup[latestVersion]
return versions, latest return versions, latest
allVersions = [] allVersions = []
recommended = [] recommended = []
for mcVersion, versionObject in remoteVersionlist.versions.items(): for mcVersion, versionObject in remoteVersionlist.versions.items():
@ -78,7 +82,7 @@ for version in allVersions:
with open(outFilepath, 'w') as outfile: with open(outFilepath, 'w') as outfile:
json.dump(version.to_json(), outfile, sort_keys=True, indent=4) json.dump(version.to_json(), outfile, sort_keys=True, indent=4)
sharedData = PolyMCSharedPackageData(uid = 'com.mumfrey.liteloader', name = 'LiteLoader') sharedData = PolyMCSharedPackageData(uid='com.mumfrey.liteloader', name='LiteLoader')
sharedData.recommended = recommended sharedData.recommended = recommended
sharedData.description = remoteVersionlist.meta.description sharedData.description = remoteVersionlist.meta.description
sharedData.projectUrl = remoteVersionlist.meta.url sharedData.projectUrl = remoteVersionlist.meta.url

View File

@ -25,32 +25,33 @@ LOG4J_HASHES = {
"sha1": "ca499d751f4ddd8afb016ef698c30be0da1d09f7", "sha1": "ca499d751f4ddd8afb016ef698c30be0da1d09f7",
"size": 21268 "size": 21268
} }
}; }
# LWJGL versions we want # LWJGL versions we want
passVariants = [ passVariants = [
"41d3ed7a755d15ad9e2f5a8aea51481858d60763", # 3.2.2 (2021-12-10 03:36:38+00:00) "41d3ed7a755d15ad9e2f5a8aea51481858d60763", # 3.2.2 (2021-12-10 03:36:38+00:00)
"57455f0bb479e07e5b554766f9f0310a6c245e10", # 3.1.2 (2018-06-21 12:57:11+00:00) "57455f0bb479e07e5b554766f9f0310a6c245e10", # 3.1.2 (2018-06-21 12:57:11+00:00)
"abfbb7905498983ab3300ae2b897ccd3c11ab8bb", # 2.9.0 (2013-10-21 16:34:47+00:00) "abfbb7905498983ab3300ae2b897ccd3c11ab8bb", # 2.9.0 (2013-10-21 16:34:47+00:00)
"47fd9d3677d7a0bcdb280453a7e7ac1fdbdab70d", # 2.9.4-nightly-20150209 (2016-12-20 14:05:34+00:00) "47fd9d3677d7a0bcdb280453a7e7ac1fdbdab70d", # 2.9.4-nightly-20150209 (2016-12-20 14:05:34+00:00)
"8ee2407d76c3af7882ab897b6ef25392839d2ab0", # 3.1.6 (2019-04-18 11:05:19+00:00) "8ee2407d76c3af7882ab897b6ef25392839d2ab0", # 3.1.6 (2019-04-18 11:05:19+00:00)
"428282d96ee546aae07d0717fef71ab8213d1176", # 3.2.1 (2019-04-18 11:05:19+00:00) "428282d96ee546aae07d0717fef71ab8213d1176", # 3.2.1 (2019-04-18 11:05:19+00:00)
"c7a84795ac3197bb476949665f3eda9c79436cf7", # 2.9.1 (2014-05-22 14:44:33+00:00) "c7a84795ac3197bb476949665f3eda9c79436cf7", # 2.9.1 (2014-05-22 14:44:33+00:00)
"66a60d78abe20960f1befd0fd5819a8855100055", # 2.9.1-nightly-20131120 (2013-12-06 13:55:34+00:00) "66a60d78abe20960f1befd0fd5819a8855100055", # 2.9.1-nightly-20131120 (2013-12-06 13:55:34+00:00)
"15a92ddad26186e720117fc0e318c6ddb8bae14e", # 2.9.3 (2015-01-30 11:58:24+00:00) "15a92ddad26186e720117fc0e318c6ddb8bae14e", # 2.9.3 (2015-01-30 11:58:24+00:00)
] ]
# LWJGL versions we def. don't want! # LWJGL versions we def. don't want!
badVariants = [ badVariants = [
"089446ef48f6ac70a3e2bc4a02cd1f34060d31bd", # 3.2.2 (2021-08-25 14:41:57+00:00) "089446ef48f6ac70a3e2bc4a02cd1f34060d31bd", # 3.2.2 (2021-08-25 14:41:57+00:00)
"6a0aaa55846ebccae9cf69e1ac2e284b3f0d81d0", # 3.2.2 (2019-07-19 09:25:47+00:00) "6a0aaa55846ebccae9cf69e1ac2e284b3f0d81d0", # 3.2.2 (2019-07-19 09:25:47+00:00)
"e3ecb31817e009ebfb3a8ed41b7b779d31e55b43", # 3.2.2 (2019-07-04 14:41:05+00:00) "e3ecb31817e009ebfb3a8ed41b7b779d31e55b43", # 3.2.2 (2019-07-04 14:41:05+00:00)
"2d0b7aa8397278c5b5f7e9cd025544af5e820072", # 2.9.0 (2013-09-06 12:31:58+00:00) "2d0b7aa8397278c5b5f7e9cd025544af5e820072", # 2.9.0 (2013-09-06 12:31:58+00:00)
"905c3a9d80a804c2d03a577775b75f45c1837263", # 2.9.0 (2011-03-30 22:00:00+00:00) "905c3a9d80a804c2d03a577775b75f45c1837263", # 2.9.0 (2011-03-30 22:00:00+00:00)
"d889b127fbabd3493115beb228730146072549a4", # 3.1.6 (2018-11-29 13:11:38+00:00) "d889b127fbabd3493115beb228730146072549a4", # 3.1.6 (2018-11-29 13:11:38+00:00)
"0034e86cec334f9142ca4ace843c91eb649017fd", # 3.2.1 (2019-02-13 16:12:08+00:00) "0034e86cec334f9142ca4ace843c91eb649017fd", # 3.2.1 (2019-02-13 16:12:08+00:00)
] ]
def addOrGetBucket(buckets, rules): def addOrGetBucket(buckets, rules):
ruleHash = None ruleHash = None
if rules: if rules:
@ -71,18 +72,22 @@ def addOrGetBucket(buckets, rules):
buckets[ruleHash] = bucket buckets[ruleHash] = bucket
return bucket return bucket
def hashVersion(lwjgl): def hashVersion(lwjgl):
lwjglObjectCopy = copy.deepcopy(lwjgl) lwjglObjectCopy = copy.deepcopy(lwjgl)
lwjglObjectCopy.releaseTime = datetime.datetime.fromtimestamp(0) lwjglObjectCopy.releaseTime = datetime.datetime.fromtimestamp(0)
return hashlib.sha1(json.dumps(lwjglObjectCopy.to_json(), sort_keys=True).encode("utf-8", "strict")).hexdigest() return hashlib.sha1(json.dumps(lwjglObjectCopy.to_json(), sort_keys=True).encode("utf-8", "strict")).hexdigest()
def sort_libs_by_name(library): def sort_libs_by_name(library):
return library.name return library.name
LWJGLEntry = namedtuple('LWJGLEntry', ('version', 'sha1')) LWJGLEntry = namedtuple('LWJGLEntry', ('version', 'sha1'))
lwjglVersionVariants = defaultdict(list) lwjglVersionVariants = defaultdict(list)
def addLWJGLVersion(versionVariants, lwjglObject): def addLWJGLVersion(versionVariants, lwjglObject):
lwjglObjectCopy = copy.deepcopy(lwjglObject) lwjglObjectCopy = copy.deepcopy(lwjglObject)
libraries = list(lwjglObjectCopy.libraries) libraries = list(lwjglObjectCopy.libraries)
@ -101,6 +106,7 @@ def addLWJGLVersion(versionVariants, lwjglObject):
print("!!! New variant for LWJGL version %s" % (lwjglVersion)) print("!!! New variant for LWJGL version %s" % (lwjglVersion))
versionVariants[lwjglVersion].append(LWJGLEntry(version=lwjglObjectCopy, sha1=lwjglObjectHash)) versionVariants[lwjglVersion].append(LWJGLEntry(version=lwjglObjectCopy, sha1=lwjglObjectHash))
def removePathsFromLib(lib): def removePathsFromLib(lib):
if pmcLib.downloads.artifact: if pmcLib.downloads.artifact:
pmcLib.downloads.artifact.path = None pmcLib.downloads.artifact.path = None
@ -108,6 +114,7 @@ def removePathsFromLib(lib):
for key, value in pmcLib.downloads.classifiers.items(): for key, value in pmcLib.downloads.classifiers.items():
value.path = None value.path = None
def adaptNewStyleArguments(arguments): def adaptNewStyleArguments(arguments):
outarr = [] outarr = []
# we ignore the jvm arguments entirely. # we ignore the jvm arguments entirely.
@ -128,10 +135,11 @@ def adaptNewStyleArguments(arguments):
pprint(arg) pprint(arg)
return ' '.join(outarr) return ' '.join(outarr)
def isOnlyMacOS(rules, specifier): def isOnlyMacOS(rules, specifier):
allowsOSX = False allowsOSX = False
allowsAll = False allowsAll = False
#print("Considering", specifier, "rules", rules) # print("Considering", specifier, "rules", rules)
if rules: if rules:
for rule in rules: for rule in rules:
if rule.action == "allow" and rule.os and rule.os.name == "osx": if rule.action == "allow" and rule.os and rule.os.name == "osx":
@ -169,7 +177,7 @@ for filename in os.listdir(UPSTREAM_DIR + '/mojang/versions'):
rules = pmcLib.rules rules = pmcLib.rules
pmcLib.rules = None pmcLib.rules = None
if isOnlyMacOS(rules, specifier): if isOnlyMacOS(rules, specifier):
print("Candidate library ", specifier, " is only for macOS and is therefore ignored.") print("Candidate library ", specifier, " is only for macOS and is therefore ignored.")
continue continue
bucket = addOrGetBucket(buckets, rules) bucket = addOrGetBucket(buckets, rules)
if specifier.group == "org.lwjgl.lwjgl" and specifier.artifact == "lwjgl": if specifier.group == "org.lwjgl.lwjgl" and specifier.artifact == "lwjgl":
@ -185,7 +193,8 @@ for filename in os.listdir(UPSTREAM_DIR + '/mojang/versions'):
else: else:
# FIXME: workaround for insane log4j nonsense from December 2021. Probably needs adjustment. # FIXME: workaround for insane log4j nonsense from December 2021. Probably needs adjustment.
if pmcLib.name.isLog4j(): if pmcLib.name.isLog4j():
replacementLib = PolyMCLibrary(name=GradleSpecifier("org.apache.logging.log4j:%s:%s" % (pmcLib.name.artifact, LOG4J_VERSION_OVERRIDE))) replacementLib = PolyMCLibrary(name=GradleSpecifier(
"org.apache.logging.log4j:%s:%s" % (pmcLib.name.artifact, LOG4J_VERSION_OVERRIDE)))
replacementLib.downloads = MojangLibraryDownloads() replacementLib.downloads = MojangLibraryDownloads()
replacementLib.downloads.artifact = MojangArtifact() replacementLib.downloads.artifact = MojangArtifact()
replacementLib.downloads.artifact.url = LOG4J_MAVEN_REPO % (replacementLib.name.getPath()) replacementLib.downloads.artifact.url = LOG4J_MAVEN_REPO % (replacementLib.name.getPath())
@ -258,10 +267,11 @@ for filename in os.listdir(UPSTREAM_DIR + '/mojang/versions'):
versionFile.minecraftArguments = adaptNewStyleArguments(mojangVersionFile.arguments) versionFile.minecraftArguments = adaptNewStyleArguments(mojangVersionFile.arguments)
filenameOut = PMC_DIR + "/net.minecraft/%s.json" % versionFile.version filenameOut = PMC_DIR + "/net.minecraft/%s.json" % versionFile.version
if versionFile.version in staticVersionlist.versions: if versionFile.version in staticVersionlist.versions:
ApplyLegacyOverride (versionFile, staticVersionlist.versions[versionFile.version]) ApplyLegacyOverride(versionFile, staticVersionlist.versions[versionFile.version])
with open(filenameOut, 'w') as outfile: with open(filenameOut, 'w') as outfile:
json.dump(versionFile.to_json(), outfile, sort_keys=True, indent=4) json.dump(versionFile.to_json(), outfile, sort_keys=True, indent=4)
def processSingleVariant(lwjglVariant): def processSingleVariant(lwjglVariant):
lwjglVersion = lwjglVariant.version lwjglVersion = lwjglVariant.version
versionObj = copy.deepcopy(lwjglVariant) versionObj = copy.deepcopy(lwjglVariant)
@ -276,7 +286,8 @@ def processSingleVariant(lwjglVariant):
versionObj.uid = 'org.lwjgl3' versionObj.uid = 'org.lwjgl3'
versionObj.conflicts = [DependencyEntry(uid='org.lwjgl')] versionObj.conflicts = [DependencyEntry(uid='org.lwjgl')]
# remove jutils and jinput from LWJGL 3 -- this is a dependency that Mojang kept in, but doesn't belong there anymore # remove jutils and jinput from LWJGL 3 -- this is a dependency that Mojang kept in, but doesn't belong there anymore
filteredLibraries = list(filter(lambda lib: not lib.name.artifact in ["jutils", "jinput"], versionObj.libraries)) filteredLibraries = list(
filter(lambda lib: not lib.name.artifact in ["jutils", "jinput"], versionObj.libraries))
versionObj.libraries = filteredLibraries versionObj.libraries = filteredLibraries
else: else:
raise Exception("LWJGL version not recognized: %s" % versionObj.version) raise Exception("LWJGL version not recognized: %s" % versionObj.version)
@ -296,7 +307,8 @@ def processSingleVariant(lwjglVariant):
for entry in checkedDict: for entry in checkedDict:
bakedEntry = lib.natives[entry] bakedEntry = lib.natives[entry]
if not bakedEntry in lib.downloads.classifiers: if not bakedEntry in lib.downloads.classifiers:
print("Missing download for classifier!", versionObj.version, lib.name, bakedEntry, lib.downloads.classifiers.keys()) print("Missing download for classifier!", versionObj.version, lib.name, bakedEntry,
lib.downloads.classifiers.keys())
good = False good = False
break break
if good: if good:
@ -322,27 +334,28 @@ for lwjglVersionVariant in lwjglVersionVariants:
passedVariants += 1 passedVariants += 1
continue continue
print(f" \"{variant.sha1}\", # {lwjglVersionVariant} ({variant.version.releaseTime})") print(f" \"{variant.sha1}\", # {lwjglVersionVariant} ({variant.version.releaseTime})")
unknownVariants += 1 unknownVariants += 1
print("") print("")
if decidedVariant and passedVariants == 1 and unknownVariants == 0: if decidedVariant and passedVariants == 1 and unknownVariants == 0:
processSingleVariant(decidedVariant.version) processSingleVariant(decidedVariant.version)
else: else:
raise Exception("No variant decided for version %s out of %d possible ones and %d unknown ones." % (lwjglVersionVariant, passedVariants, unknownVariants)) raise Exception("No variant decided for version %s out of %d possible ones and %d unknown ones." % (
lwjglVersionVariant, passedVariants, unknownVariants))
lwjglSharedData = PolyMCSharedPackageData(uid = 'org.lwjgl', name = 'LWJGL 2') lwjglSharedData = PolyMCSharedPackageData(uid='org.lwjgl', name='LWJGL 2')
lwjglSharedData.recommended = ['2.9.4-nightly-20150209'] lwjglSharedData.recommended = ['2.9.4-nightly-20150209']
lwjglSharedData.write() lwjglSharedData.write()
if found_any_lwjgl3: if found_any_lwjgl3:
lwjglSharedData = PolyMCSharedPackageData(uid = 'org.lwjgl3', name = 'LWJGL 3') lwjglSharedData = PolyMCSharedPackageData(uid='org.lwjgl3', name='LWJGL 3')
lwjglSharedData.recommended = ['3.1.2'] lwjglSharedData.recommended = ['3.1.2']
lwjglSharedData.write() lwjglSharedData.write()
with open(UPSTREAM_DIR + "/mojang/version_manifest_v2.json", 'r', encoding='utf-8') as localIndexFile: with open(UPSTREAM_DIR + "/mojang/version_manifest_v2.json", 'r', encoding='utf-8') as localIndexFile:
localVersionlist = MojangIndexWrap(json.load(localIndexFile)) localVersionlist = MojangIndexWrap(json.load(localIndexFile))
mcSharedData = PolyMCSharedPackageData(uid = 'net.minecraft', name = 'Minecraft') mcSharedData = PolyMCSharedPackageData(uid='net.minecraft', name='Minecraft')
mcSharedData.recommended = [localVersionlist.latest['release']] mcSharedData.recommended = [localVersionlist.latest['release']]
mcSharedData.write() mcSharedData.write()

View File

@ -5,6 +5,7 @@ from metautil import *
PMC_DIR = os.environ["PMC_DIR"] PMC_DIR = os.environ["PMC_DIR"]
# take the hash type (like hashlib.md5) and filename, return hex string of hash # take the hash type (like hashlib.md5) and filename, return hex string of hash
def HashFile(hash, fname): def HashFile(hash, fname):
hash_instance = hash() hash_instance = hash()
@ -13,6 +14,7 @@ def HashFile(hash, fname):
hash_instance.update(chunk) hash_instance.update(chunk)
return hash_instance.hexdigest() return hash_instance.hexdigest()
# ignore these files when indexing versions # ignore these files when indexing versions
ignore = set(["index.json", "package.json", ".git"]) ignore = set(["index.json", "package.json", ".git"])
@ -69,12 +71,12 @@ for package in sorted(os.listdir(PMC_DIR)):
# insert entry into the package index # insert entry into the package index
packageEntry = PolyMCPackageIndexEntry( packageEntry = PolyMCPackageIndexEntry(
{ {
"uid" : package, "uid": package,
"name" : sharedData.name, "name": sharedData.name,
"sha256": HashFile(hashlib.sha256, outFilePath) "sha256": HashFile(hashlib.sha256, outFilePath)
} }
) )
packages.packages.append(packageEntry) packages.packages.append(packageEntry)
# write the repository package index # write the repository package index

View File

@ -8,7 +8,6 @@ import datetime
from . import properties from . import properties
import re import re
re_date = re.compile(r'^(\d{4})\D?(0[1-9]|1[0-2])\D?([12]\d|0[1-9]|3[01])$') re_date = re.compile(r'^(\d{4})\D?(0[1-9]|1[0-2])\D?([12]\d|0[1-9]|3[01])$')
re_time = re.compile( re_time = re.compile(
r'^([01]\d|2[0-3])\D?([0-5]\d)\D?([0-5]\d)?\D?(\d{3,6})?$') r'^([01]\d|2[0-3])\D?([0-5]\d)\D?([0-5]\d)?\D?(\d{3,6})?$')

View File

@ -10,7 +10,6 @@ from .exceptions import (
from .base_properties import JsonProperty, DefaultProperty from .base_properties import JsonProperty, DefaultProperty
from .utils import check_type from .utils import check_type
JsonObjectClassSettings = namedtuple('JsonObjectClassSettings', ['type_config']) JsonObjectClassSettings = namedtuple('JsonObjectClassSettings', ['type_config'])
CLASS_SETTINGS_ATTR = '_$_class_settings' CLASS_SETTINGS_ATTR = '_$_class_settings'
@ -60,6 +59,7 @@ class TypeConfig(object):
instead of the default. instead of the default.
""" """
def __init__(self, properties=None, string_conversions=None): def __init__(self, properties=None, string_conversions=None):
self._properties = properties if properties is not None else {} self._properties = properties if properties is not None else {}
@ -108,11 +108,11 @@ class TypeConfig(object):
result.append((pattern, conversion)) result.append((pattern, conversion))
return result return result
META_ATTRS = ('properties', 'string_conversions', 'update_properties') META_ATTRS = ('properties', 'string_conversions', 'update_properties')
class JsonObjectMeta(type): class JsonObjectMeta(type):
class Meta(object): class Meta(object):
pass pass
@ -181,7 +181,6 @@ class _JsonObjectPrivateInstanceVariables(object):
@six.add_metaclass(JsonObjectMeta) @six.add_metaclass(JsonObjectMeta)
class JsonObjectBase(object): class JsonObjectBase(object):
_allow_dynamic_properties = False _allow_dynamic_properties = False
_validate_required_lazily = False _validate_required_lazily = False
@ -305,9 +304,9 @@ class JsonObjectBase(object):
def __is_dynamic_property(self, name): def __is_dynamic_property(self, name):
return ( return (
name not in self._properties_by_attr and name not in self._properties_by_attr and
not name.startswith('_') and not name.startswith('_') and
not inspect.isdatadescriptor(getattr(self.__class__, name, None)) not inspect.isdatadescriptor(getattr(self.__class__, name, None))
) )
def __setattr__(self, name, value): def __setattr__(self, name, value):

View File

@ -13,7 +13,6 @@ else:
class JsonProperty(object): class JsonProperty(object):
default = None default = None
type_config = None type_config = None
@ -124,7 +123,6 @@ class JsonProperty(object):
class JsonContainerProperty(JsonProperty): class JsonContainerProperty(JsonProperty):
_type = default = None _type = default = None
container_class = None container_class = None
@ -259,7 +257,7 @@ class DefaultProperty(JsonProperty):
if convert is not None: if convert is not None:
try: try:
#sometimes regex fail so return value # sometimes regex fail so return value
value = convert(value) value = convert(value)
except Exception: except Exception:
pass pass
@ -290,7 +288,6 @@ class AssertTypeProperty(JsonProperty):
class AbstractDateProperty(JsonProperty): class AbstractDateProperty(JsonProperty):
_type = None _type = None
def __init__(self, exact=False, *args, **kwargs): def __init__(self, exact=False, *args, **kwargs):

View File

@ -3,6 +3,7 @@ from .base_properties import DefaultProperty
from .utils import check_type, SimpleDict from .utils import check_type, SimpleDict
import copy import copy
class JsonArray(list): class JsonArray(list):
def __init__(self, _obj=None, wrapper=None, type_config=None): def __init__(self, _obj=None, wrapper=None, type_config=None):
super(JsonArray, self).__init__() super(JsonArray, self).__init__()
@ -12,8 +13,8 @@ class JsonArray(list):
assert type_config is not None assert type_config is not None
self._type_config = type_config self._type_config = type_config
self._wrapper = ( self._wrapper = (
wrapper or wrapper or
DefaultProperty(type_config=self._type_config) DefaultProperty(type_config=self._type_config)
) )
for item in self._obj: for item in self._obj:
super(JsonArray, self).append(self._wrapper.wrap(item)) super(JsonArray, self).append(self._wrapper.wrap(item))
@ -118,8 +119,8 @@ class JsonDict(SimpleDict):
assert type_config is not None assert type_config is not None
self._type_config = type_config self._type_config = type_config
self._wrapper = ( self._wrapper = (
wrapper or wrapper or
DefaultProperty(type_config=self._type_config) DefaultProperty(type_config=self._type_config)
) )
for key, value in self._obj.items(): for key, value in self._obj.items():
self[key] = self.__wrap(key, value) self[key] = self.__wrap(key, value)
@ -161,8 +162,8 @@ class JsonSet(set):
assert type_config is not None assert type_config is not None
self._type_config = type_config self._type_config = type_config
self._wrapper = ( self._wrapper = (
wrapper or wrapper or
DefaultProperty(type_config=self._type_config) DefaultProperty(type_config=self._type_config)
) )
for item in self._obj: for item in self._obj:
super(JsonSet, self).add(self._wrapper.wrap(item)) super(JsonSet, self).add(self._wrapper.wrap(item))

View File

@ -14,7 +14,6 @@ from .base_properties import (
) )
from .containers import JsonArray, JsonDict, JsonSet from .containers import JsonArray, JsonDict, JsonSet
if sys.version > '3': if sys.version > '3':
unicode = str unicode = str
long = int long = int
@ -62,7 +61,6 @@ class DecimalProperty(JsonProperty):
class DateProperty(AbstractDateProperty): class DateProperty(AbstractDateProperty):
_type = datetime.date _type = datetime.date
def _wrap(self, value): def _wrap(self, value):
@ -77,7 +75,6 @@ class DateProperty(AbstractDateProperty):
class DateTimeProperty(AbstractDateProperty): class DateTimeProperty(AbstractDateProperty):
_type = datetime.datetime _type = datetime.datetime
def _wrap(self, value): def _wrap(self, value):
@ -103,7 +100,6 @@ class DateTimeProperty(AbstractDateProperty):
class TimeProperty(AbstractDateProperty): class TimeProperty(AbstractDateProperty):
_type = datetime.time _type = datetime.time
def _wrap(self, value): def _wrap(self, value):
@ -124,7 +120,6 @@ class TimeProperty(AbstractDateProperty):
class ObjectProperty(JsonContainerProperty): class ObjectProperty(JsonContainerProperty):
default = lambda self: self.item_type() default = lambda self: self.item_type()
def wrap(self, obj, string_conversions=None): def wrap(self, obj, string_conversions=None):
@ -137,7 +132,6 @@ class ObjectProperty(JsonContainerProperty):
class ListProperty(JsonContainerProperty): class ListProperty(JsonContainerProperty):
_type = default = list _type = default = list
container_class = JsonArray container_class = JsonArray
@ -146,7 +140,6 @@ class ListProperty(JsonContainerProperty):
class DictProperty(JsonContainerProperty): class DictProperty(JsonContainerProperty):
_type = default = dict _type = default = dict
container_class = JsonDict container_class = JsonDict
@ -155,7 +148,6 @@ class DictProperty(JsonContainerProperty):
class SetProperty(JsonContainerProperty): class SetProperty(JsonContainerProperty):
_type = default = set _type = default = set
container_class = JsonSet container_class = JsonSet

View File

@ -16,6 +16,7 @@ class SimpleDict(dict):
Re-implements destructive methods of dict Re-implements destructive methods of dict
to use only setitem and getitem and delitem to use only setitem and getitem and delitem
""" """
def update(self, E=None, **F): def update(self, E=None, **F):
for dct in (E, F): for dct in (E, F):
if dct: if dct:

View File

@ -1,6 +1,5 @@
from metautil import * from metautil import *
''' '''
"repo":{ "repo":{
"stream":"RELEASE", "stream":"RELEASE",
@ -9,12 +8,15 @@ from metautil import *
"classifier":"" "classifier":""
}, },
''' '''
class LiteloaderRepo(JsonObject): class LiteloaderRepo(JsonObject):
stream = StringProperty(required=True) stream = StringProperty(required=True)
type = StringProperty(required=True) type = StringProperty(required=True)
url = StringProperty(required=True) url = StringProperty(required=True)
classifier = StringProperty(required=True) classifier = StringProperty(required=True)
''' '''
"53639d52340479ccf206a04f5e16606f":{ "53639d52340479ccf206a04f5e16606f":{
"tweakClass":"com.mumfrey.liteloader.launch.LiteLoaderTweaker", "tweakClass":"com.mumfrey.liteloader.launch.LiteLoaderTweaker",
@ -36,6 +38,8 @@ class LiteloaderRepo(JsonObject):
"timestamp":"1367366420" "timestamp":"1367366420"
}, },
''' '''
class LiteloaderArtefact(JsonObject): class LiteloaderArtefact(JsonObject):
tweakClass = StringProperty(required=True) tweakClass = StringProperty(required=True)
libraries = ListProperty(PolyMCLibrary, required=True) libraries = ListProperty(PolyMCLibrary, required=True)
@ -48,21 +52,26 @@ class LiteloaderArtefact(JsonObject):
srcJar = StringProperty(default=None, exclude_if_none=True) srcJar = StringProperty(default=None, exclude_if_none=True)
mcpJar = StringProperty(default=None, exclude_if_none=True) mcpJar = StringProperty(default=None, exclude_if_none=True)
class LiteloaderDev(JsonObject): class LiteloaderDev(JsonObject):
fgVersion = StringProperty(default=None ,exclude_if_none=True) fgVersion = StringProperty(default=None, exclude_if_none=True)
mappings = StringProperty(required=None, exclude_if_none=True) mappings = StringProperty(required=None, exclude_if_none=True)
mcp = StringProperty(default=None, exclude_if_none=True) mcp = StringProperty(default=None, exclude_if_none=True)
class LiteloaderArtefacts(JsonObject): class LiteloaderArtefacts(JsonObject):
liteloader = DictProperty(LiteloaderArtefact, name="com.mumfrey:liteloader", required=True) liteloader = DictProperty(LiteloaderArtefact, name="com.mumfrey:liteloader", required=True)
class LiteloaderSnapshot(LiteloaderArtefact): class LiteloaderSnapshot(LiteloaderArtefact):
lastSuccessfulBuild = IntegerProperty() lastSuccessfulBuild = IntegerProperty()
class LiteloaderSnapshots(JsonObject): class LiteloaderSnapshots(JsonObject):
libraries = ListProperty(PolyMCLibrary, required=True) libraries = ListProperty(PolyMCLibrary, required=True)
liteloader = DictProperty(LiteloaderSnapshot, name="com.mumfrey:liteloader", required=True) liteloader = DictProperty(LiteloaderSnapshot, name="com.mumfrey:liteloader", required=True)
''' '''
"1.10.2":{ "1.10.2":{
"dev": { ... }, "dev": { ... },
@ -75,12 +84,15 @@ class LiteloaderSnapshots(JsonObject):
... ...
} }
''' '''
class LiteloaderEntry(JsonObject): class LiteloaderEntry(JsonObject):
dev = ObjectProperty(LiteloaderDev, default=None, exclude_if_none=True) dev = ObjectProperty(LiteloaderDev, default=None, exclude_if_none=True)
repo = ObjectProperty(LiteloaderRepo, required=True) repo = ObjectProperty(LiteloaderRepo, required=True)
artefacts = ObjectProperty(LiteloaderArtefacts, default=None, exclude_if_none=True) artefacts = ObjectProperty(LiteloaderArtefacts, default=None, exclude_if_none=True)
snapshots = ObjectProperty(LiteloaderSnapshots, default=None, exclude_if_none=True) snapshots = ObjectProperty(LiteloaderSnapshots, default=None, exclude_if_none=True)
''' '''
"meta":{ "meta":{
"description":"LiteLoader is a lightweight mod bootstrap designed to provide basic loader functionality for mods which don't need to modify game mechanics.", "description":"LiteLoader is a lightweight mod bootstrap designed to provide basic loader functionality for mods which don't need to modify game mechanics.",
@ -90,6 +102,8 @@ class LiteloaderEntry(JsonObject):
"updatedTime":1487763247 "updatedTime":1487763247
}, },
''' '''
class LiteloaderMeta(JsonObject): class LiteloaderMeta(JsonObject):
description = StringProperty(required=True) description = StringProperty(required=True)
authors = StringProperty(required=True) authors = StringProperty(required=True)
@ -97,6 +111,7 @@ class LiteloaderMeta(JsonObject):
updated = ISOTimestampProperty(required=True) updated = ISOTimestampProperty(required=True)
updatedTime = IntegerProperty(required=True) updatedTime = IntegerProperty(required=True)
# The raw Forge version index # The raw Forge version index
class LiteloaderIndex(JsonObject): class LiteloaderIndex(JsonObject):
meta = ObjectProperty(LiteloaderMeta, required=True) meta = ObjectProperty(LiteloaderMeta, required=True)

View File

@ -7,8 +7,8 @@ from jsonobject import *
PMC_DIR = os.environ["PMC_DIR"] PMC_DIR = os.environ["PMC_DIR"]
class ISOTimestampProperty(AbstractDateProperty):
class ISOTimestampProperty(AbstractDateProperty):
_type = datetime.datetime _type = datetime.datetime
def _wrap(self, value): def _wrap(self, value):
@ -63,12 +63,11 @@ class GradleSpecifier:
return "%s-%s.%s" % (self.artifact, self.version, self.extension) return "%s-%s.%s" % (self.artifact, self.version, self.extension)
def getBase(self): def getBase(self):
return "%s/%s/%s/" % (self.group.replace('.','/'), self.artifact, self.version) return "%s/%s/%s/" % (self.group.replace('.', '/'), self.artifact, self.version)
def getPath(self): def getPath(self):
return self.getBase() + self.getFilename() return self.getBase() + self.getFilename()
def __repr__(self): def __repr__(self):
return "GradleSpecifier('" + self.toString() + "')" return "GradleSpecifier('" + self.toString() + "')"
@ -78,7 +77,6 @@ class GradleSpecifier:
def isLog4j(self): def isLog4j(self):
return self.group == "org.apache.logging.log4j" return self.group == "org.apache.logging.log4j"
def __lt__(self, other): def __lt__(self, other):
return self.toString() < other.toString() return self.toString() < other.toString()
@ -91,6 +89,7 @@ class GradleSpecifier:
def __hash__(self): def __hash__(self):
return self.toString().__hash__() return self.toString().__hash__()
class GradleSpecifierProperty(JsonProperty): class GradleSpecifierProperty(JsonProperty):
def wrap(self, value): def wrap(self, value):
return GradleSpecifier(value) return GradleSpecifier(value)
@ -98,6 +97,7 @@ class GradleSpecifierProperty(JsonProperty):
def unwrap(self, value): def unwrap(self, value):
return value, value.toString() return value, value.toString()
''' '''
Mojang index files look like this: Mojang index files look like this:
{ {
@ -119,6 +119,7 @@ Mojang index files look like this:
} }
''' '''
class MojangIndexEntry(JsonObject): class MojangIndexEntry(JsonObject):
id = StringProperty() id = StringProperty()
releaseTime = ISOTimestampProperty() releaseTime = ISOTimestampProperty()
@ -128,10 +129,12 @@ class MojangIndexEntry(JsonObject):
sha1 = StringProperty(exclude_if_none=True, default=None) sha1 = StringProperty(exclude_if_none=True, default=None)
complianceLevel = IntegerProperty(exclude_if_none=True, default=None) complianceLevel = IntegerProperty(exclude_if_none=True, default=None)
class MojangIndex(JsonObject): class MojangIndex(JsonObject):
latest = DictProperty(StringProperty) latest = DictProperty(StringProperty)
versions = ListProperty(MojangIndexEntry) versions = ListProperty(MojangIndexEntry)
class MojangIndexWrap: class MojangIndexWrap:
def __init__(self, json): def __init__(self, json):
self.index = MojangIndex.wrap(json) self.index = MojangIndex.wrap(json)
@ -142,25 +145,30 @@ class MojangIndexWrap:
self.versions = versionsDict self.versions = versionsDict
class MojangArtifactBase (JsonObject): class MojangArtifactBase(JsonObject):
sha1 = StringProperty(exclude_if_none=True, default=None) sha1 = StringProperty(exclude_if_none=True, default=None)
size = IntegerProperty(exclude_if_none=True, default=None) size = IntegerProperty(exclude_if_none=True, default=None)
url = StringProperty() url = StringProperty()
class MojangArtifact (MojangArtifactBase):
class MojangArtifact(MojangArtifactBase):
path = StringProperty(exclude_if_none=True, default=None) path = StringProperty(exclude_if_none=True, default=None)
class MojangAssets (MojangArtifactBase):
class MojangAssets(MojangArtifactBase):
id = StringProperty() id = StringProperty()
totalSize = IntegerProperty() totalSize = IntegerProperty()
class MojangLibraryDownloads(JsonObject): class MojangLibraryDownloads(JsonObject):
artifact = ObjectProperty(MojangArtifact, exclude_if_none=True, default=None) artifact = ObjectProperty(MojangArtifact, exclude_if_none=True, default=None)
classifiers = DictProperty(MojangArtifact, exclude_if_none=True, default=None) classifiers = DictProperty(MojangArtifact, exclude_if_none=True, default=None)
class MojangLibraryExtractRules(JsonObject): class MojangLibraryExtractRules(JsonObject):
exclude = ListProperty(StringProperty) exclude = ListProperty(StringProperty)
''' '''
"rules": [ "rules": [
{ {
@ -175,52 +183,64 @@ class MojangLibraryExtractRules(JsonObject):
] ]
''' '''
class OSRule (JsonObject):
name = StringProperty(choices=["osx", "linux", "windows"], required = True) class OSRule(JsonObject):
name = StringProperty(choices=["osx", "linux", "windows"], required=True)
version = StringProperty(exclude_if_none=True, default=None) version = StringProperty(exclude_if_none=True, default=None)
class MojangRule (JsonObject):
action = StringProperty(choices=["allow", "disallow"], required = True) class MojangRule(JsonObject):
action = StringProperty(choices=["allow", "disallow"], required=True)
os = ObjectProperty(OSRule, exclude_if_none=True, default=None) os = ObjectProperty(OSRule, exclude_if_none=True, default=None)
class MojangLibrary (JsonObject):
class MojangLibrary(JsonObject):
extract = ObjectProperty(MojangLibraryExtractRules, exclude_if_none=True, default=None) extract = ObjectProperty(MojangLibraryExtractRules, exclude_if_none=True, default=None)
name = GradleSpecifierProperty(required = True) name = GradleSpecifierProperty(required=True)
downloads = ObjectProperty(MojangLibraryDownloads, exclude_if_none=True, default=None) downloads = ObjectProperty(MojangLibraryDownloads, exclude_if_none=True, default=None)
natives = DictProperty(StringProperty, exclude_if_none=True, default=None) natives = DictProperty(StringProperty, exclude_if_none=True, default=None)
rules = ListProperty(MojangRule, exclude_if_none=True, default=None) rules = ListProperty(MojangRule, exclude_if_none=True, default=None)
class MojangLoggingArtifact (MojangArtifactBase):
class MojangLoggingArtifact(MojangArtifactBase):
id = StringProperty() id = StringProperty()
class MojangLogging (JsonObject):
file = ObjectProperty(MojangLoggingArtifact, required = True)
argument = StringProperty(required = True)
type = StringProperty(required = True, choices=["log4j2-xml"])
class MojangArguments (JsonObject): class MojangLogging(JsonObject):
file = ObjectProperty(MojangLoggingArtifact, required=True)
argument = StringProperty(required=True)
type = StringProperty(required=True, choices=["log4j2-xml"])
class MojangArguments(JsonObject):
game = ListProperty(exclude_if_none=True, default=None) game = ListProperty(exclude_if_none=True, default=None)
jvm = ListProperty(exclude_if_none=True, default=None) jvm = ListProperty(exclude_if_none=True, default=None)
class JavaVersion (JsonObject):
class JavaVersion(JsonObject):
component = StringProperty(default="jre-legacy") component = StringProperty(default="jre-legacy")
majorVersion = IntegerProperty(default=8) majorVersion = IntegerProperty(default=8)
class UnknownVersionException(Exception): class UnknownVersionException(Exception):
"""Exception raised for unknown Mojang version file format versions. """Exception raised for unknown Mojang version file format versions.
Attributes: Attributes:
message -- explanation of the error message -- explanation of the error
""" """
def __init__(self, message): def __init__(self, message):
self.message = message self.message = message
def validateSupportedMojangVersion(version): def validateSupportedMojangVersion(version):
supportedVersion = 21 supportedVersion = 21
if version > supportedVersion: if version > supportedVersion:
raise UnknownVersionException("Unsupported Mojang format version: %d. Max supported is: %d" % (version, supportedVersion)) raise UnknownVersionException(
"Unsupported Mojang format version: %d. Max supported is: %d" % (version, supportedVersion))
class MojangVersionFile (JsonObject):
class MojangVersionFile(JsonObject):
arguments = ObjectProperty(MojangArguments, exclude_if_none=True, default=None) arguments = ObjectProperty(MojangArguments, exclude_if_none=True, default=None)
assetIndex = ObjectProperty(MojangAssets, exclude_if_none=True, default=None) assetIndex = ObjectProperty(MojangAssets, exclude_if_none=True, default=None)
assets = StringProperty(exclude_if_none=True, default=None) assets = StringProperty(exclude_if_none=True, default=None)
@ -230,7 +250,8 @@ class MojangVersionFile (JsonObject):
mainClass = StringProperty(exclude_if_none=True, default=None) mainClass = StringProperty(exclude_if_none=True, default=None)
processArguments = StringProperty(exclude_if_none=True, default=None) processArguments = StringProperty(exclude_if_none=True, default=None)
minecraftArguments = StringProperty(exclude_if_none=True, default=None) minecraftArguments = StringProperty(exclude_if_none=True, default=None)
minimumLauncherVersion = IntegerProperty(exclude_if_none=True, default=None, validators=validateSupportedMojangVersion) minimumLauncherVersion = IntegerProperty(exclude_if_none=True, default=None,
validators=validateSupportedMojangVersion)
releaseTime = ISOTimestampProperty(exclude_if_none=True, default=None) releaseTime = ISOTimestampProperty(exclude_if_none=True, default=None)
time = ISOTimestampProperty(exclude_if_none=True, default=None) time = ISOTimestampProperty(exclude_if_none=True, default=None)
type = StringProperty(exclude_if_none=True, default=None) type = StringProperty(exclude_if_none=True, default=None)
@ -239,24 +260,32 @@ class MojangVersionFile (JsonObject):
complianceLevel = IntegerProperty(exclude_if_none=True, default=None) complianceLevel = IntegerProperty(exclude_if_none=True, default=None)
javaVersion = ObjectProperty(JavaVersion, exclude_if_none=True, default=None) javaVersion = ObjectProperty(JavaVersion, exclude_if_none=True, default=None)
CurrentPolyMCFormatVersion = 1 CurrentPolyMCFormatVersion = 1
def validateSupportedPolyMCVersion(version): def validateSupportedPolyMCVersion(version):
if version > CurrentPolyMCFormatVersion: if version > CurrentPolyMCFormatVersion:
raise UnknownVersionException("Unsupported PolyMC format version: %d. Max supported is: %d" % (version, CurrentPolyMCFormatVersion)) raise UnknownVersionException(
"Unsupported PolyMC format version: %d. Max supported is: %d" % (version, CurrentPolyMCFormatVersion))
class PolyMCLibrary (MojangLibrary):
class PolyMCLibrary(MojangLibrary):
url = StringProperty(exclude_if_none=True, default=None) url = StringProperty(exclude_if_none=True, default=None)
mmcHint = StringProperty(name="MMC-hint", exclude_if_none=True, default=None) # this is supposed to be MMC-hint! mmcHint = StringProperty(name="MMC-hint", exclude_if_none=True, default=None) # this is supposed to be MMC-hint!
class VersionedJsonObject(JsonObject): class VersionedJsonObject(JsonObject):
formatVersion = IntegerProperty(default=CurrentPolyMCFormatVersion, validators=validateSupportedPolyMCVersion) formatVersion = IntegerProperty(default=CurrentPolyMCFormatVersion, validators=validateSupportedPolyMCVersion)
class DependencyEntry (JsonObject):
class DependencyEntry(JsonObject):
uid = StringProperty(required=True) uid = StringProperty(required=True)
equals = StringProperty(exclude_if_none=True, default=None) equals = StringProperty(exclude_if_none=True, default=None)
suggests = StringProperty(exclude_if_none=True, default=None) suggests = StringProperty(exclude_if_none=True, default=None)
class PolyMCVersionFile (VersionedJsonObject):
class PolyMCVersionFile(VersionedJsonObject):
name = StringProperty(required=True) name = StringProperty(required=True)
version = StringProperty(required=True) version = StringProperty(required=True)
uid = StringProperty(required=True) uid = StringProperty(required=True)
@ -277,18 +306,20 @@ class PolyMCVersionFile (VersionedJsonObject):
addTweakers = ListProperty(StringProperty, name="+tweakers", exclude_if_none=True, default=None) addTweakers = ListProperty(StringProperty, name="+tweakers", exclude_if_none=True, default=None)
order = IntegerProperty(exclude_if_none=True, default=None) order = IntegerProperty(exclude_if_none=True, default=None)
class UnknownComplianceLevelException(Exception): class UnknownComplianceLevelException(Exception):
"""Exception raised for unknown Mojang compliance level """Exception raised for unknown Mojang compliance level
Attributes: Attributes:
message -- explanation of the error message -- explanation of the error
""" """
def __init__(self, message): def __init__(self, message):
self.message = message self.message = message
# Convert Mojang version file object to a PolyMC version file object # Convert Mojang version file object to a PolyMC version file object
def MojangToPolyMC (file, name, uid, version): def MojangToPolyMC(file, name, uid, version):
pmcFile = PolyMCVersionFile( pmcFile = PolyMCVersionFile(
{ {
"name": name, "name": name,
@ -327,9 +358,11 @@ def MojangToPolyMC (file, name, uid, version):
pmcFile.addTraits = [] pmcFile.addTraits = []
pmcFile.addTraits.append("XR:Initial") pmcFile.addTraits.append("XR:Initial")
else: else:
raise UnknownComplianceLevelException("Unsupported Mojang compliance level: %d. Max supported is: %d" % (file.complianceLevel, maxSupportedLevel)) raise UnknownComplianceLevelException("Unsupported Mojang compliance level: %d. Max supported is: %d" % (
file.complianceLevel, maxSupportedLevel))
return pmcFile return pmcFile
class PolyMCSharedPackageData(VersionedJsonObject): class PolyMCSharedPackageData(VersionedJsonObject):
name = StringProperty(required=True) name = StringProperty(required=True)
uid = StringProperty(required=True) uid = StringProperty(required=True)
@ -345,18 +378,21 @@ class PolyMCSharedPackageData(VersionedJsonObject):
except EnvironmentError as e: except EnvironmentError as e:
print("Error while trying to save shared packaged data for %s:" % self.uid, e) print("Error while trying to save shared packaged data for %s:" % self.uid, e)
def writeSharedPackageData(uid, name): def writeSharedPackageData(uid, name):
desc = PolyMCSharedPackageData({ desc = PolyMCSharedPackageData({
'name': name, 'name': name,
'uid': uid 'uid': uid
}) })
with open(PMC_DIR + "/%s/package.json" % uid, 'w') as file: with open(PMC_DIR + "/%s/package.json" % uid, 'w') as file:
json.dump(desc.to_json(), file, sort_keys=True, indent=4) json.dump(desc.to_json(), file, sort_keys=True, indent=4)
def readSharedPackageData(uid): def readSharedPackageData(uid):
with open(PMC_DIR + "/%s/package.json" % uid, 'r') as file: with open(PMC_DIR + "/%s/package.json" % uid, 'r') as file:
return PolyMCSharedPackageData(json.load(file)) return PolyMCSharedPackageData(json.load(file))
class PolyMCVersionIndexEntry(JsonObject): class PolyMCVersionIndexEntry(JsonObject):
version = StringProperty() version = StringProperty()
type = StringProperty(exclude_if_none=True, default=None) type = StringProperty(exclude_if_none=True, default=None)
@ -367,19 +403,23 @@ class PolyMCVersionIndexEntry(JsonObject):
volatile = BooleanProperty(exclude_if_none=True, default=None) volatile = BooleanProperty(exclude_if_none=True, default=None)
sha256 = StringProperty() sha256 = StringProperty()
class PolyMCVersionIndex(VersionedJsonObject): class PolyMCVersionIndex(VersionedJsonObject):
name = StringProperty() name = StringProperty()
uid = StringProperty() uid = StringProperty()
versions = ListProperty(PolyMCVersionIndexEntry) versions = ListProperty(PolyMCVersionIndexEntry)
class PolyMCPackageIndexEntry(JsonObject): class PolyMCPackageIndexEntry(JsonObject):
name = StringProperty() name = StringProperty()
uid = StringProperty() uid = StringProperty()
sha256 = StringProperty() sha256 = StringProperty()
class PolyMCPackageIndex(VersionedJsonObject): class PolyMCPackageIndex(VersionedJsonObject):
packages = ListProperty(PolyMCPackageIndexEntry) packages = ListProperty(PolyMCPackageIndexEntry)
''' '''
The PolyMC static override file for legacy looks like this: The PolyMC static override file for legacy looks like this:
{ {
@ -399,16 +439,19 @@ The PolyMC static override file for legacy looks like this:
} }
''' '''
class LegacyOverrideEntry(JsonObject): class LegacyOverrideEntry(JsonObject):
releaseTime = ISOTimestampProperty(exclude_if_none=True, default=None) releaseTime = ISOTimestampProperty(exclude_if_none=True, default=None)
mainClass = StringProperty(exclude_if_none=True, default=None) mainClass = StringProperty(exclude_if_none=True, default=None)
appletClass = StringProperty(exclude_if_none=True, default=None) appletClass = StringProperty(exclude_if_none=True, default=None)
addTraits = ListProperty(StringProperty, name="+traits", exclude_if_none=True, default=None) addTraits = ListProperty(StringProperty, name="+traits", exclude_if_none=True, default=None)
class LegacyOverrideIndex(JsonObject): class LegacyOverrideIndex(JsonObject):
versions = DictProperty(LegacyOverrideEntry) versions = DictProperty(LegacyOverrideEntry)
def ApplyLegacyOverride (pmcFile, legacyOverride):
def ApplyLegacyOverride(pmcFile, legacyOverride):
# simply hard override classes # simply hard override classes
pmcFile.mainClass = legacyOverride.mainClass pmcFile.mainClass = legacyOverride.mainClass
pmcFile.appletClass = legacyOverride.appletClass pmcFile.appletClass = legacyOverride.appletClass

View File

@ -11,10 +11,12 @@ UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
forever_cache = FileCache('caches/http_cache', forever=True) forever_cache = FileCache('caches/http_cache', forever=True)
sess = CacheControl(requests.Session(), forever_cache) sess = CacheControl(requests.Session(), forever_cache)
def mkdirs(path): def mkdirs(path):
if not os.path.exists(path): if not os.path.exists(path):
os.makedirs(path) os.makedirs(path)
def filehash(filename, hashtype, blocksize=65536): def filehash(filename, hashtype, blocksize=65536):
hash = hashtype() hash = hashtype()
with open(filename, "rb") as f: with open(filename, "rb") as f:
@ -22,12 +24,14 @@ def filehash(filename, hashtype, blocksize=65536):
hash.update(block) hash.update(block)
return hash.hexdigest() return hash.hexdigest()
def get_maven_url(mavenKey, server, ext): def get_maven_url(mavenKey, server, ext):
mavenParts = mavenKey.split(":", 3) mavenParts = mavenKey.split(":", 3)
mavenVerUrl = server + mavenParts[0].replace(".", "/") + "/" + mavenParts[1] + "/" + mavenParts[2] + "/" mavenVerUrl = server + mavenParts[0].replace(".", "/") + "/" + mavenParts[1] + "/" + mavenParts[2] + "/"
mavenUrl = mavenVerUrl + mavenParts[1] + "-" + mavenParts[2] + ext mavenUrl = mavenVerUrl + mavenParts[1] + "-" + mavenParts[2] + ext
return mavenUrl return mavenUrl
def get_json_file(path, url): def get_json_file(path, url):
with open(path, 'w', encoding='utf-8') as f: with open(path, 'w', encoding='utf-8') as f:
r = sess.get(url) r = sess.get(url)
@ -36,6 +40,7 @@ def get_json_file(path, url):
json.dump(version_json, f, sort_keys=True, indent=4) json.dump(version_json, f, sort_keys=True, indent=4)
return version_json return version_json
def get_binary_file(path, url): def get_binary_file(path, url):
with open(path, 'w', encoding='utf-8') as f: with open(path, 'w', encoding='utf-8') as f:
r = sess.get(url) r = sess.get(url)
@ -44,6 +49,7 @@ def get_binary_file(path, url):
for chunk in r.iter_content(chunk_size=128): for chunk in r.iter_content(chunk_size=128):
f.write(chunk) f.write(chunk)
def compute_jar_file(path, url): def compute_jar_file(path, url):
jarPath = path + ".jar" jarPath = path + ".jar"
get_binary_file(jarPath, url) get_binary_file(jarPath, url)
@ -62,13 +68,15 @@ def compute_jar_file(path, url):
with open(path + ".json", 'w') as outfile: with open(path + ".json", 'w') as outfile:
json.dump(data.to_json(), outfile, sort_keys=True, indent=4) json.dump(data.to_json(), outfile, sort_keys=True, indent=4)
mkdirs(UPSTREAM_DIR + "/fabric/meta-v2") mkdirs(UPSTREAM_DIR + "/fabric/meta-v2")
mkdirs(UPSTREAM_DIR + "/fabric/loader-installer-json") mkdirs(UPSTREAM_DIR + "/fabric/loader-installer-json")
mkdirs(UPSTREAM_DIR + "/fabric/jars") mkdirs(UPSTREAM_DIR + "/fabric/jars")
# get the version list for each component we are interested in # get the version list for each component we are interested in
for component in ["intermediary", "loader"]: for component in ["intermediary", "loader"]:
index = get_json_file(UPSTREAM_DIR + "/fabric/meta-v2/" + component + ".json", "https://meta.fabricmc.net/v2/versions/" + component) index = get_json_file(UPSTREAM_DIR + "/fabric/meta-v2/" + component + ".json",
"https://meta.fabricmc.net/v2/versions/" + component)
for it in index: for it in index:
jarMavenUrl = get_maven_url(it["maven"], "https://maven.fabricmc.net/", ".jar") jarMavenUrl = get_maven_url(it["maven"], "https://maven.fabricmc.net/", ".jar")
compute_jar_file(UPSTREAM_DIR + "/fabric/jars/" + it["maven"].replace(":", "."), jarMavenUrl) compute_jar_file(UPSTREAM_DIR + "/fabric/jars/" + it["maven"].replace(":", "."), jarMavenUrl)

View File

@ -18,9 +18,11 @@ from metautil import *
UPSTREAM_DIR = os.environ["UPSTREAM_DIR"] UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
def eprint(*args, **kwargs): def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs) print(*args, file=sys.stderr, **kwargs)
def filehash(filename, hashtype, blocksize=65536): def filehash(filename, hashtype, blocksize=65536):
hash = hashtype() hash = hashtype()
with open(filename, "rb") as f: with open(filename, "rb") as f:
@ -28,6 +30,7 @@ def filehash(filename, hashtype, blocksize=65536):
hash.update(block) hash.update(block)
return hash.hexdigest() return hash.hexdigest()
forever_cache = FileCache('caches/http_cache', forever=True) forever_cache = FileCache('caches/http_cache', forever=True)
sess = CacheControl(requests.Session(), forever_cache) sess = CacheControl(requests.Session(), forever_cache)
@ -67,13 +70,15 @@ for promoKey, shortversion in promotions_json.get('promos').items():
continue continue
elif match.group('promotion') == 'recommended': elif match.group('promotion') == 'recommended':
recommendedSet.add(shortversion) recommendedSet.add(shortversion)
print ('%s added to recommended set' % shortversion) print('%s added to recommended set' % shortversion)
elif match.group('promotion') == 'latest': elif match.group('promotion') == 'latest':
pass pass
else: else:
assert False assert False
versionExpression = re.compile("^(?P<mc>[0-9a-zA-Z_\\.]+)-(?P<ver>[0-9\\.]+\\.(?P<build>[0-9]+))(-(?P<branch>[a-zA-Z0-9\\.]+))?$") versionExpression = re.compile(
"^(?P<mc>[0-9a-zA-Z_\\.]+)-(?P<ver>[0-9\\.]+\\.(?P<build>[0-9]+))(-(?P<branch>[a-zA-Z0-9\\.]+))?$")
def getSingleForgeFilesManifest(longversion): def getSingleForgeFilesManifest(longversion):
pathThing = UPSTREAM_DIR + "/forge/files_manifests/%s.json" % longversion pathThing = UPSTREAM_DIR + "/forge/files_manifests/%s.json" % longversion
@ -81,7 +86,7 @@ def getSingleForgeFilesManifest(longversion):
from_file = False from_file = False
if files_manifest_file.is_file(): if files_manifest_file.is_file():
with open(pathThing, 'r') as f: with open(pathThing, 'r') as f:
files_json=json.load(f) files_json = json.load(f)
from_file = True from_file = True
else: else:
fileUrl = 'https://files.minecraftforge.net/net/minecraftforge/forge/%s/meta.json' % longversion fileUrl = 'https://files.minecraftforge.net/net/minecraftforge/forge/%s/meta.json' % longversion
@ -138,6 +143,7 @@ def getSingleForgeFilesManifest(longversion):
return retDict return retDict
print("") print("")
print("Making dirs...") print("Making dirs...")
os.makedirs(UPSTREAM_DIR + "/forge/jars/", exist_ok=True) os.makedirs(UPSTREAM_DIR + "/forge/jars/", exist_ok=True)
@ -185,8 +191,8 @@ for mcversion, value in main_json.items():
newIndex.by_mcversion.setdefault(mcversion, ForgeMcVersionInfo()) newIndex.by_mcversion.setdefault(mcversion, ForgeMcVersionInfo())
newIndex.by_mcversion[mcversion].versions.append(longversion) newIndex.by_mcversion[mcversion].versions.append(longversion)
# NOTE: we add this later after the fact. The forge promotions file lies about these. # NOTE: we add this later after the fact. The forge promotions file lies about these.
#if entry.latest: # if entry.latest:
#newIndex.by_mcversion[mcversion].latest = longversion # newIndex.by_mcversion[mcversion].latest = longversion
if entry.recommended: if entry.recommended:
newIndex.by_mcversion[mcversion].recommended = longversion newIndex.by_mcversion[mcversion].recommended = longversion
@ -219,14 +225,14 @@ fuckedVersions = []
print("Grabbing installers and dumping installer profiles...") print("Grabbing installers and dumping installer profiles...")
# get the installer jars - if needed - and get the installer profiles out of them # get the installer jars - if needed - and get the installer profiles out of them
for id, entry in newIndex.versions.items(): for id, entry in newIndex.versions.items():
eprint ("Updating Forge %s" % id) eprint("Updating Forge %s" % id)
if entry.mcversion == None: if entry.mcversion == None:
eprint ("Skipping %d with invalid MC version" % entry.build) eprint("Skipping %d with invalid MC version" % entry.build)
continue continue
version = ForgeVersion(entry) version = ForgeVersion(entry)
if version.url() == None: if version.url() == None:
eprint ("Skipping %d with no valid files" % version.build) eprint("Skipping %d with no valid files" % version.build)
continue continue
jarFilepath = UPSTREAM_DIR + "/forge/jars/%s" % version.filename() jarFilepath = UPSTREAM_DIR + "/forge/jars/%s" % version.filename()
@ -244,14 +250,14 @@ for id, entry in newIndex.versions.items():
if installerRefreshRequired: if installerRefreshRequired:
# grab the installer if it's not there # grab the installer if it's not there
if not os.path.isfile(jarFilepath): if not os.path.isfile(jarFilepath):
eprint ("Downloading %s" % version.url()) eprint("Downloading %s" % version.url())
rfile = sess.get(version.url(), stream=True) rfile = sess.get(version.url(), stream=True)
rfile.raise_for_status() rfile.raise_for_status()
with open(jarFilepath, 'wb') as f: with open(jarFilepath, 'wb') as f:
for chunk in rfile.iter_content(chunk_size=128): for chunk in rfile.iter_content(chunk_size=128):
f.write(chunk) f.write(chunk)
eprint ("Processing %s" % version.url()) eprint("Processing %s" % version.url())
# harvestables from the installer # harvestables from the installer
if not os.path.isfile(profileFilepath): if not os.path.isfile(profileFilepath):
print(jarFilepath) print(jarFilepath)
@ -299,7 +305,7 @@ for id, entry in newIndex.versions.items():
if version.isSupported(): if version.isSupported():
raise exception raise exception
else: else:
eprint ("Version %s is not supported and won't be generated later." % version.longVersion) eprint("Version %s is not supported and won't be generated later." % version.longVersion)
with open(profileFilepath, 'wb') as profileFile: with open(profileFilepath, 'wb') as profileFile:
profileFile.write(installProfileJsonData) profileFile.write(installProfileJsonData)
@ -308,13 +314,13 @@ for id, entry in newIndex.versions.items():
# installer info v1 # installer info v1
if not os.path.isfile(installerInfoFilepath): if not os.path.isfile(installerInfoFilepath):
installerInfo = InstallerInfo() installerInfo = InstallerInfo()
eprint ("SHA1 %s" % jarFilepath) eprint("SHA1 %s" % jarFilepath)
installerInfo.sha1hash = filehash(jarFilepath, hashlib.sha1) installerInfo.sha1hash = filehash(jarFilepath, hashlib.sha1)
eprint ("SHA256 %s" % jarFilepath) eprint("SHA256 %s" % jarFilepath)
installerInfo.sha256hash = filehash(jarFilepath, hashlib.sha256) installerInfo.sha256hash = filehash(jarFilepath, hashlib.sha256)
eprint ("SIZE %s" % jarFilepath) eprint("SIZE %s" % jarFilepath)
installerInfo.size = os.path.getsize(jarFilepath) installerInfo.size = os.path.getsize(jarFilepath)
eprint ("DUMP %s" % jarFilepath) eprint("DUMP %s" % jarFilepath)
with open(installerInfoFilepath, 'w', encoding='utf-8') as installerInfoFile: with open(installerInfoFilepath, 'w', encoding='utf-8') as installerInfoFile:
json.dump(installerInfo.to_json(), installerInfoFile, sort_keys=True, indent=4) json.dump(installerInfo.to_json(), installerInfoFile, sort_keys=True, indent=4)
installerInfoFile.close() installerInfoFile.close()
@ -335,7 +341,7 @@ for id, entry in newIndex.versions.items():
for chunk in rfile.iter_content(chunk_size=128): for chunk in rfile.iter_content(chunk_size=128):
f.write(chunk) f.write(chunk)
# find the latest timestamp in the zip file # find the latest timestamp in the zip file
tstamp = datetime.datetime.fromtimestamp(0) tstamp = datetime.datetime.fromtimestamp(0)
with zipfile.ZipFile(jarFilepath, 'r') as jar: with zipfile.ZipFile(jarFilepath, 'r') as jar:
allinfo = jar.infolist() allinfo = jar.infolist()
for info in allinfo: for info in allinfo:

View File

@ -11,13 +11,14 @@ from liteloaderutil import *
UPSTREAM_DIR = os.environ["UPSTREAM_DIR"] UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
def eprint(*args, **kwargs): def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs) print(*args, file=sys.stderr, **kwargs)
forever_cache = FileCache('caches/http_cache', forever=True) forever_cache = FileCache('caches/http_cache', forever=True)
sess = CacheControl(requests.Session(), forever_cache) sess = CacheControl(requests.Session(), forever_cache)
# get the remote version list # get the remote version list
r = sess.get('http://dl.liteloader.com/versions/versions.json') r = sess.get('http://dl.liteloader.com/versions/versions.json')
r.raise_for_status() r.raise_for_status()

View File

@ -8,6 +8,7 @@ UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
forever_cache = FileCache('caches/http_cache', forever=True) forever_cache = FileCache('caches/http_cache', forever=True)
sess = CacheControl(requests.Session(), forever_cache) sess = CacheControl(requests.Session(), forever_cache)
def get_version_file(path, url): def get_version_file(path, url):
with open(path, 'w', encoding='utf-8') as f: with open(path, 'w', encoding='utf-8') as f:
r = sess.get(url) r = sess.get(url)
@ -18,6 +19,7 @@ def get_version_file(path, url):
json.dump(version_json, f, sort_keys=True, indent=4) json.dump(version_json, f, sort_keys=True, indent=4)
return assetId, assetUrl return assetId, assetUrl
def get_file(path, url): def get_file(path, url):
with open(path, 'w', encoding='utf-8') as f: with open(path, 'w', encoding='utf-8') as f:
r = sess.get(url) r = sess.get(url)
@ -25,6 +27,7 @@ def get_file(path, url):
version_json = r.json() version_json = r.json()
json.dump(version_json, f, sort_keys=True, indent=4) json.dump(version_json, f, sort_keys=True, indent=4)
# get the local version list # get the local version list
localVersionlist = None localVersionlist = None
try: try:
@ -60,12 +63,12 @@ assets = {}
for id in updatedIDs: for id in updatedIDs:
version = remoteVersionlist.versions[id] version = remoteVersionlist.versions[id]
print("Updating " + version.id + " to timestamp " + version.releaseTime.strftime('%s')) print("Updating " + version.id + " to timestamp " + version.releaseTime.strftime('%s'))
assetId, assetUrl = get_version_file( UPSTREAM_DIR + "/mojang/versions/" + id + '.json', version.url) assetId, assetUrl = get_version_file(UPSTREAM_DIR + "/mojang/versions/" + id + '.json', version.url)
assets[assetId] = assetUrl assets[assetId] = assetUrl
for assetId, assetUrl in iter(assets.items()): for assetId, assetUrl in iter(assets.items()):
print("assets", assetId, assetUrl) print("assets", assetId, assetUrl)
get_file( UPSTREAM_DIR + "/mojang/assets/" + assetId + '.json', assetUrl) get_file(UPSTREAM_DIR + "/mojang/assets/" + assetId + '.json', assetUrl)
with open(UPSTREAM_DIR + "/mojang/version_manifest_v2.json", 'w', encoding='utf-8') as f: with open(UPSTREAM_DIR + "/mojang/version_manifest_v2.json", 'w', encoding='utf-8') as f:
json.dump(main_json, f, sort_keys=True, indent=4) json.dump(main_json, f, sort_keys=True, indent=4)