Исправление патчей, реализация базвого функционала для сборки apk

This commit is contained in:
2025-09-08 13:07:46 +03:00
parent 0f53c836ae
commit 8a74245c9c
10 changed files with 185 additions and 41 deletions
+30 -5
View File
@@ -4,6 +4,7 @@ import json
import requests
import colorama
import importlib
import traceback
import subprocess
from tqdm import tqdm
@@ -12,7 +13,7 @@ def init() -> dict:
if not os.path.exists(directory):
os.makedirs(directory)
with open("./patches/config.json", "r") as config_file:
with open("./config.json", "r") as config_file:
conf = json.load(config_file)
if not os.path.exists("./tools/apktool.jar"):
@@ -106,6 +107,23 @@ def decompile_apk(apk: str):
sys.exit(1)
def compile_apk(apk: str):
print("Компилируем apk...")
try:
result = subprocess.run(
"tools/apktool b decompiled -o " + os.path.join("modified", apk),
shell=True,
check=True,
text=True,
stdout=subprocess.DEVNULL,
stderr=subprocess.PIPE,
)
except subprocess.CalledProcessError as e:
print("Ошибка при выполнении команды:")
print(e.stderr)
sys.exit(1)
class Patch:
def __init__(self, name, pkg):
self.name = name
@@ -122,7 +140,8 @@ class Patch:
return True
except Exception as e:
print(f"Ошибка при применении патча {self.name}: {e}")
print(e.args)
print(type(e), e.args)
traceback.print_exc()
return False
@@ -150,8 +169,14 @@ for patch in patches:
print(f"{marker}{colorama.Style.RESET_ALL} {patch.name}")
if all(statuses.values()):
print("Все патчи успешно применены")
print(f"{colorama.Fore.GREEN}Все патчи успешно применены{colorama.Style.RESET_ALL}")
compile_apk(apk)
elif any(statuses.values()):
print("Некоторые патчи не были успешно применены")
print(f"{colorama.Fore.YELLOW}{colorama.Style.RESET_ALL} Некоторые патчи не были успешно применены")
if input("Продолжить? (y/n): ").lower() == "y":
compile_apk(apk)
else:
print(colorama.Fore.RED + "Операция отменена" + colorama.Style.RESET_ALL)
else:
print("Ни один патч не был успешно применен")
print(f"{colorama.Fore.RED}Ни один патч не был успешно применен{colorama.Style.RESET_ALL}")
sys.exit(1)