mirror of
https://github.com/unmojang/meta.git
synced 2025-09-24 03:31:03 -04:00
add Fabric support
This commit is contained in:
parent
87b0bfe4a4
commit
4bff382e75
33
fabricutil.py
Normal file
33
fabricutil.py
Normal file
@ -0,0 +1,33 @@
|
||||
from metautil import *
|
||||
import jsonobject
|
||||
|
||||
# barebones semver-like parser
|
||||
def isFabricVerStable(ver):
|
||||
s = ver.split("+")
|
||||
return ("-" not in s[0])
|
||||
|
||||
class FabricInstallerArguments(JsonObject):
|
||||
client = ListProperty(StringProperty)
|
||||
common = ListProperty(StringProperty)
|
||||
server = ListProperty(StringProperty)
|
||||
|
||||
class FabricInstallerLaunchwrapper(JsonObject):
|
||||
tweakers = ObjectProperty(FabricInstallerArguments, required=True)
|
||||
|
||||
class FabricInstallerLibraries(JsonObject):
|
||||
client = ListProperty(MultiMCLibrary)
|
||||
common = ListProperty(MultiMCLibrary)
|
||||
server = ListProperty(MultiMCLibrary)
|
||||
|
||||
class FabricInstallerDataV1(JsonObject):
|
||||
version = IntegerProperty(required=True)
|
||||
libraries = ObjectProperty(FabricInstallerLibraries, required=True)
|
||||
mainClass = jsonobject.DefaultProperty()
|
||||
arguments = ObjectProperty(FabricInstallerArguments, required=False)
|
||||
launchwrapper = ObjectProperty(FabricInstallerLaunchwrapper, required=False)
|
||||
|
||||
class FabricJarInfo(JsonObject):
|
||||
releaseTime = ISOTimestampProperty()
|
||||
size = IntegerProperty()
|
||||
sha256 = StringProperty()
|
||||
sha1 = StringProperty()
|
98
generateFabric.py
Executable file
98
generateFabric.py
Executable file
@ -0,0 +1,98 @@
|
||||
#!/usr/bin/python3
|
||||
from fabricutil import *
|
||||
from jsonobject import *
|
||||
from datetime import datetime
|
||||
from pprint import pprint
|
||||
import os, copy
|
||||
|
||||
# turn loader versions into packages
|
||||
loaderRecommended = []
|
||||
loaderVersions = []
|
||||
intermediaryRecommended = []
|
||||
intermediaryVersions = []
|
||||
|
||||
def mkdirs(path):
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
|
||||
mkdirs("multimc/net.fabricmc.fabric-loader")
|
||||
mkdirs("multimc/net.fabricmc.intermediary")
|
||||
|
||||
def loadJarInfo(mavenKey):
|
||||
with open("upstream/fabric/jars/" + mavenKey.replace(":", ".") + ".json", 'r', encoding='utf-8') as jarInfoFile:
|
||||
return FabricJarInfo(json.load(jarInfoFile))
|
||||
|
||||
def processLoaderVersion(loaderVersion, it, loaderData):
|
||||
verStable = isFabricVerStable(loaderVersion)
|
||||
if (len(loaderRecommended) < 1) and verStable:
|
||||
loaderRecommended.append(loaderVersion)
|
||||
versionJarInfo = loadJarInfo(it["maven"])
|
||||
version = MultiMCVersionFile(name="Fabric Loader", uid="net.fabricmc.fabric-loader", version=loaderVersion)
|
||||
version.releaseTime = versionJarInfo.releaseTime
|
||||
version.requires = []
|
||||
version.order = 10
|
||||
if verStable:
|
||||
version.type = "release"
|
||||
else:
|
||||
version.type = "snapshot"
|
||||
if isinstance(loaderData.mainClass, dict):
|
||||
version.mainClass = loaderData.mainClass["client"]
|
||||
else:
|
||||
version.mainClass = loaderData.mainClass
|
||||
version.libraries = []
|
||||
version.libraries.extend(loaderData.libraries.common)
|
||||
version.libraries.extend(loaderData.libraries.client)
|
||||
loaderLib = MultiMCLibrary(name=GradleSpecifier(it["maven"]), url="https://maven.fabricmc.net")
|
||||
version.libraries.append(loaderLib)
|
||||
loaderVersions.append(version)
|
||||
|
||||
def processIntermediaryVersion(it):
|
||||
intermediaryRecommended.append(it["version"])
|
||||
versionJarInfo = loadJarInfo(it["maven"])
|
||||
version = MultiMCVersionFile(name="Intermediary Mappings", uid="net.fabricmc.intermediary", version=it["version"])
|
||||
version.releaseTime = versionJarInfo.releaseTime
|
||||
version.requires = [DependencyEntry(uid='net.minecraft', equals=it["version"])]
|
||||
version.order = 10
|
||||
version.type = "release"
|
||||
version.libraries = []
|
||||
mappingLib = MultiMCLibrary(name=GradleSpecifier(it["maven"]), url="https://maven.fabricmc.net")
|
||||
version.libraries.append(mappingLib)
|
||||
intermediaryVersions.append(version)
|
||||
|
||||
with open("upstream/fabric/meta-v2/loader.json", 'r', encoding='utf-8') as loaderVersionIndexFile:
|
||||
loaderVersionIndex = json.load(loaderVersionIndexFile)
|
||||
for it in loaderVersionIndex:
|
||||
version = it["version"]
|
||||
with open("upstream/fabric/loader-installer-json/" + version + ".json", 'r', encoding='utf-8') as loaderVersionFile:
|
||||
ldata = json.load(loaderVersionFile)
|
||||
ldata = FabricInstallerDataV1(ldata)
|
||||
processLoaderVersion(version, it, ldata)
|
||||
|
||||
with open("upstream/fabric/meta-v2/intermediary.json", 'r', encoding='utf-8') as intermediaryVersionIndexFile:
|
||||
intermediaryVersionIndex = json.load(intermediaryVersionIndexFile)
|
||||
for it in intermediaryVersionIndex:
|
||||
processIntermediaryVersion(it)
|
||||
|
||||
for version in loaderVersions:
|
||||
outFilepath = "multimc/net.fabricmc.fabric-loader/%s.json" % version.version
|
||||
with open(outFilepath, 'w') as outfile:
|
||||
json.dump(version.to_json(), outfile, sort_keys=True, indent=4)
|
||||
|
||||
sharedData = MultiMCSharedPackageData(uid = 'net.fabricmc.fabric-loader', name = 'Fabric Loader')
|
||||
sharedData.recommended = loaderRecommended
|
||||
sharedData.description = "Fabric Loader is a tool to load Fabric-compatible mods in game environments."
|
||||
sharedData.projectUrl = "https://fabricmc.net"
|
||||
sharedData.authors = ["Fabric Developers"]
|
||||
sharedData.write()
|
||||
|
||||
for version in intermediaryVersions:
|
||||
outFilepath = "multimc/net.fabricmc.intermediary/%s.json" % version.version
|
||||
with open(outFilepath, 'w') as outfile:
|
||||
json.dump(version.to_json(), outfile, sort_keys=True, indent=4)
|
||||
|
||||
sharedData = MultiMCSharedPackageData(uid = 'net.fabricmc.intermediary', name = 'Intermediary Mappings')
|
||||
sharedData.recommended = intermediaryRecommended
|
||||
sharedData.description = "Intermediary mappings allow using Fabric Loader with mods for Minecraft in a more compatible manner."
|
||||
sharedData.projectUrl = "https://fabricmc.net"
|
||||
sharedData.authors = ["Fabric Developers"]
|
||||
sharedData.write()
|
12
update.sh
12
update.sh
@ -40,10 +40,14 @@ cd "${BASEDIR}"
|
||||
|
||||
./updateMojang.py || fail_in
|
||||
./updateForge2.py || fail_in
|
||||
./updateFabric.py || fail_in
|
||||
./updateLiteloader.py || fail_in
|
||||
|
||||
cd "${BASEDIR}/${UPSTREAM_DIR}"
|
||||
git add mojang/version_manifest.json mojang/versions/* mojang/assets/* forge/*.json liteloader/*.json || fail_in
|
||||
git add mojang/version_manifest.json mojang/versions/* mojang/assets/* || fail_in
|
||||
git add forge/*.json || fail_in
|
||||
git add fabric/loader-installer-json/*.json fabric/meta-v2/*.json || fail_in
|
||||
git add liteloader/*.json || fail_in
|
||||
if ! git diff --cached --exit-code ; then
|
||||
git commit -a -m "Update ${currentDate}" || fail_in
|
||||
GIT_SSH_COMMAND="ssh -i ${BASEDIR}/config/meta-upstream.key" git push || exit 1
|
||||
@ -57,11 +61,15 @@ cd "${BASEDIR}"
|
||||
|
||||
./generateMojang.py || fail_out
|
||||
./generateForge2.py || fail_out
|
||||
./generateFabric.py || fail_in
|
||||
./generateLiteloader.py || fail_out
|
||||
./index.py || fail_out
|
||||
|
||||
cd "${BASEDIR}/${MMC_DIR}"
|
||||
git add index.json org.lwjgl/* net.minecraft/* net.minecraftforge/* com.mumfrey.liteloader/* || fail_out
|
||||
git add index.json org.lwjgl/* net.minecraft/* || fail_out
|
||||
git add net.minecraftforge/* || fail_out
|
||||
git add net.fabricmc.fabric-loader/* net.fabricmc.intermediary/* || fail_out
|
||||
git add com.mumfrey.liteloader/* || fail_out
|
||||
if [ -d "org.lwjgl3" ]; then
|
||||
git add org.lwjgl3/* || fail_out
|
||||
fi
|
||||
|
81
updateFabric.py
Executable file
81
updateFabric.py
Executable file
@ -0,0 +1,81 @@
|
||||
#!/usr/bin/python3
|
||||
import os, requests
|
||||
from cachecontrol import CacheControl
|
||||
import datetime
|
||||
import hashlib, json
|
||||
import zipfile
|
||||
from fabricutil import *
|
||||
|
||||
from cachecontrol.caches import FileCache
|
||||
|
||||
forever_cache = FileCache('http_cache', forever=True)
|
||||
sess = CacheControl(requests.Session(), forever_cache)
|
||||
|
||||
def mkdirs(path):
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
|
||||
def filehash(filename, hashtype, blocksize=65536):
|
||||
hash = hashtype()
|
||||
with open(filename, "rb") as f:
|
||||
for block in iter(lambda: f.read(blocksize), b""):
|
||||
hash.update(block)
|
||||
return hash.hexdigest()
|
||||
|
||||
def get_maven_url(mavenKey, server, ext):
|
||||
mavenParts = mavenKey.split(":", 3)
|
||||
mavenVerUrl = server + mavenParts[0].replace(".", "/") + "/" + mavenParts[1] + "/" + mavenParts[2] + "/"
|
||||
mavenUrl = mavenVerUrl + mavenParts[1] + "-" + mavenParts[2] + ext
|
||||
return mavenUrl
|
||||
|
||||
def get_json_file(path, url):
|
||||
with open(path, 'w', encoding='utf-8') as f:
|
||||
r = sess.get(url)
|
||||
r.raise_for_status()
|
||||
version_json = r.json()
|
||||
json.dump(version_json, f, sort_keys=True, indent=4)
|
||||
return version_json
|
||||
|
||||
def get_binary_file(path, url):
|
||||
with open(path, 'w', encoding='utf-8') as f:
|
||||
r = sess.get(url)
|
||||
r.raise_for_status()
|
||||
with open(path, 'wb') as f:
|
||||
for chunk in r.iter_content(chunk_size=128):
|
||||
f.write(chunk)
|
||||
|
||||
def compute_jar_file(path, url):
|
||||
jarPath = path + ".jar"
|
||||
get_binary_file(jarPath, url)
|
||||
tstamp = datetime.datetime.fromtimestamp(0)
|
||||
with zipfile.ZipFile(jarPath, 'r') as jar:
|
||||
allinfo = jar.infolist()
|
||||
for info in allinfo:
|
||||
tstampNew = datetime.datetime(*info.date_time)
|
||||
if tstampNew > tstamp:
|
||||
tstamp = tstampNew
|
||||
data = FabricJarInfo()
|
||||
data.releaseTime = tstamp
|
||||
data.sha1 = filehash(jarPath, hashlib.sha1)
|
||||
data.sha256 = filehash(jarPath, hashlib.sha256)
|
||||
data.size = os.path.getsize(jarPath)
|
||||
with open(path + ".json", 'w') as outfile:
|
||||
json.dump(data.to_json(), outfile, sort_keys=True, indent=4)
|
||||
|
||||
mkdirs("upstream/fabric/meta-v2")
|
||||
mkdirs("upstream/fabric/loader-installer-json")
|
||||
mkdirs("upstream/fabric/jars")
|
||||
|
||||
# get the version list for each component we are interested in
|
||||
for component in ["intermediary", "loader"]:
|
||||
index = get_json_file("upstream/fabric/meta-v2/" + component + ".json", "https://meta.fabricmc.net/v2/versions/" + component)
|
||||
for it in index:
|
||||
jarMavenUrl = get_maven_url(it["maven"], "https://maven.fabricmc.net/", ".jar")
|
||||
compute_jar_file("upstream/fabric/jars/" + it["maven"].replace(":", "."), jarMavenUrl)
|
||||
|
||||
# for each loader, download installer JSON file from maven
|
||||
with open("upstream/fabric/meta-v2/loader.json", 'r', encoding='utf-8') as loaderVersionIndexFile:
|
||||
loaderVersionIndex = json.load(loaderVersionIndexFile)
|
||||
for it in loaderVersionIndex:
|
||||
mavenUrl = get_maven_url(it["maven"], "https://maven.fabricmc.net/", ".json")
|
||||
get_json_file("upstream/fabric/loader-installer-json/" + it["version"] + ".json", mavenUrl)
|
Loading…
x
Reference in New Issue
Block a user