mirror of
https://github.com/Radiquum/anixart-patcher.git
synced 2025-09-05 10:45:32 +05:00
feat: add compile and sign of apk
This commit is contained in:
parent
b6c058c40f
commit
4ec18d7dd4
3 changed files with 70 additions and 4 deletions
|
@ -41,3 +41,51 @@ def decompile_apk(apk: str):
|
|||
except subprocess.CalledProcessError as e:
|
||||
log.fatal(f"error of running a command: %s", e.stderr, exc_info=True)
|
||||
exit(1)
|
||||
|
||||
|
||||
def compile_apk(apk: str):
|
||||
if not os.path.exists(config["folders"]["dist"]):
|
||||
log.info(f"creating `dist` folder: {config['folders']['dist']}")
|
||||
os.mkdir(config["folders"]["dist"])
|
||||
else:
|
||||
log.info(f"resetting `dist` folder: {config['folders']['dist']}")
|
||||
shutil.rmtree(config["folders"]["dist"])
|
||||
os.mkdir(config["folders"]["dist"])
|
||||
|
||||
log.info(f"compile apk: `{apk}`")
|
||||
try:
|
||||
result = subprocess.run(
|
||||
f"java -jar {config['folders']['tools']}/apktool.jar b -f -o {config['folders']['dist']}/{apk} {config['folders']['decompiled']}",
|
||||
shell=True,
|
||||
check=True,
|
||||
text=True,
|
||||
# stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.PIPE,
|
||||
)
|
||||
except subprocess.CalledProcessError as e:
|
||||
log.fatal(f"error of running a command: %s", e.stderr, exc_info=True)
|
||||
exit(1)
|
||||
|
||||
|
||||
def sign_apk(apk: str):
|
||||
log.info(f"sign and align apk: `{apk}`")
|
||||
try:
|
||||
result = subprocess.run(
|
||||
f"zipalign -p 4 {config['folders']['dist']}/{apk} {config['folders']['dist']}/{apk.removesuffix(".apk")}-aligned.apk",
|
||||
shell=True,
|
||||
check=True,
|
||||
text=True,
|
||||
# stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.PIPE,
|
||||
)
|
||||
result = subprocess.run(
|
||||
f"apksigner sign --ks ./keystore.jks --out {config['folders']['dist']}/{apk.removesuffix(".apk")}-aligned-signed.apk {config['folders']['dist']}/{apk.removesuffix(".apk")}-aligned.apk",
|
||||
shell=True,
|
||||
check=True,
|
||||
text=True,
|
||||
# stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.PIPE,
|
||||
)
|
||||
except subprocess.CalledProcessError as e:
|
||||
log.fatal(f"error of running a command: %s", e.stderr, exc_info=True)
|
||||
exit(1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue