Build system (pretty much) complete! (Minus Java)
This commit is contained in:
parent
537f359f11
commit
586fc6a34f
8 changed files with 77 additions and 16 deletions
8
TODO.txt
8
TODO.txt
|
@ -1,6 +1,2 @@
|
|||
1. Add android.jar from android sdk 35 to classpath
|
||||
2. Identify tumblr apk version
|
||||
3. Fix enhanced block n shit
|
||||
4. ???
|
||||
5. Profit
|
||||
6. Fix that bug that prevents you from opening your account settings
|
||||
Implement smali patches + migrate all smali code to patches
|
||||
Implement Java stack
|
|
@ -1,7 +1,5 @@
|
|||
# from task.extract import extract
|
||||
from task.patch_smali import patch_smali
|
||||
from task.patch_resources import patch_resources
|
||||
from task.merge_resources import merge_resources
|
||||
from task.sign_apk import sign_apk
|
||||
|
||||
if __name__ == '__main__':
|
||||
_ = merge_resources()
|
||||
_ = sign_apk()
|
17
buildtool/task/assemble_apk.py
Normal file
17
buildtool/task/assemble_apk.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
from .util import *
|
||||
from .merge_resources import merge_resources
|
||||
|
||||
import subprocess
|
||||
|
||||
def assemble_apk():
|
||||
updated = merge_resources()
|
||||
|
||||
if not updated and Path(ASSEMBLED_APK).exists():
|
||||
print("Skipping assembly")
|
||||
return False
|
||||
|
||||
# Assemble
|
||||
print("Assembling APK...")
|
||||
_ = subprocess.run([JAVA_BIN, '-jar', APKTOOL, 'b', MERGED_RSC_DIR, '-o', ASSEMBLED_APK])
|
||||
|
||||
return True
|
|
@ -6,7 +6,7 @@ import re
|
|||
# Task dependencies
|
||||
from .patch_smali import patch_smali
|
||||
|
||||
def to_dex_name(smali_name):
|
||||
def to_dex_name(smali_name: str):
|
||||
if smali_name == 'smali':
|
||||
return 'classes.dex'
|
||||
else:
|
||||
|
|
|
@ -21,7 +21,11 @@ def merge_resources():
|
|||
shutil.copytree(EXTRACTED_DIR, MERGED_RSC_DIR, ignore=shutil.ignore_patterns("smali", "smali_classes*"))
|
||||
first_time = True
|
||||
|
||||
updated = first_time
|
||||
|
||||
print("Merging patched resources...")
|
||||
_ = fileutil.merge_into(PATCHED_RSC_DIR, MERGED_RSC_DIR, check_date=not first_time)
|
||||
updated = updated or fileutil.merge_into(PATCHED_RSC_DIR, MERGED_RSC_DIR, check_date=not first_time)
|
||||
print("Merging dex files...")
|
||||
_ = fileutil.merge_into(COMPILED_SMALI_DIR, MERGED_RSC_DIR, check_date=not first_time)
|
||||
updated = updated or fileutil.merge_into(COMPILED_SMALI_DIR, MERGED_RSC_DIR, check_date=not first_time)
|
||||
|
||||
return updated
|
45
buildtool/task/sign_apk.py
Normal file
45
buildtool/task/sign_apk.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
import shutil
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
from .util import *
|
||||
from .assemble_apk import assemble_apk
|
||||
|
||||
def align_apk():
|
||||
updated = assemble_apk()
|
||||
|
||||
if not updated and Path(ALIGNED_APK).exists():
|
||||
print("Skipping alignment")
|
||||
return False
|
||||
|
||||
# Align the APK
|
||||
print("Aligning APK...")
|
||||
ALIGNED_APK.parent.mkdir(exist_ok=True)
|
||||
_ = subprocess.run([ZIPALIGN, '-pvf', '4', ASSEMBLED_APK, ALIGNED_APK])
|
||||
|
||||
def sign_apk():
|
||||
updated = align_apk()
|
||||
|
||||
# Check what kind of signing the user wants us to do
|
||||
arg = sys.argv[1] if len(sys.argv) > 1 else ''
|
||||
if 'd' in arg:
|
||||
keystore_params = ['--ks', 'keystores/debug.keystore', '--ks-pass', 'pass:123456']
|
||||
signed_apk = SIGNED_APK_DEBUG
|
||||
elif 'r' in arg:
|
||||
keystore_params = ['--ks', 'keystores/debug.keystore',]
|
||||
signed_apk = SIGNED_APK
|
||||
else:
|
||||
print("WARNING: Neither 'r' (release) nor 'd' (debug) was specified for the second parameter so the aligned apk will not be signed.")
|
||||
print("STOP.")
|
||||
exit(0)
|
||||
|
||||
if not updated and Path(signed_apk).exists():
|
||||
print("Skipping signing")
|
||||
return False
|
||||
|
||||
|
||||
# Sign the APK
|
||||
print("Signing APK...")
|
||||
shutil.copy(ALIGNED_APK, signed_apk)
|
||||
SIGNED_APK.parent.mkdir(exist_ok=True)
|
||||
_ = subprocess.run([JAVA_BIN, '-jar', APKSIGNER, 'sign', *keystore_params, signed_apk])
|
|
@ -18,6 +18,10 @@ PATCHED_RSC_DIR = BUILD_DIR / "patched_resources"
|
|||
PATCHED_SMALI_DIR = BUILD_DIR / "patched_smali"
|
||||
MERGED_RSC_DIR = BUILD_DIR / "merged_resources"
|
||||
COMPILED_SMALI_DIR = BUILD_DIR / "compiled_smali"
|
||||
ASSEMBLED_APK = BUILD_DIR / "assembled_apk" / "tumblr-ykit.apk"
|
||||
ALIGNED_APK = BUILD_DIR / "signed_apk" / "tumblr-ykit_aligned.apk"
|
||||
SIGNED_APK = BUILD_DIR / "signed_apk" / "tumblr-ykit.apk"
|
||||
SIGNED_APK_DEBUG = BUILD_DIR / "signed_apk" / "tumblr-ykit_debug.apk"
|
||||
|
||||
SRC_DIR = Path("src")
|
||||
SRC_RESOURCES_DIR = SRC_DIR / "resources"
|
||||
|
|
3
test.py
3
test.py
|
@ -1,3 +0,0 @@
|
|||
from buildtool.polly.patcher import process_patch_file
|
||||
|
||||
process_patch_file('src/patches/public.patch', check_date=True)
|
Loading…
Add table
Reference in a new issue