summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSefa Eyeoglu <contact@scrumplex.net>2023-08-06 15:01:45 +0200
committerSefa Eyeoglu <contact@scrumplex.net>2023-08-06 15:10:55 +0200
commite3a82eda07264045e9b40859d01c7a36af8d193f (patch)
tree463e2284f378a9050f30ffc35daaa138f3fad373
parent51dda0e273b89640ce9d84ea5b4d3ec12de44714 (diff)
downloadProject-Tick-e3a82eda07264045e9b40859d01c7a36af8d193f.tar.gz
Project-Tick-e3a82eda07264045e9b40859d01c7a36af8d193f.zip
fix: remove unused legacy stuff
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
-rw-r--r--generateNeoForge.py109
-rw-r--r--meta/common/neoforge.py3
-rw-r--r--meta/model/neoforge.py15
-rw-r--r--updateNeoForge.py208
4 files changed, 83 insertions, 252 deletions
diff --git a/generateNeoForge.py b/generateNeoForge.py
index 78898c55c7..2e556a6337 100644
--- a/generateNeoForge.py
+++ b/generateNeoForge.py
@@ -11,9 +11,7 @@ from meta.common.neoforge import (
INSTALLER_MANIFEST_DIR,
VERSION_MANIFEST_DIR,
DERIVED_INDEX_FILE,
- STATIC_LEGACYINFO_FILE,
INSTALLER_INFO_DIR,
- BAD_VERSIONS,
FORGEWRAPPER_MAVEN,
)
from meta.common.forge import FORGE_COMPONENT
@@ -30,12 +28,9 @@ from meta.model import (
from meta.model.neoforge import (
NeoForgeVersion,
NeoForgeInstallerProfile,
- NeoForgeLegacyInfo,
- fml_libs_for_version,
NeoForgeInstallerProfileV2,
InstallerInfo,
DerivedNeoForgeIndex,
- NeoForgeLegacyInfoList,
)
from meta.model.mojang import MojangVersion
@@ -149,103 +144,6 @@ def version_from_profile(
return v
-def version_from_modernized_installer(
- installer: MojangVersion, version: NeoForgeVersion
-) -> MetaVersion:
- v = MetaVersion(name="NeoForge", version=version.rawVersion, uid=NEOFORGE_COMPONENT)
- mc_version = version.mc_version
- v.requires = [Dependency(uid=MINECRAFT_COMPONENT, equals=mc_version)]
- v.main_class = installer.main_class
- v.release_time = installer.release_time
-
- args = installer.minecraft_arguments
- tweakers = []
- expression = re.compile("--tweakClass ([a-zA-Z0-9.]+)")
- match = expression.search(args)
- while match is not None:
- tweakers.append(match.group(1))
- args = args[: match.start()] + args[match.end() :]
- match = expression.search(args)
- if len(tweakers) > 0:
- args = args.strip()
- v.additional_tweakers = tweakers
- # v.minecraftArguments = args
-
- v.libraries = []
-
- mc_filter = load_mc_version_filter(mc_version)
- for upstream_lib in installer.libraries:
- forge_lib = Library.parse_obj(
- upstream_lib.dict()
- ) # "cast" MojangLibrary to Library
- if (
- forge_lib.name.is_lwjgl()
- or forge_lib.name.is_log4j()
- or should_ignore_artifact(mc_filter, forge_lib.name)
- ):
- continue
-
- if forge_lib.name.group == "net.minecraftforge":
- if forge_lib.name.artifact == "forge":
- overridden_name = forge_lib.name
- overridden_name.classifier = "universal"
- forge_lib.downloads.artifact.path = overridden_name.path()
- forge_lib.downloads.artifact.url = (
- "https://maven.minecraftforge.net/%s" % overridden_name.path()
- )
- forge_lib.name = overridden_name
-
- elif forge_lib.name.artifact == "minecraftforge":
- overridden_name = forge_lib.name
- overridden_name.artifact = "forge"
- overridden_name.classifier = "universal"
- overridden_name.version = "%s-%s" % (
- mc_version,
- overridden_name.version,
- )
- forge_lib.downloads.artifact.path = overridden_name.path()
- forge_lib.downloads.artifact.url = (
- "https://maven.minecraftforge.net/%s" % overridden_name.path()
- )
- forge_lib.name = overridden_name
-
- v.libraries.append(forge_lib)
-
- v.order = 5
- return v
-
-
-def version_from_legacy(
- info: NeoForgeLegacyInfo, version: NeoForgeVersion
-) -> MetaVersion:
- v = MetaVersion(name="NeoForge", version=version.rawVersion, uid=NEOFORGE_COMPONENT)
- mc_version = version.mc_version_sane
- v.requires = [Dependency(uid=MINECRAFT_COMPONENT, equals=mc_version)]
- v.release_time = info.release_time
- v.order = 5
- if fml_libs_for_version(
- mc_version
- ): # WHY, WHY DID I WASTE MY TIME REWRITING FMLLIBSMAPPING
- v.additional_traits = ["legacyFML"]
-
- classifier = "client"
- if "universal" in version.url():
- classifier = "universal"
-
- main_mod = Library(
- name=GradleSpecifier(
- "net.minecraftforge", "forge", version.long_version, classifier
- )
- )
- main_mod.downloads = MojangLibraryDownloads()
- main_mod.downloads.artifact = MojangArtifact(
- url=version.url(), sha1=info.sha1, size=info.size
- )
- main_mod.downloads.artifact.path = None
- v.jar_mods = [main_mod]
- return v
-
-
def version_from_build_system_installer(
installer: MojangVersion,
profile: NeoForgeInstallerProfileV2,
@@ -345,13 +243,6 @@ def main():
version = NeoForgeVersion(entry)
- if version.long_version in BAD_VERSIONS:
- # Version 1.12.2-14.23.5.2851 is ultra cringe, I can't imagine why you would even spend one second on
- # actually adding support for this version.
- # It is cringe, because it's installer info is broken af
- eprint(f"Skipping bad version {version.long_version}")
- continue
-
if version.url() is None:
eprint("Skipping %s with no valid files" % key)
continue
diff --git a/meta/common/neoforge.py b/meta/common/neoforge.py
index d5d08ec939..079933008a 100644
--- a/meta/common/neoforge.py
+++ b/meta/common/neoforge.py
@@ -9,9 +9,6 @@ VERSION_MANIFEST_DIR = join(BASE_DIR, "version_manifests")
FILE_MANIFEST_DIR = join(BASE_DIR, "files_manifests")
DERIVED_INDEX_FILE = join(BASE_DIR, "derived_index.json")
-STATIC_LEGACYINFO_FILE = join(BASE_DIR, "neoforge-legacyinfo.json")
-
NEOFORGE_COMPONENT = "net.neoforged"
FORGEWRAPPER_MAVEN = "https://files.prismlauncher.org/maven/%s"
-BAD_VERSIONS = [""]
diff --git a/meta/model/neoforge.py b/meta/model/neoforge.py
index b5721d04e8..906b20bfca 100644
--- a/meta/model/neoforge.py
+++ b/meta/model/neoforge.py
@@ -138,17 +138,6 @@ class NeoForgeInstallerProfile(MetaBase):
optionals: Optional[List[NeoForgeOptional]]
-class NeoForgeLegacyInfo(MetaBase):
- release_time: Optional[datetime] = Field(alias="releaseTime")
- size: Optional[int]
- sha256: Optional[str]
- sha1: Optional[str]
-
-
-class NeoForgeLegacyInfoList(MetaBase):
- number: Dict[str, NeoForgeLegacyInfo] = Field({})
-
-
class DataSpec(MetaBase):
client: Optional[str]
server: Optional[str]
@@ -258,7 +247,3 @@ class NeoForgeVersion:
# return False
return True
-
-
-def fml_libs_for_version(mc_version: str) -> List[FMLLib]:
- return []
diff --git a/updateNeoForge.py b/updateNeoForge.py
index d7a6ed80e3..57b5492606 100644
--- a/updateNeoForge.py
+++ b/updateNeoForge.py
@@ -23,20 +23,16 @@ from meta.common.forge import (
INSTALLER_MANIFEST_DIR,
VERSION_MANIFEST_DIR,
FILE_MANIFEST_DIR,
- BAD_VERSIONS,
- STATIC_LEGACYINFO_FILE,
)
from meta.model.neoforge import (
NeoForgeFile,
NeoForgeEntry,
NeoForgeMCVersionInfo,
- NeoForgeLegacyInfoList,
DerivedNeoForgeIndex,
NeoForgeVersion,
NeoForgeInstallerProfile,
NeoForgeInstallerProfileV2,
InstallerInfo,
- NeoForgeLegacyInfo,
)
from meta.model.mojang import MojangVersion
@@ -49,8 +45,6 @@ ensure_upstream_dir(INSTALLER_MANIFEST_DIR)
ensure_upstream_dir(VERSION_MANIFEST_DIR)
ensure_upstream_dir(FILE_MANIFEST_DIR)
-LEGACYINFO_PATH = os.path.join(STATIC_DIR, STATIC_LEGACYINFO_FILE)
-
sess = default_session()
@@ -194,8 +188,6 @@ def main():
new_index.write(UPSTREAM_DIR + "/neoforge/derived_index.json")
- legacy_info_list = NeoForgeLegacyInfoList()
-
print("Grabbing installers and dumping installer profiles...")
# get the installer jars - if needed - and get the installer profiles out of them
for key, entry in new_index.versions.items():
@@ -208,134 +200,100 @@ def main():
if version.url() is None:
eprint("Skipping %d with no valid files" % version.build)
continue
- if version.long_version in BAD_VERSIONS:
- eprint(f"Skipping bad version {version.long_version}")
+ if not version.uses_installer():
+ eprint(f"version {version.long_version} does not use installer")
continue
jar_path = os.path.join(UPSTREAM_DIR, JARS_DIR, version.filename())
- if version.uses_installer():
- installer_info_path = (
- UPSTREAM_DIR + "/neoforge/installer_info/%s.json" % version.long_version
- )
- profile_path = (
- UPSTREAM_DIR
- + "/neoforge/installer_manifests/%s.json" % version.long_version
- )
- version_file_path = (
- UPSTREAM_DIR
- + "/neoforge/version_manifests/%s.json" % version.long_version
- )
-
- installer_refresh_required = not os.path.isfile(
- profile_path
- ) or not os.path.isfile(installer_info_path)
-
- if installer_refresh_required:
- # grab the installer if it's not there
- if not os.path.isfile(jar_path):
- eprint("Downloading %s" % version.url())
- try:
- rfile = sess.get(version.url(), stream=True)
- rfile.raise_for_status()
- Path(jar_path).parent.mkdir(parents=True, exist_ok=True)
- with open(jar_path, "wb") as f:
- for chunk in rfile.iter_content(chunk_size=128):
- f.write(chunk)
- except Exception as e:
- eprint("Failed to download %s" % version.url())
- eprint("Error is %s" % e)
- continue
-
- eprint("Processing %s" % version.url())
- # harvestables from the installer
- if not os.path.isfile(profile_path):
- print(jar_path)
- with zipfile.ZipFile(jar_path) as jar:
- with suppress(KeyError):
- with jar.open("version.json") as profile_zip_entry:
- version_data = profile_zip_entry.read()
-
- # Process: does it parse?
- MojangVersion.parse_raw(version_data)
-
- Path(version_file_path).parent.mkdir(
- parents=True, exist_ok=True
- )
- with open(version_file_path, "wb") as versionJsonFile:
- versionJsonFile.write(version_data)
- versionJsonFile.close()
+ installer_info_path = (
+ UPSTREAM_DIR + "/neoforge/installer_info/%s.json" % version.long_version
+ )
+ profile_path = (
+ UPSTREAM_DIR
+ + "/neoforge/installer_manifests/%s.json" % version.long_version
+ )
+ version_file_path = (
+ UPSTREAM_DIR + "/neoforge/version_manifests/%s.json" % version.long_version
+ )
- with jar.open("install_profile.json") as profile_zip_entry:
- install_profile_data = profile_zip_entry.read()
+ installer_refresh_required = not os.path.isfile(
+ profile_path
+ ) or not os.path.isfile(installer_info_path)
- # Process: does it parse?
- is_parsable = False
- exception = None
- try:
- NeoForgeInstallerProfile.parse_raw(install_profile_data)
- is_parsable = True
- except ValidationError as err:
- exception = err
- try:
- NeoForgeInstallerProfileV2.parse_raw(install_profile_data)
- is_parsable = True
- except ValidationError as err:
- exception = err
-
- if not is_parsable:
- if version.is_supported():
- raise exception
- else:
- eprint(
- "Version %s is not supported and won't be generated later."
- % version.long_version
- )
-
- Path(profile_path).parent.mkdir(parents=True, exist_ok=True)
- with open(profile_path, "wb") as profileFile:
- profileFile.write(install_profile_data)
- profileFile.close()
-
- # installer info v1
- if not os.path.isfile(installer_info_path):
- installer_info = InstallerInfo()
- installer_info.sha1hash = filehash(jar_path, hashlib.sha1)
- installer_info.sha256hash = filehash(jar_path, hashlib.sha256)
- installer_info.size = os.path.getsize(jar_path)
- installer_info.write(installer_info_path)
- else:
- # ignore the two versions without install manifests and jar mod class files
- # TODO: fix those versions?
- if version.mc_version_sane == "1.6.1":
- continue
-
- # only gather legacy info if it's missing
- if not os.path.isfile(LEGACYINFO_PATH):
- # grab the jar/zip if it's not there
- if not os.path.isfile(jar_path):
+ if installer_refresh_required:
+ # grab the installer if it's not there
+ if not os.path.isfile(jar_path):
+ eprint("Downloading %s" % version.url())
+ try:
rfile = sess.get(version.url(), stream=True)
rfile.raise_for_status()
+ Path(jar_path).parent.mkdir(parents=True, exist_ok=True)
with open(jar_path, "wb") as f:
for chunk in rfile.iter_content(chunk_size=128):
f.write(chunk)
- # find the latest timestamp in the zip file
- tstamp = datetime.fromtimestamp(0)
- with zipfile.ZipFile(jar_path) as jar:
- for info in jar.infolist():
- tstamp_new = datetime(*info.date_time)
- if tstamp_new > tstamp:
- tstamp = tstamp_new
- legacy_info = NeoForgeLegacyInfo()
- legacy_info.release_time = tstamp
- legacy_info.sha1 = filehash(jar_path, hashlib.sha1)
- legacy_info.sha256 = filehash(jar_path, hashlib.sha256)
- legacy_info.size = os.path.getsize(jar_path)
- legacy_info_list.number[key] = legacy_info
-
- # only write legacy info if it's missing
- if not os.path.isfile(LEGACYINFO_PATH):
- legacy_info_list.write(LEGACYINFO_PATH)
+ except Exception as e:
+ eprint("Failed to download %s" % version.url())
+ eprint("Error is %s" % e)
+ continue
+
+ eprint("Processing %s" % version.url())
+ # harvestables from the installer
+ if not os.path.isfile(profile_path):
+ print(jar_path)
+ with zipfile.ZipFile(jar_path) as jar:
+ with suppress(KeyError):
+ with jar.open("version.json") as profile_zip_entry:
+ version_data = profile_zip_entry.read()
+
+ # Process: does it parse?
+ MojangVersion.parse_raw(version_data)
+
+ Path(version_file_path).parent.mkdir(
+ parents=True, exist_ok=True
+ )
+ with open(version_file_path, "wb") as versionJsonFile:
+ versionJsonFile.write(version_data)
+ versionJsonFile.close()
+
+ with jar.open("install_profile.json") as profile_zip_entry:
+ install_profile_data = profile_zip_entry.read()
+
+ # Process: does it parse?
+ is_parsable = False
+ exception = None
+ try:
+ NeoForgeInstallerProfile.parse_raw(install_profile_data)
+ is_parsable = True
+ except ValidationError as err:
+ exception = err
+ try:
+ NeoForgeInstallerProfileV2.parse_raw(install_profile_data)
+ is_parsable = True
+ except ValidationError as err:
+ exception = err
+
+ if not is_parsable:
+ if version.is_supported():
+ raise exception
+ else:
+ eprint(
+ "Version %s is not supported and won't be generated later."
+ % version.long_version
+ )
+
+ Path(profile_path).parent.mkdir(parents=True, exist_ok=True)
+ with open(profile_path, "wb") as profileFile:
+ profileFile.write(install_profile_data)
+ profileFile.close()
+
+ # installer info v1
+ if not os.path.isfile(installer_info_path):
+ installer_info = InstallerInfo()
+ installer_info.sha1hash = filehash(jar_path, hashlib.sha1)
+ installer_info.sha256hash = filehash(jar_path, hashlib.sha256)
+ installer_info.size = os.path.getsize(jar_path)
+ installer_info.write(installer_info_path)
if __name__ == "__main__":