Skip to content

Commit

Permalink
V2.2.0
Browse files Browse the repository at this point in the history
* FW: Exclude dynamic_partitions_op_list from and exaid firmware zip and updater-script
* Vendor: Use modified dynamic_partitions_op_list with resize vendor line only

Signed-off-by: yshalsager <ysh-alsager@hotmail.com>
  • Loading branch information
yshalsager committed Apr 17, 2021
1 parent ad6d667 commit 1d4a077
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "xiaomi_flashable_firmware_creator"
version = "2.1.2"
version = "2.2.0"
description = "Create flashable firmware zip from MIUI Recovery ROMs!"
authors = ["yshalsager <ysh-alsager@hotmail.com>"]
license = "GPL-3.0-only"
Expand Down
28 changes: 17 additions & 11 deletions xiaomi_flashable_firmware_creator/firmware_creator.py
Expand Up @@ -9,6 +9,7 @@
"""

# pylint: disable=too-many-instance-attributes
import re
from datetime import datetime
from pathlib import Path
from shutil import rmtree, make_archive, copy2
Expand Down Expand Up @@ -58,8 +59,9 @@ def __init__(self, input_file, _extract_mode, out_dir=""):
self.extract_mode = self.get_extract_mode(_extract_mode)
self.update_script = ''
self.is_android_one = False
self.firmware_excluded_files = ['dtbo', 'logo', 'splash', 'vbmeta', 'boot', 'system',
'vendor', 'product', 'odm']
self.firmware_excluded_files = ['dtbo', 'logo', 'splash', 'vbmeta', 'boot.img', 'system',
'vendor', 'product', 'odm', 'exaid',
'dynamic_partitions_op_list']
self.extractor = ZipExtractor(self.input_file, self._tmp_dir)
self.init()

Expand Down Expand Up @@ -149,9 +151,8 @@ def get_files_list(self) -> List[str]:
and (i.endswith('updater-script') or i.endswith('update-binary'))
) or all(n not in i for n in self.firmware_excluded_files)] \
if self.type is ZipTypes.qcom \
else [n for n in self.extractor.files if 'system' not in n and 'vendor' not in n
and 'product' not in n and 'boot.img' not in n
and 'file_contexts' not in n]
else [n for n in self.extractor.files if all(
file not in n for file in self.firmware_excluded_files + ['file_contexts'])]
if self.extract_mode is ProcessTypes.non_arb_firmware:
return [n for n in self.extractor.files if 'dspso.bin' in n
or n.startswith('firmware-update/BTFM.bin')
Expand Down Expand Up @@ -180,13 +181,11 @@ def get_updater_script_lines(self) -> str:
if self.extract_mode is ProcessTypes.firmware:
lines = [line for line in original_updater_script if "getprop" in line
or "Target" in line
or "firmware-update" in line and "dtbo.img" not in line
and "vbmeta" not in line and "splash" not in line
and "logo" not in line] \
or "firmware-update" in line and ("ro.product" in line or all(
file not in line for file in self.firmware_excluded_files))] \
if self.type is ZipTypes.qcom \
else [line for line in original_updater_script if "system" not in line
and "vendor" not in line and 'boot.img' not in line
and "dtbo.img" not in line and "vbmeta" not in line]
else [line for line in original_updater_script if "ro.product" in line or
all(file not in line for file in self.firmware_excluded_files)]
elif self.extract_mode is ProcessTypes.non_arb_firmware:
lines = [line for line in original_updater_script if "getprop" in line
or "Target" in line
Expand Down Expand Up @@ -240,6 +239,13 @@ def generate_updater_script(self):
self.update_script = updater_script
with open(f"{str(self._flashing_script_dir)}/updater-script", "w") as out:
out.write(updater_script)
# Use modified dynamic_partitions_op_list with resize vendor line only
if self.extract_mode is ProcessTypes.vendor and "dynamic_partitions_op_list" in updater_script:
original_dynamic_partitions_list = Path(self._tmp_dir / 'dynamic_partitions_op_list').read_text()
vendor_resize = re.search(r'(resize vendor .*$)', original_dynamic_partitions_list, re.M)
if vendor_resize:
with open(f"{str(self._tmp_dir)}/dynamic_partitions_op_list", "w") as out:
out.write(vendor_resize.group(1))

# def generate_update_binary(self):
# """
Expand Down

0 comments on commit 1d4a077

Please sign in to comment.