fix patchport

This commit is contained in:
leo60228 2021-09-20 11:23:55 -04:00
parent 59c76a6506
commit a8124a4796

View file

@ -16,7 +16,7 @@ with open("/opt/ctc/gitrepo/resources/patchport-state.json", "r") as f:
from_versionname = jin["versionname"] from_versionname = jin["versionname"]
apk_folder = sys.argv[1] apk_folder = sys.argv[1]
cutthecord_folder = os.path.dirname(os.path.realpath(__file__)) cutthecord_folder = os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
debug = False debug = False
tmp_folder = "/tmp/patchport" tmp_folder = "/tmp/patchport"
@ -32,11 +32,6 @@ def modify_patch(patch_name, patch_path):
patch_content = patch_content.replace(from_versioncode, to_versioncode) patch_content = patch_content.replace(from_versioncode, to_versioncode)
patch_content = patch_content.replace(from_versionname, to_versionname) patch_content = patch_content.replace(from_versionname, to_versionname)
if patch_name == "notrack":
# TODO: There's a risk here that we'll replace the nulled value
from_crashlytics_id = re_crashlytics.findall(patch_content)[0]
patch_content = patch_content.replace(from_crashlytics_id,
to_crashlytics_id)
return patch_content return patch_content
@ -113,9 +108,6 @@ re_versioncode_yml = re.compile(r'versionCode: \'([0-9]+)\'')
re_versionname_yml = re.compile(r'versionName: \'?(.+?)\'?$') re_versionname_yml = re.compile(r'versionName: \'?(.+?)\'?$')
re_releasedate = re.compile(r'released on ([0-9]{4}-[0-9]{2}-[0-9]{2})') re_releasedate = re.compile(r'released on ([0-9]{4}-[0-9]{2}-[0-9]{2})')
re_crashlytics = re.compile(r'com\.crashlytics\.android\.build_id">([a-z0-9]'
r'{8}-?[a-z0-9]{4}-?[a-z0-9]{4}-?[a-z0-9]{4}-?'
r'[a-z0-9]{12})</string>')
# Get version code and name # Get version code and name
@ -124,12 +116,6 @@ with open(os.path.join(apk_folder, "apktool.yml")) as f:
to_versioncode = re_versioncode_yml.findall(file_contents)[0] to_versioncode = re_versioncode_yml.findall(file_contents)[0]
to_versionname = re_versionname_yml.findall(file_contents)[0] to_versionname = re_versionname_yml.findall(file_contents)[0]
# Get crashlytics build ID
with open(os.path.join(apk_folder, "res", "values", "strings.xml")) as f:
file_contents = f.read()
to_crashlytics_id = re_crashlytics.findall(file_contents)[0]
failures = [] failures = []
for patch in os.listdir(os.path.join(cutthecord_folder, "resources/xmlpatches")): for patch in os.listdir(os.path.join(cutthecord_folder, "resources/xmlpatches")):
@ -152,6 +138,8 @@ for patch in os.listdir(os.path.join(cutthecord_folder, "resources/xmlpatches"))
tmp_out_path = os.path.join("/tmp/", patch, f"{to_versioncode}.xml") tmp_out_path = os.path.join("/tmp/", patch, f"{to_versioncode}.xml")
readme_path = os.path.join(cutthecord_folder, "resources/xmlpatches", patch, "README.md") readme_path = os.path.join(cutthecord_folder, "resources/xmlpatches", patch, "README.md")
os.mkdir(os.path.dirname(tmp_out_path))
# Handle copying of versioned scripts, untested and dirty! # Handle copying of versioned scripts, untested and dirty!
script_path = os.path.join(cutthecord_folder, "resources/xmlpatches", patch, f"{from_versioncode}.sh") script_path = os.path.join(cutthecord_folder, "resources/xmlpatches", patch, f"{from_versioncode}.sh")
if os.path.exists(script_path): if os.path.exists(script_path):