Some fixes for updating and generating forge files

This commit is contained in:
Petr Mrázek 2021-10-25 06:48:22 +02:00
parent 921be2793a
commit 1645c727b4
3 changed files with 95 additions and 10 deletions

View File

@ -53,6 +53,24 @@ class ForgeVersion:
else:
return self.universal_url
def isSupported(self):
if self.url() == None:
return False
versionElements = self.rawVersion.split('.')
if len(versionElements) < 1:
return False
majorVersionStr = versionElements[0]
if not majorVersionStr.isnumeric():
return False
majorVersion = int(majorVersionStr)
if majorVersion >= 37:
return False
return True
class ForgeFile(JsonObject):
classifier = StringProperty(required=True)
hash = StringProperty(required=True)
@ -239,6 +257,25 @@ class ProcessorSpec(JsonObject):
args = ListProperty(StringProperty)
outputs = DictProperty(StringProperty)
# 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...
class ForgeInstallerProfileV1_5(JsonObject):
_comment = ListProperty(StringProperty)
spec = IntegerProperty()
profile = StringProperty()
version = StringProperty()
icon = StringProperty()
json = StringProperty()
path = GradleSpecifierProperty()
logo = StringProperty()
minecraft = StringProperty()
welcome = StringProperty()
# We don't know what 'data' actually is in this one. It's an empty array
data = ListProperty(StringProperty)
processors = ListProperty(ProcessorSpec)
libraries = ListProperty(MojangLibrary)
mirrorList = StringProperty(exclude_if_none=True, default=None)
class ForgeInstallerProfileV2(JsonObject):
_comment = ListProperty(StringProperty)
spec = IntegerProperty()

View File

@ -80,7 +80,7 @@ def versionFromProfile(profile, version):
fixedName.classifier = "universal"
ourLib = MultiMCLibrary(name=fixedName)
if forgeLib.url == "http://files.minecraftforge.net/maven/":
ourLib.url = "https://files.minecraftforge.net/maven/"
ourLib.url = "https://maven.minecraftforge.net/"
else:
ourLib.url = forgeLib.url
#if forgeLib.checksums and len(forgeLib.checksums) == 2:
@ -336,6 +336,7 @@ for id, entry in remoteVersionlist.versions.items():
installerVersionFilepath = "upstream/forge/version_manifests/%s.json" % version.longVersion
profileFilepath = "upstream/forge/installer_manifests/%s.json" % version.longVersion
eprint(installerVersionFilepath)
if os.path.isfile(installerVersionFilepath):
with open(installerVersionFilepath, 'r', encoding='utf-8') as installerVersionFile:
installerVersion = MojangVersionFile(json.load(installerVersionFile))

View File

@ -105,8 +105,16 @@ def getSingleForgeFilesManifest(longversion):
while index < len(extensionObj.items()):
mutableCopy = copy.deepcopy(extensionObj)
extension, hash = mutableCopy.popitem()
if not type(classifier) == str:
pprint(classifier)
pprint(extensionObj)
if not type(hash) == str:
pprint(classifier)
pprint(extensionObj)
print('%s: Skipping missing hash for extension %s:' % (longversion, extension))
index = index + 1
continue
assert type(classifier) == str
assert type(hash) == str
processedHash = re.sub(r"\W", "", hash)
if not len(processedHash) == 32:
print('%s: Skipping invalid hash for extension %s:' % (longversion, extension))
@ -210,6 +218,8 @@ versions = []
legacyinfolist = ForgeLegacyInfoList()
tsPath = "static/forge-legacyinfo.json"
fuckedVersions = []
print("Grabbing installers and dumping installer profiles...")
# get the installer jars - if needed - and get the installer profiles out of them
for id, entry in newIndex.versions.items():
@ -250,18 +260,55 @@ for id, entry in newIndex.versions.items():
if not os.path.isfile(profileFilepath):
print(jarFilepath)
with zipfile.ZipFile(jarFilepath, 'r') as jar:
with jar.open('install_profile.json', 'r') as profileZipEntry:
with open(profileFilepath, 'wb') as profileFile:
profileFile.write(profileZipEntry.read())
profileFile.close()
profileZipEntry.close()
with suppress(KeyError):
with jar.open('version.json', 'r') as profileZipEntry:
with open(versionJsonFilepath, 'wb') as versionJsonFile:
versionJsonFile.write(profileZipEntry.read())
versionJsonFile.close()
versionJsonData = profileZipEntry.read();
versionJsonJson = json.loads(versionJsonData)
profileZipEntry.close()
# Process: does it parse?
doesItParse = MojangVersionFile(versionJsonJson)
with open(versionJsonFilepath, 'wb') as versionJsonFile:
versionJsonFile.write(versionJsonData)
versionJsonFile.close()
with jar.open('install_profile.json', 'r') as profileZipEntry:
installProfileJsonData = profileZipEntry.read()
profileZipEntry.close()
# Process: does it parse?
installProfileJsonJson = json.loads(installProfileJsonData)
atLeastOneFormatWorked = False
exception = None
try:
doesItParseV1 = ForgeInstallerProfile(installProfileJsonJson)
atLeastOneFormatWorked = True
except BaseException as err:
exception = err
try:
doesItParseV2 = ForgeInstallerProfileV2(installProfileJsonJson)
atLeastOneFormatWorked = True
except BaseException as err:
exception = err
# NOTE: Only here for 1.12.2-14.23.5.2851
try:
doesItParseV1_5 = ForgeInstallerProfileV1_5(installProfileJsonJson)
atLeastOneFormatWorked = True
except BaseException as err:
exception = err
if not atLeastOneFormatWorked:
if version.isSupported():
raise exception
else:
eprint ("Version %s is not supported and won't be generated later." % version.longVersion)
with open(profileFilepath, 'wb') as profileFile:
profileFile.write(installProfileJsonData)
profileFile.close()
# installer info v1
if not os.path.isfile(installerInfoFilepath):
installerInfo = InstallerInfo()