Skip to content

Commit 3003f93

Browse files
committed
fix: carry PR #42 recovery.img extraction into the rewrite
- add recovery.img to boot image processing in the Python extractor - unpack recovery ramdisks in the rewrite-native path - extract recovery device trees for parity with other boot image handlers
1 parent c4a5aed commit 3003f93

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

dumpyarabot/firmware_extractor.py

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,16 @@ async def _extract_fsg_partition(self):
165165
safe_remove_file(fsg_file)
166166
console.print("[green]Successfully extracted fsg.mbn[/green]")
167167

168-
async def process_boot_images(self) -> None:
169-
"""Process boot images (boot.img, vendor_boot.img, etc.)."""
170-
boot_images = ["init_boot.img", "vendor_kernel_boot.img", "vendor_boot.img", "boot.img", "dtbo.img"]
168+
async def process_boot_images(self) -> None:
169+
"""Process boot images (boot.img, vendor_boot.img, etc.)."""
170+
boot_images = [
171+
"init_boot.img",
172+
"vendor_kernel_boot.img",
173+
"vendor_boot.img",
174+
"boot.img",
175+
"recovery.img",
176+
"dtbo.img",
177+
]
171178

172179
# Move boot images to work directory root if they're in subdirectories
173180
for image_name in boot_images:
@@ -191,12 +198,14 @@ async def _process_single_boot_image(self, image_path: Path):
191198

192199
console.print(f"[blue]Processing {image_name}...[/blue]")
193200

194-
if image_name == "boot.img":
195-
await self._process_boot_img(image_path, output_dir)
196-
elif image_name in ["vendor_boot.img", "vendor_kernel_boot.img", "init_boot.img"]:
197-
await self._process_vendor_boot_img(image_path, output_dir)
198-
elif image_name == "dtbo.img":
199-
await self._process_dtbo_img(image_path, output_dir)
201+
if image_name == "boot.img":
202+
await self._process_boot_img(image_path, output_dir)
203+
elif image_name == "recovery.img":
204+
await self._process_recovery_img(image_path, output_dir)
205+
elif image_name in ["vendor_boot.img", "vendor_kernel_boot.img", "init_boot.img"]:
206+
await self._process_vendor_boot_img(image_path, output_dir)
207+
elif image_name == "dtbo.img":
208+
await self._process_dtbo_img(image_path, output_dir)
200209

201210
async def _process_boot_img(self, image_path: Path, output_dir: Path):
202211
"""Process boot.img with comprehensive analysis."""
@@ -218,16 +227,25 @@ async def _process_boot_img(self, image_path: Path, output_dir: Path):
218227
# Extract and process device tree blobs
219228
await self._extract_device_trees(image_path, output_dir)
220229

221-
async def _process_vendor_boot_img(self, image_path: Path, output_dir: Path):
222-
"""Process vendor_boot.img or similar images."""
223-
output_dir.mkdir(exist_ok=True)
230+
async def _process_vendor_boot_img(self, image_path: Path, output_dir: Path):
231+
"""Process vendor_boot.img or similar images."""
232+
output_dir.mkdir(exist_ok=True)
224233

225234
# Extract contents if using alternative dumper
226235
if self.firmware_extractor_path.exists():
227236
await self._unpack_boot_image(image_path, output_dir)
228237

229-
# Extract device tree blobs
230-
await self._extract_device_trees(image_path, output_dir)
238+
# Extract device tree blobs
239+
await self._extract_device_trees(image_path, output_dir)
240+
241+
async def _process_recovery_img(self, image_path: Path, output_dir: Path):
242+
"""Process recovery.img by unpacking the image and extracting its ramdisk."""
243+
output_dir.mkdir(exist_ok=True)
244+
245+
if self.firmware_extractor_path.exists():
246+
await self._unpack_boot_image(image_path, output_dir)
247+
248+
await self._extract_device_trees(image_path, output_dir)
231249

232250
async def _process_dtbo_img(self, image_path: Path, output_dir: Path):
233251
"""Process dtbo.img."""
@@ -447,4 +465,3 @@ async def _process_oppo_images(self):
447465
console.print(f"[green]Extracted {img_file.name}[/green]")
448466
else:
449467
console.print(f"[yellow]Failed to extract {img_file.name}[/yellow]")
450-

0 commit comments

Comments
 (0)