Removed other sources

This commit is contained in:
Mio.
2025-06-28 00:06:48 +02:00
parent 965c2a4f43
commit 8ddfe82fd6
5479 changed files with 789 additions and 22912 deletions

88
.github/scripts/create-repo.py vendored Normal file
View File

@@ -0,0 +1,88 @@
import json
import os
import re
import subprocess
from pathlib import Path
from zipfile import ZipFile
PACKAGE_NAME_REGEX = re.compile(r"package: name='([^']+)'")
VERSION_CODE_REGEX = re.compile(r"versionCode='([^']+)'")
VERSION_NAME_REGEX = re.compile(r"versionName='([^']+)'")
IS_NSFW_REGEX = re.compile(r"'tachiyomi.extension.nsfw' value='([^']+)'")
APPLICATION_LABEL_REGEX = re.compile(r"^application-label:'([^']+)'", re.MULTILINE)
APPLICATION_ICON_320_REGEX = re.compile(r"^application-icon-320:'([^']+)'", re.MULTILINE)
LANGUAGE_REGEX = re.compile(r"tachiyomi-([^.]+)")
*_, ANDROID_BUILD_TOOLS = (Path(os.environ["ANDROID_HOME"]) / "build-tools").iterdir()
REPO_DIR = Path("repo")
REPO_APK_DIR = REPO_DIR / "apk"
REPO_ICON_DIR = REPO_DIR / "icon"
REPO_ICON_DIR.mkdir(parents=True, exist_ok=True)
with open("output.json", encoding="utf-8") as f:
inspector_data = json.load(f)
index_min_data = []
for apk in REPO_APK_DIR.iterdir():
badging = subprocess.check_output(
[
ANDROID_BUILD_TOOLS / "aapt",
"dump",
"--include-meta-data",
"badging",
apk,
]
).decode()
package_info = next(x for x in badging.splitlines() if x.startswith("package: "))
package_name = PACKAGE_NAME_REGEX.search(package_info).group(1)
application_icon = APPLICATION_ICON_320_REGEX.search(badging).group(1)
with ZipFile(apk) as z, z.open(application_icon) as i, (
REPO_ICON_DIR / f"{package_name}.png"
).open("wb") as f:
f.write(i.read())
language = LANGUAGE_REGEX.search(apk.name).group(1)
sources = inspector_data[package_name]
if len(sources) == 1:
source_language = sources[0]["lang"]
if (
source_language != language
and source_language not in {"all", "other"}
and language not in {"all", "other"}
):
language = source_language
common_data = {
"name": APPLICATION_LABEL_REGEX.search(badging).group(1),
"pkg": package_name,
"apk": apk.name,
"lang": language,
"code": int(VERSION_CODE_REGEX.search(package_info).group(1)),
"version": VERSION_NAME_REGEX.search(package_info).group(1),
"nsfw": int(IS_NSFW_REGEX.search(badging).group(1)),
}
min_data = {
**common_data,
"sources": [],
}
for source in sources:
min_data["sources"].append(
{
"name": source["name"],
"lang": source["lang"],
"id": source["id"],
"baseUrl": source["baseUrl"],
}
)
index_min_data.append(min_data)
with REPO_DIR.joinpath("index.min.json").open("w", encoding="utf-8") as index_file:
json.dump(index_min_data, index_file, ensure_ascii=False, separators=(",", ":"))

View File

