From 75267a8c7626857d73eecea8a0925dfff76576be Mon Sep 17 00:00:00 2001 From: doronz88 Date: Thu, 15 Aug 2024 10:28:00 +0300 Subject: [PATCH] ipsw: add `create_device_support()` method --- ipsw_parser/__main__.py | 20 +------------------- ipsw_parser/ipsw.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/ipsw_parser/__main__.py b/ipsw_parser/__main__.py index db4877f..297e23a 100644 --- a/ipsw_parser/__main__.py +++ b/ipsw_parser/__main__.py @@ -1,7 +1,5 @@ #!/usr/bin/env python3 import logging -import plistlib -from datetime import datetime from pathlib import Path from typing import IO from zipfile import ZipFile @@ -66,23 +64,7 @@ def extract(file: IO, output: str) -> None: @click.argument('file', type=click.Path(exists=True, file_okay=True, dir_okay=False)) def device_support(file: IO) -> None: """ Create DeviceSupport directory """ - device_support_path = Path('~/Library/Developer/Xcode/iOS DeviceSupport').expanduser() - ipsw = IPSW(ZipFile(file)) - device_support_path /= (f'{ipsw.build_manifest.supported_product_types[0]} ' - f'{ipsw.build_manifest.product_version} ({ipsw.build_manifest.product_build_version})') - build_identity = ipsw.build_manifest.build_identities[0] - symbols_path = device_support_path / 'Symbols' - build_identity.extract_dsc(symbols_path) - for file in (symbols_path / 'private/preboot/Cryptexes/OS/System/Library/Caches/com.apple.dyld').iterdir(): - file.unlink() - (device_support_path / 'Info.plist').write_bytes(plistlib.dumps({ - 'DSC Extractor Version': '1228.0.0.0.0', - 'DateCollected': datetime.now(), - 'Version': '16.0', - })) - (device_support_path / '.finalized').write_bytes(plistlib.dumps({})) - (device_support_path / '.processed_dyld_shared_cache_arm64e').touch() - (device_support_path / '.processing_lock').touch() + IPSW(ZipFile(file)).create_device_support() if __name__ == '__main__': diff --git a/ipsw_parser/ipsw.py b/ipsw_parser/ipsw.py index 55c2a6e..70335bb 100644 --- a/ipsw_parser/ipsw.py +++ b/ipsw_parser/ipsw.py @@ -1,6 +1,9 @@ import logging +import plistlib import zipfile from contextlib import contextmanager +from datetime import datetime +from pathlib import Path from typing import List from cached_property import cached_property @@ -109,3 +112,21 @@ def get_development_files(self) -> List[str]: if release in entry.lower(): result.append(entry) return result + + def create_device_support(self) -> None: + device_support_path = Path('~/Library/Developer/Xcode/iOS DeviceSupport').expanduser() + device_support_path /= (f'{self.build_manifest.supported_product_types[0]} ' + f'{self.build_manifest.product_version} ({self.build_manifest.product_build_version})') + build_identity = self.build_manifest.build_identities[0] + symbols_path = device_support_path / 'Symbols' + build_identity.extract_dsc(symbols_path) + for file in (symbols_path / 'private/preboot/Cryptexes/OS/System/Library/Caches/com.apple.dyld').iterdir(): + file.unlink() + (device_support_path / 'Info.plist').write_bytes(plistlib.dumps({ + 'DSC Extractor Version': '1228.0.0.0.0', + 'DateCollected': datetime.now(), + 'Version': '16.0', + })) + (device_support_path / '.finalized').write_bytes(plistlib.dumps({})) + (device_support_path / '.processed_dyld_shared_cache_arm64e').touch() + (device_support_path / '.processing_lock').touch()