More work on the patching system
This commit is contained in:
parent
8a7b95beee
commit
7229e518d3
|
@ -1,5 +1,7 @@
|
||||||
# from task.extract import extract
|
# from task.extract import extract
|
||||||
|
from task.patch_smali import patch_smali
|
||||||
from task.patch_resources import patch_resources
|
from task.patch_resources import patch_resources
|
||||||
|
from task.merge_resources import merge_resources
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
_ = patch_resources()
|
_ = merge_resources()
|
|
@ -56,7 +56,10 @@ def process_patch_file(patch_file: str, check_date: bool = True):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
i2["pos"] += len(insertion["content"])
|
i2["pos"] += len(insertion["content"])
|
||||||
|
|
||||||
|
# Make parent dirs
|
||||||
|
target_dest.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
# Write the changed output
|
# Write the changed output
|
||||||
with open(target_dest, 'w') as f:
|
with open(target_dest, 'w') as f:
|
||||||
f.write(src)
|
f.write(src)
|
||||||
|
@ -64,8 +67,6 @@ def process_patch_file(patch_file: str, check_date: bool = True):
|
||||||
def process_all_patches(dir: Path | str, check_date: bool = True):
|
def process_all_patches(dir: Path | str, check_date: bool = True):
|
||||||
dir = Path(dir)
|
dir = Path(dir)
|
||||||
|
|
||||||
for (cd, _, files) in dir.walk():
|
for patch_file in dir.rglob("*.patch"):
|
||||||
for f in files:
|
print("Processing patch {}".format(patch_file.relative_to(dir)))
|
||||||
if f.endswith(".patch"):
|
process_patch_file(str(patch_file), check_date=check_date)
|
||||||
print("Processing patch {}".format((cd / f).relative_to(dir)))
|
|
||||||
process_patch_file(str(cd / f), check_date=check_date)
|
|
27
buildtool/task/merge_resources.py
Normal file
27
buildtool/task/merge_resources.py
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
from .util import *
|
||||||
|
from . import fileutil
|
||||||
|
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
# Task dependencies
|
||||||
|
from .patch_resources import patch_resources
|
||||||
|
from .patch_smali import patch_smali
|
||||||
|
|
||||||
|
# Merges resources from all the previous steps
|
||||||
|
|
||||||
|
def merge_resources():
|
||||||
|
_ = patch_resources()
|
||||||
|
_ = patch_smali()
|
||||||
|
|
||||||
|
first_time = False
|
||||||
|
|
||||||
|
# Copy original resources only the first time
|
||||||
|
if not MERGED_RSC_DIR.exists():
|
||||||
|
print("Merging original resources...")
|
||||||
|
shutil.copytree(EXTRACTED_DIR, MERGED_RSC_DIR, ignore=shutil.ignore_patterns("smali*"))
|
||||||
|
first_time = True
|
||||||
|
|
||||||
|
print("Merging patched resources...")
|
||||||
|
_ = fileutil.merge_into(PATCHED_RSC_DIR, MERGED_RSC_DIR, check_date=not first_time)
|
||||||
|
print("Merging patched smali...")
|
||||||
|
_ = fileutil.merge_into(PATCHED_SMALI_DIR, MERGED_RSC_DIR, check_date=not first_time)
|
|
@ -1,8 +1,6 @@
|
||||||
from .util import *
|
from .util import *
|
||||||
from . import fileutil
|
from . import fileutil
|
||||||
|
|
||||||
import shutil
|
|
||||||
|
|
||||||
from polly.patcher import process_all_patches
|
from polly.patcher import process_all_patches
|
||||||
|
|
||||||
# Task dependencies
|
# Task dependencies
|
||||||
|
@ -11,19 +9,13 @@ from .extract import extract
|
||||||
def patch_resources():
|
def patch_resources():
|
||||||
_ = extract()
|
_ = extract()
|
||||||
|
|
||||||
first_time = False
|
# Previously, we populated patched_resources with original resources too, now that is covered in the merge_resources step
|
||||||
|
|
||||||
# Copy original resources only the first time
|
s = fileutil.merge_into(SRC_RESOURCES_DIR, PATCHED_RSC_DIR)
|
||||||
if not PATCHED_RSC_DIR.exists():
|
|
||||||
print("Copying original resources...")
|
|
||||||
shutil.copytree(EXTRACTED_DIR, PATCHED_RSC_DIR, ignore=shutil.ignore_patterns("smali*"))
|
|
||||||
first_time = True
|
|
||||||
|
|
||||||
s = fileutil.merge_into(SRC_RESOURCES_DIR, PATCHED_RSC_DIR, check_date=not first_time)
|
|
||||||
if s:
|
if s:
|
||||||
print("Copied custom resources from src/resources")
|
print("Copied custom resources from src/resources")
|
||||||
else:
|
else:
|
||||||
print("Skipped copying resources from src/resources")
|
print("Skipped copying resources from src/resources")
|
||||||
|
|
||||||
# Patch other resources
|
# Patch other resources
|
||||||
process_all_patches(SRC_PATCHES_DIR, check_date=not first_time)
|
process_all_patches(SRC_RESOURCE_PATCHES_DIR)
|
30
buildtool/task/patch_smali.py
Normal file
30
buildtool/task/patch_smali.py
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
from .util import *
|
||||||
|
from . import fileutil
|
||||||
|
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
from polly.patcher import process_all_patches
|
||||||
|
|
||||||
|
# Task dependencies
|
||||||
|
from .extract import extract
|
||||||
|
|
||||||
|
def patch_smali():
|
||||||
|
_ = extract()
|
||||||
|
|
||||||
|
first_time = False
|
||||||
|
|
||||||
|
# Copy original resources only the first time
|
||||||
|
if not PATCHED_SMALI_DIR.exists():
|
||||||
|
print("Copying original smali...")
|
||||||
|
for smali_dir in EXTRACTED_DIR.glob("smali*"):
|
||||||
|
shutil.copytree(smali_dir, PATCHED_SMALI_DIR / smali_dir.relative_to(EXTRACTED_DIR))
|
||||||
|
first_time = True
|
||||||
|
|
||||||
|
s = fileutil.merge_into(SRC_SMALI_DIR, PATCHED_SMALI_DIR, check_date=not first_time)
|
||||||
|
if s:
|
||||||
|
print("Copied custom code from src/smali")
|
||||||
|
else:
|
||||||
|
print("Skipped copying code from src/smali")
|
||||||
|
|
||||||
|
# Patch other resources
|
||||||
|
process_all_patches(SRC_SMALI_PATCHES_DIR, check_date=not first_time)
|
|
@ -5,7 +5,11 @@ SOURCE_APK_DIR = Path("source-apk")
|
||||||
BUILD_DIR = Path("build")
|
BUILD_DIR = Path("build")
|
||||||
EXTRACTED_DIR = BUILD_DIR / "extracted"
|
EXTRACTED_DIR = BUILD_DIR / "extracted"
|
||||||
PATCHED_RSC_DIR = BUILD_DIR / "patched_resources"
|
PATCHED_RSC_DIR = BUILD_DIR / "patched_resources"
|
||||||
|
PATCHED_SMALI_DIR = BUILD_DIR / "patched_smali"
|
||||||
|
MERGED_RSC_DIR = BUILD_DIR / "merged_resources"
|
||||||
|
|
||||||
SRC_DIR = Path("src")
|
SRC_DIR = Path("src")
|
||||||
SRC_RESOURCES_DIR = SRC_DIR / "resources"
|
SRC_RESOURCES_DIR = SRC_DIR / "resources"
|
||||||
SRC_PATCHES_DIR = SRC_DIR / "patches"
|
SRC_SMALI_DIR = SRC_DIR / "smali"
|
||||||
|
SRC_RESOURCE_PATCHES_DIR = SRC_DIR / "patches" / "resource"
|
||||||
|
SRC_SMALI_PATCHES_DIR = SRC_DIR / "patches" / "smali"
|
|
@ -1,5 +1,7 @@
|
||||||
file 'res/values/public.xml'
|
file 'res/values/public.xml'
|
||||||
|
|
||||||
|
# IDs and resources used by various ykit elements
|
||||||
|
|
||||||
insert ln17595 << @end
|
insert ln17595 << @end
|
||||||
|
|
||||||
<!-- Ykit -->
|
<!-- Ykit -->
|
|
@ -1,5 +1,7 @@
|
||||||
file 'res/layout/color_options_toolbar.xml'
|
file 'res/layout/color_options_toolbar.xml'
|
||||||
|
|
||||||
|
# Adds yellow into the list of colors in the toolbar
|
||||||
|
|
||||||
insert ln8 << @end
|
insert ln8 << @end
|
||||||
<androidx.appcompat.widget.AppCompatImageButton android:id="@id/text_color_yellow" android:background="?selectableItemBackgroundBorderless" android:layout_width="48.0dip" android:layout_height="48.0dip" android:layout_marginLeft="2.0dip" android:layout_marginRight="2.0dip" android:layout_weight="0.5" app:srcCompat="@drawable/oval_yellow" />
|
<androidx.appcompat.widget.AppCompatImageButton android:id="@id/text_color_yellow" android:background="?selectableItemBackgroundBorderless" android:layout_width="48.0dip" android:layout_height="48.0dip" android:layout_marginLeft="2.0dip" android:layout_marginRight="2.0dip" android:layout_weight="0.5" app:srcCompat="@drawable/oval_yellow" />
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
file 'res/layout/fragment_blog_settings.xml'
|
file 'res/layout/fragment_blog_settings.xml'
|
||||||
|
|
||||||
|
# Adds the YKit Settings entry to the account settings menu
|
||||||
|
|
||||||
insert ln10 << @end
|
insert ln10 << @end
|
||||||
<com.tumblr.ui.widget.TMBlogSettingsTextRow android:id="@id/ykit_settings" tumblr:listItemDetail="Change settings for YKit" tumblr:listItemTitle="YKit Settings" style="@style/DetailedListItem" />
|
<com.tumblr.ui.widget.TMBlogSettingsTextRow android:id="@id/ykit_settings" tumblr:listItemDetail="Change settings for YKit" tumblr:listItemTitle="YKit Settings" style="@style/DetailedListItem" />
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
.method static constructor <clinit>()V
|
.method static constructor <clinit>()V
|
||||||
.locals 0
|
.locals 0
|
||||||
|
|
||||||
invoke-static {}, Ldev/maelstrom/ykit/java/Test;->test()V
|
# invoke-static {}, Ldev/maelstrom/ykit/java/Test;->test()V
|
||||||
|
|
||||||
return-void
|
return-void
|
||||||
.end method
|
.end method
|
||||||
|
|
BIN
tools/apksigner.jar
Normal file
BIN
tools/apksigner.jar
Normal file
Binary file not shown.
Loading…
Reference in a new issue