@@ -0,0 +1,113 @@
import itertools
import json
import os
import re
import subprocess
import sys
from pathlib import Path
from typing import NoReturn
EXTENSION_REGEX = re.compile(r"^src/(?P<lang>\w+)/(?P<extension>\w+)")
MULTISRC_LIB_REGEX = re.compile(r"^lib-multisrc/(?P<multisrc>\w+)")
LIB_REGEX = re.compile(r"^lib/(?P<lib>\w+)")
MODULE_REGEX = re.compile(r"^:src:(?P<lang>\w+):(?P<extension>\w+)$")
CORE_FILES_REGEX = re.compile(
r"^(buildSrc/|core/|gradle/|build\.gradle\.kts|common\.gradle|gradle\.properties|settings\.gradle\.kts|utils/)"
)
def run_command(command: str) -> str:
result = subprocess.run(command, capture_output=True, text=True, shell=True)
if result.returncode != 0:
print(result.stderr.strip())
sys.exit(result.returncode)
return result.stdout.strip()
def get_module_list(ref: str) -> tuple[list[str], list[str]]:
changed_files = run_command(f"git diff --name-only {ref}").splitlines()
modules = set()
libs = set()
deleted = set()
core_files_changed = False
for file in map(lambda x: Path(x).as_posix(), changed_files):
if CORE_FILES_REGEX.search(file):
core_files_changed = True
elif match := EXTENSION_REGEX.search(file):
lang = match.group("lang")
extension = match.group("extension")
if Path("src", lang, extension).is_dir():
modules.add(f':src:{lang}:{extension}')
deleted.add(f"{lang}.{extension}")
elif match := MULTISRC_LIB_REGEX.search(file):
multisrc = match.group("multisrc")
if Path("lib-multisrc", multisrc).is_dir():
libs.add(f":lib-multisrc:{multisrc}:printDependentExtensions")
elif match := LIB_REGEX.search(file):
lib = match.group("lib")
if Path("lib", lib).is_dir():
libs.add(f":lib:{lib}:printDependentExtensions")
def is_extension_module(module: str) -> bool:
if not (match := MODULE_REGEX.search(module)):
return False
lang = match.group("lang")
extension = match.group("extension")
deleted.add(f"{lang}.{extension}")
return True
if len(libs) != 0 and not core_files_changed:
modules.update([
module for module in
run_command("./gradlew -q " + " ".join(libs)).splitlines()
if is_extension_module(module)
])
if os.getenv("IS_PR_CHECK") != "true" and not core_files_changed:
with Path(".github/always_build.json").open() as always_build_file:
always_build = json.load(always_build_file)
for extension in always_build:
modules.add(":src:" + extension.replace(".", ":"))
deleted.add(extension)
if core_files_changed:
(all_modules, all_deleted) = get_all_modules()
modules.update(all_modules)
deleted.update(all_deleted)
return list(modules), list(deleted)
def get_all_modules() -> tuple[list[str], list[str]]:
modules = []
deleted = []
for lang in Path("src").iterdir():
for extension in lang.iterdir():
modules.append(f":src:{lang.name}:{extension.name}")
deleted.append(f"{lang.name}.{extension.name}")
return modules, deleted
def main() -> NoReturn:
_, ref, build_type = sys.argv
modules, deleted = get_module_list(ref)
chunked = {
"chunk": [
{"number": i + 1, "modules": modules}
for i, modules in
enumerate(itertools.batched(
map(lambda x: f"{x}:assemble{build_type}", modules),
int(os.getenv("CI_CHUNK_SIZE", 65))
))
]
}
print(f"Module chunks to build:\n{json.dumps(chunked, indent=2)}\n\nModule to delete:\n{json.dumps(deleted, indent=2)}")
if os.getenv("CI") == "true":
with open(os.getenv("GITHUB_OUTPUT"), 'a') as out_file:
out_file.write(f"matrix={json.dumps(chunked)}\n")
out_file.write(f"delete={json.dumps(deleted)}\n")
if __name__ == '__main__':
main()

50
.github/scripts/merge-repo.py vendored Normal file
View File

@@ -0,0 +1,50 @@
import html
import sys
import json
from pathlib import Path
import shutil
REMOTE_REPO: Path = Path.cwd()
LOCAL_REPO: Path = REMOTE_REPO.parent.joinpath(sys.argv[2])
to_delete: list[str] = json.loads(sys.argv[1])
for module in to_delete:
apk_name = f"tachiyomi-{module}-v*.*.*.apk"
icon_name = f"eu.kanade.tachiyomi.extension.{module}.png"
for file in REMOTE_REPO.joinpath("apk").glob(apk_name):
print(file.name)
file.unlink(missing_ok=True)
for file in REMOTE_REPO.joinpath("icon").glob(icon_name):
print(file.name)
file.unlink(missing_ok=True)
shutil.copytree(src=LOCAL_REPO.joinpath("apk"), dst=REMOTE_REPO.joinpath("apk"), dirs_exist_ok = True)
shutil.copytree(src=LOCAL_REPO.joinpath("icon"), dst=REMOTE_REPO.joinpath("icon"), dirs_exist_ok = True)
with REMOTE_REPO.joinpath("index.min.json").open() as remote_index_file:
remote_index = json.load(remote_index_file)
with LOCAL_REPO.joinpath("index.min.json").open() as local_index_file:
local_index = json.load(local_index_file)
index = [
item for item in remote_index
if not any([item["pkg"].endswith(f".{module}") for module in to_delete])
]
index.extend(local_index)
index.sort(key=lambda x: x["pkg"])
with REMOTE_REPO.joinpath("index.json").open("w", encoding="utf-8") as index_file:
json.dump(index, index_file, ensure_ascii=False, indent=2)
with REMOTE_REPO.joinpath("index.min.json").open("w", encoding="utf-8") as index_min_file:
json.dump(index, index_min_file, ensure_ascii=False, separators=(",", ":"))
with REMOTE_REPO.joinpath("index.html").open("w", encoding="utf-8") as index_html_file:
index_html_file.write('<!DOCTYPE html>\n<html>\n<head>\n<meta charset="UTF-8">\n<title>apks</title>\n</head>\n<body>\n<pre>\n')
for entry in index:
apk_escaped = 'apk/' + html.escape(entry["apk"])
name_escaped = html.escape(entry["name"])
index_html_file.write(f'<a href="{apk_escaped}">{name_escaped}</a>\n')
index_html_file.write('</pre>\n</body>\n</html>\n')

12
.github/scripts/move-built-apks.py vendored Normal file
View File

@@ -0,0 +1,12 @@
from pathlib import Path
import shutil
REPO_APK_DIR = Path("repo/apk")
shutil.rmtree(REPO_APK_DIR, ignore_errors=True)
REPO_APK_DIR.mkdir(parents=True, exist_ok=True)
for apk in Path.home().joinpath("apk-artifacts").glob("**/*.apk"):
apk_name = apk.name.replace("-release.apk", ".apk")
shutil.move(apk, REPO_APK_DIR.joinpath(apk_name))