Skip to content

Commit 1d4a077

Browse files
committed
V2.2.0
* 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>
1 parent ad6d667 commit 1d4a077

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "xiaomi_flashable_firmware_creator"
3-
version = "2.1.2"
3+
version = "2.2.0"
44
description = "Create flashable firmware zip from MIUI Recovery ROMs!"
55
authors = ["yshalsager <ysh-alsager@hotmail.com>"]
66
license = "GPL-3.0-only"

xiaomi_flashable_firmware_creator/firmware_creator.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"""
1010

1111
# pylint: disable=too-many-instance-attributes
12+
import re
1213
from datetime import datetime
1314
from pathlib import Path
1415
from shutil import rmtree, make_archive, copy2
@@ -58,8 +59,9 @@ def __init__(self, input_file, _extract_mode, out_dir=""):
5859
self.extract_mode = self.get_extract_mode(_extract_mode)
5960
self.update_script = ''
6061
self.is_android_one = False
61-
self.firmware_excluded_files = ['dtbo', 'logo', 'splash', 'vbmeta', 'boot', 'system',
62-
'vendor', 'product', 'odm']
62+
self.firmware_excluded_files = ['dtbo', 'logo', 'splash', 'vbmeta', 'boot.img', 'system',
63+
'vendor', 'product', 'odm', 'exaid',
64+
'dynamic_partitions_op_list']
6365
self.extractor = ZipExtractor(self.input_file, self._tmp_dir)
6466
self.init()
6567

@@ -149,9 +151,8 @@ def get_files_list(self) -> List[str]:
149151
and (i.endswith('updater-script') or i.endswith('update-binary'))
150152
) or all(n not in i for n in self.firmware_excluded_files)] \
151153
if self.type is ZipTypes.qcom \
152-
else [n for n in self.extractor.files if 'system' not in n and 'vendor' not in n
153-
and 'product' not in n and 'boot.img' not in n
154-
and 'file_contexts' not in n]
154+
else [n for n in self.extractor.files if all(
155+
file not in n for file in self.firmware_excluded_files + ['file_contexts'])]
155156
if self.extract_mode is ProcessTypes.non_arb_firmware:
156157
return [n for n in self.extractor.files if 'dspso.bin' in n
157158
or n.startswith('firmware-update/BTFM.bin')
@@ -180,13 +181,11 @@ def get_updater_script_lines(self) -> str:
180181
if self.extract_mode is ProcessTypes.firmware:
181182
lines = [line for line in original_updater_script if "getprop" in line
182183
or "Target" in line
183-
or "firmware-update" in line and "dtbo.img" not in line
184-
and "vbmeta" not in line and "splash" not in line
185-
and "logo" not in line] \
184+
or "firmware-update" in line and ("ro.product" in line or all(
185+
file not in line for file in self.firmware_excluded_files))] \
186186
if self.type is ZipTypes.qcom \
187-
else [line for line in original_updater_script if "system" not in line
188-
and "vendor" not in line and 'boot.img' not in line
189-
and "dtbo.img" not in line and "vbmeta" not in line]
187+
else [line for line in original_updater_script if "ro.product" in line or
188+
all(file not in line for file in self.firmware_excluded_files)]
190189
elif self.extract_mode is ProcessTypes.non_arb_firmware:
191190
lines = [line for line in original_updater_script if "getprop" in line
192191
or "Target" in line
@@ -240,6 +239,13 @@ def generate_updater_script(self):
240239
self.update_script = updater_script
241240
with open(f"{str(self._flashing_script_dir)}/updater-script", "w") as out:
242241
out.write(updater_script)
242+
# Use modified dynamic_partitions_op_list with resize vendor line only
243+
if self.extract_mode is ProcessTypes.vendor and "dynamic_partitions_op_list" in updater_script:
244+
original_dynamic_partitions_list = Path(self._tmp_dir / 'dynamic_partitions_op_list').read_text()
245+
vendor_resize = re.search(r'(resize vendor .*$)', original_dynamic_partitions_list, re.M)
246+
if vendor_resize:
247+
with open(f"{str(self._tmp_dir)}/dynamic_partitions_op_list", "w") as out:
248+
out.write(vendor_resize.group(1))
243249

244250
# def generate_update_binary(self):
245251
# """

0 commit comments

Comments
 (0)