ipsw-parser 1.3.8__tar.gz → 1.3.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/PKG-INFO +7 -4
  2. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/README.md +5 -3
  3. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/ipsw_parser/__main__.py +26 -10
  4. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/ipsw_parser/_version.py +2 -2
  5. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/ipsw_parser/build_identity.py +12 -0
  6. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/ipsw_parser.egg-info/PKG-INFO +7 -4
  7. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/ipsw_parser.egg-info/requires.txt +1 -0
  8. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/requirements.txt +2 -1
  9. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/.gitattributes +0 -0
  10. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  11. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  12. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/.github/workflows/codeql.yml +0 -0
  13. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/.github/workflows/python-app.yml +0 -0
  14. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/.github/workflows/python-publish.yml +0 -0
  15. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/.gitignore +0 -0
  16. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/.pre-commit-config.yaml +0 -0
  17. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/CODE_OF_CONDUCT.md +0 -0
  18. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/LICENSE +0 -0
  19. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/ipsw_parser/__init__.py +0 -0
  20. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/ipsw_parser/build_manifest.py +0 -0
  21. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/ipsw_parser/component.py +0 -0
  22. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/ipsw_parser/exceptions.py +0 -0
  23. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/ipsw_parser/firmware.py +0 -0
  24. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/ipsw_parser/img4.py +0 -0
  25. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/ipsw_parser/ipsw.py +0 -0
  26. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/ipsw_parser.egg-info/SOURCES.txt +0 -0
  27. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/ipsw_parser.egg-info/dependency_links.txt +0 -0
  28. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/ipsw_parser.egg-info/entry_points.txt +0 -0
  29. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/ipsw_parser.egg-info/top_level.txt +0 -0
  30. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/pyproject.toml +0 -0
  31. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/pytest.ini +0 -0
  32. {ipsw_parser-1.3.8 → ipsw_parser-1.3.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ipsw-parser
3
- Version: 1.3.8
3
+ Version: 1.3.9
4
4
  Summary: python3 utility for parsing and extracting data from IPSW
5
5
  Author-email: doronz88 <doron88@gmail.com>
6
6
  Maintainer-email: doronz88 <doron88@gmail.com>
@@ -701,18 +701,21 @@ Requires-Dist: cached_property
701
701
  Requires-Dist: plumbum
702
702
  Requires-Dist: pyimg4>=0.8.6
703
703
  Requires-Dist: requests
704
+ Requires-Dist: remotezip2
704
705
  Provides-Extra: test
705
706
  Requires-Dist: pytest; extra == "test"
706
707
 
708
+ # ipsw-parser
709
+
707
710
  [![Python application](https://github.com/doronz88/ipsw_parser/workflows/Python%20application/badge.svg)](https://github.com/doronz88/ipsw_parser/actions/workflows/python-app.yml "Python application action")
708
711
  [![Pypi version](https://img.shields.io/pypi/v/ipsw_parser.svg)](https://pypi.org/project/ipsw_parser/ "PyPi package")
709
712
  [![Downloads](https://static.pepy.tech/personalized-badge/ipsw_parser?period=total&units=none&left_color=grey&right_color=blue&left_text=Downloads)](https://pepy.tech/project/ipsw_parser)
710
713
 
711
- # Overview
714
+ ## Overview
712
715
 
713
716
  python3 utility for parsing and extracting data from IPSW.
714
717
 
715
- # Installation
718
+ ## Installation
716
719
 
717
720
  ```shell
718
721
  python3 -m pip install ipsw-parser
@@ -721,7 +724,7 @@ python3 -m pip install ipsw-parser
721
724
  Additionally, if you installed [blacktop/ipsw](https://github.com/blacktop/ipsw), the IPSW extraction will also contain
722
725
  the split DSC.
723
726
 
724
- # Usage
727
+ ## Usage
725
728
 
726
729
  ```
727
730
  Usage: ipsw-parser [OPTIONS] COMMAND [ARGS]...
@@ -1,12 +1,14 @@
1
+ # ipsw-parser
2
+
1
3
  [![Python application](https://github.com/doronz88/ipsw_parser/workflows/Python%20application/badge.svg)](https://github.com/doronz88/ipsw_parser/actions/workflows/python-app.yml "Python application action")
2
4
  [![Pypi version](https://img.shields.io/pypi/v/ipsw_parser.svg)](https://pypi.org/project/ipsw_parser/ "PyPi package")
3
5
  [![Downloads](https://static.pepy.tech/personalized-badge/ipsw_parser?period=total&units=none&left_color=grey&right_color=blue&left_text=Downloads)](https://pepy.tech/project/ipsw_parser)
4
6
 
5
- # Overview
7
+ ## Overview
6
8
 
7
9
  python3 utility for parsing and extracting data from IPSW.
8
10
 
9
- # Installation
11
+ ## Installation
10
12
 
11
13
  ```shell
12
14
  python3 -m pip install ipsw-parser
@@ -15,7 +17,7 @@ python3 -m pip install ipsw-parser
15
17
  Additionally, if you installed [blacktop/ipsw](https://github.com/blacktop/ipsw), the IPSW extraction will also contain
16
18
  the split DSC.
17
19
 
18
- # Usage
20
+ ## Usage
19
21
 
20
22
  ```
21
23
  Usage: ipsw-parser [OPTIONS] COMMAND [ARGS]...
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env python3
2
2
  import logging
3
3
  from pathlib import Path
4
- from typing import IO, Optional
4
+ from typing import Optional
5
5
  from zipfile import ZipFile
6
6
 
7
7
  import click
8
8
  import coloredlogs
9
+ from remotezip2 import RemoteZip
9
10
 
10
11
  from ipsw_parser.ipsw import IPSW
11
12
 
@@ -23,6 +24,14 @@ logger = logging.getLogger(__name__)
23
24
 
24
25
  PEM_DB_ENV_VAR = 'IPSW_PARSER_PEM_DB'
25
26
 
27
+
28
+ def handle_ipsw_argument(ctx: click.Context, param: click.Argument, value: str) -> IPSW:
29
+ if value.startswith('http://') or value.startswith('https://'):
30
+ return IPSW(RemoteZip(value))
31
+ return IPSW(ZipFile(Path(value).expanduser()))
32
+
33
+
34
+ ipsw_argument = click.argument('ipsw', callback=handle_ipsw_argument)
26
35
  pem_db_option = click.option('--pem-db', envvar=PEM_DB_ENV_VAR,
27
36
  help='Path DB file url (can be either a filesystem path or an HTTP URL). '
28
37
  'Alternatively, use the IPSW_PARSER_PEM_DB envvar.')
@@ -35,10 +44,9 @@ def cli() -> None:
35
44
 
36
45
 
37
46
  @cli.command('info')
38
- @click.argument('file', type=click.Path(exists=True, file_okay=True, dir_okay=False))
39
- def info(file) -> None:
47
+ @ipsw_argument
48
+ def info(ipsw) -> None:
40
49
  """ Parse given .ipsw basic info """
41
- ipsw = IPSW(ZipFile(file))
42
50
  print(f'SupportedProductTypes: {ipsw.build_manifest.supported_product_types}')
43
51
  print(f'ProductVersion: {ipsw.build_manifest.product_version}')
44
52
  print(f'ProductBuildVersion: {ipsw.build_manifest.product_build_version}')
@@ -51,28 +59,36 @@ def info(file) -> None:
51
59
 
52
60
 
53
61
  @cli.command('extract')
54
- @click.argument('file', type=click.Path(exists=True, file_okay=True, dir_okay=False))
62
+ @ipsw_argument
55
63
  @click.argument('output', type=click.Path(exists=False))
56
64
  @pem_db_option
57
- def extract(file: IO, output: str, pem_db: Optional[str]) -> None:
65
+ def extract(ipsw: IPSW, output: str, pem_db: Optional[str]) -> None:
58
66
  """ Extract .ipsw into filesystem layout """
59
67
  output = Path(output)
60
68
 
61
69
  if not output.exists():
62
70
  output.mkdir(parents=True, exist_ok=True)
63
71
 
64
- ipsw = IPSW(ZipFile(file))
65
72
  ipsw.build_manifest.build_identities[0].extract(output, pem_db=pem_db)
66
73
  ipsw.archive.extractall(
67
74
  path=output, members=[f for f in ipsw.archive.filelist if f.filename.startswith('Firmware')])
68
75
 
69
76
 
77
+ @cli.command('extract-kernel')
78
+ @ipsw_argument
79
+ @click.argument('output', type=click.Path(exists=False))
80
+ @click.option('--arch', help='Arch name to extract using lipo')
81
+ def extract_kernel(ipsw: IPSW, output: str, arch: Optional[str]) -> None:
82
+ """ Extract kernelcache from given .ipsw into given output filename """
83
+ Path(output).write_bytes(ipsw.build_manifest.build_identities[0].get_kernelcache_payload(arch=arch))
84
+
85
+
70
86
  @cli.command('device-support')
71
- @click.argument('file', type=click.Path(exists=True, file_okay=True, dir_okay=False))
87
+ @ipsw_argument
72
88
  @pem_db_option
73
- def device_support(file: IO, pem_db: Optional[str]) -> None:
89
+ def device_support(ipsw: IPSW, pem_db: Optional[str]) -> None:
74
90
  """ Create DeviceSupport directory """
75
- IPSW(ZipFile(file)).create_device_support(pem_db=pem_db)
91
+ ipsw.create_device_support(pem_db=pem_db)
76
92
 
77
93
 
78
94
  if __name__ == '__main__':
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '1.3.8'
16
- __version_tuple__ = version_tuple = (1, 3, 8)
15
+ __version__ = version = '1.3.9'
16
+ __version_tuple__ = version_tuple = (1, 3, 9)
@@ -158,6 +158,18 @@ class BuildIdentity(UserDict):
158
158
  sub_path=Path('System'), pem_db=pem_db)
159
159
  _split_dsc(output)
160
160
 
161
+ def get_kernelcache_payload(self, arch: Optional[str] = None) -> bytes:
162
+ im4p = IM4P(self.build_manifest.build_identities[0].get_component('KernelCache').data)
163
+ im4p.payload.decompress()
164
+ payload = im4p.payload.output().data
165
+ if arch is None:
166
+ return payload
167
+
168
+ with TemporaryDirectory() as temp_dir:
169
+ kernel_output = Path(temp_dir) / 'kernel'
170
+ local['ipsw']('macho', 'lipo', '-a', arch, kernel_output)
171
+ return Path(next(kernel_output.parent.glob(f'*.{arch}'))).read_bytes()
172
+
161
173
  def extract(self, output: Path, pem_db: Optional[str] = None) -> None:
162
174
  logger.info(f'extracting into: {output}')
163
175
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ipsw-parser
3
- Version: 1.3.8
3
+ Version: 1.3.9
4
4
  Summary: python3 utility for parsing and extracting data from IPSW
5
5
  Author-email: doronz88 <doron88@gmail.com>
6
6
  Maintainer-email: doronz88 <doron88@gmail.com>
@@ -701,18 +701,21 @@ Requires-Dist: cached_property
701
701
  Requires-Dist: plumbum
702
702
  Requires-Dist: pyimg4>=0.8.6
703
703
  Requires-Dist: requests
704
+ Requires-Dist: remotezip2
704
705
  Provides-Extra: test
705
706
  Requires-Dist: pytest; extra == "test"
706
707
 
708
+ # ipsw-parser
709
+
707
710
  [![Python application](https://github.com/doronz88/ipsw_parser/workflows/Python%20application/badge.svg)](https://github.com/doronz88/ipsw_parser/actions/workflows/python-app.yml "Python application action")
708
711
  [![Pypi version](https://img.shields.io/pypi/v/ipsw_parser.svg)](https://pypi.org/project/ipsw_parser/ "PyPi package")
709
712
  [![Downloads](https://static.pepy.tech/personalized-badge/ipsw_parser?period=total&units=none&left_color=grey&right_color=blue&left_text=Downloads)](https://pepy.tech/project/ipsw_parser)
710
713
 
711
- # Overview
714
+ ## Overview
712
715
 
713
716
  python3 utility for parsing and extracting data from IPSW.
714
717
 
715
- # Installation
718
+ ## Installation
716
719
 
717
720
  ```shell
718
721
  python3 -m pip install ipsw-parser
@@ -721,7 +724,7 @@ python3 -m pip install ipsw-parser
721
724
  Additionally, if you installed [blacktop/ipsw](https://github.com/blacktop/ipsw), the IPSW extraction will also contain
722
725
  the split DSC.
723
726
 
724
- # Usage
727
+ ## Usage
725
728
 
726
729
  ```
727
730
  Usage: ipsw-parser [OPTIONS] COMMAND [ARGS]...
@@ -5,6 +5,7 @@ cached_property
5
5
  plumbum
6
6
  pyimg4>=0.8.6
7
7
  requests
8
+ remotezip2
8
9
 
9
10
  [test]
10
11
  pytest
@@ -4,4 +4,5 @@ coloredlogs
4
4
  cached_property
5
5
  plumbum
6
6
  pyimg4>=0.8.6
7
- requests
7
+ requests
8
+ remotezip2
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes