Skip to content

Commit

Permalink
Merge pull request #24 from doronz88/feature/device-support-api
Browse files Browse the repository at this point in the history
ipsw: add `create_device_support()` method
  • Loading branch information
doronz88 authored Aug 15, 2024
2 parents 75da2b6 + 75267a8 commit da68526
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
20 changes: 1 addition & 19 deletions ipsw_parser/__main__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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__':
Expand Down
21 changes: 21 additions & 0 deletions ipsw_parser/ipsw.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()

0 comments on commit da68526

Please sign in to comment.