ipsw-parser 1.7.5__tar.gz → 1.8.0__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.
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/PKG-INFO +1 -2
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/ipsw_parser/_version.py +3 -3
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/ipsw_parser/build_identity.py +8 -11
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/ipsw_parser/dsc.py +2 -3
- ipsw_parser-1.8.0/ipsw_parser/process.py +31 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/ipsw_parser.egg-info/PKG-INFO +1 -2
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/ipsw_parser.egg-info/SOURCES.txt +3 -1
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/ipsw_parser.egg-info/requires.txt +0 -1
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/ipsw_parser.egg-info/scm_file_list.json +3 -1
- ipsw_parser-1.8.0/ipsw_parser.egg-info/scm_version.json +8 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/requirements.txt +0 -1
- ipsw_parser-1.8.0/tests/test_process.py +40 -0
- ipsw_parser-1.7.5/ipsw_parser.egg-info/scm_version.json +0 -8
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/.gitattributes +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/.github/workflows/codeql.yml +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/.github/workflows/python-app.yml +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/.github/workflows/python-publish.yml +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/.gitignore +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/.pre-commit-config.yaml +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/CODE_OF_CONDUCT.md +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/LICENSE +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/README.md +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/ipsw_parser/__init__.py +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/ipsw_parser/__main__.py +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/ipsw_parser/archive.py +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/ipsw_parser/build_manifest.py +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/ipsw_parser/component.py +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/ipsw_parser/exceptions.py +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/ipsw_parser/firmware.py +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/ipsw_parser/ipsw.py +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/ipsw_parser.egg-info/dependency_links.txt +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/ipsw_parser.egg-info/entry_points.txt +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/ipsw_parser.egg-info/top_level.txt +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/pyproject.toml +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/pytest.ini +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/setup.cfg +0 -0
- {ipsw_parser-1.7.5 → ipsw_parser-1.8.0}/tests/test_archive_backends.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ipsw-parser
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.8.0
|
|
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>
|
|
@@ -697,7 +697,6 @@ Description-Content-Type: text/markdown
|
|
|
697
697
|
License-File: LICENSE
|
|
698
698
|
Requires-Dist: construct>=2.9.29
|
|
699
699
|
Requires-Dist: coloredlogs
|
|
700
|
-
Requires-Dist: plumbum
|
|
701
700
|
Requires-Dist: pyimg4>=0.8.8
|
|
702
701
|
Requires-Dist: requests
|
|
703
702
|
Requires-Dist: remotezip2
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '1.
|
|
22
|
-
__version_tuple__ = version_tuple = (1,
|
|
21
|
+
__version__ = version = '1.8.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (1, 8, 0)
|
|
23
23
|
|
|
24
|
-
__commit_id__ = commit_id = '
|
|
24
|
+
__commit_id__ = commit_id = 'gfea62ccb1'
|
|
@@ -9,12 +9,12 @@ from tempfile import TemporaryDirectory
|
|
|
9
9
|
from typing import Optional
|
|
10
10
|
|
|
11
11
|
import requests
|
|
12
|
-
from plumbum import ProcessExecutionError, local
|
|
13
12
|
from pyimg4 import IM4P
|
|
14
13
|
|
|
15
14
|
from ipsw_parser.archive import Archive
|
|
16
15
|
from ipsw_parser.component import Component
|
|
17
16
|
from ipsw_parser.dsc import split_dsc
|
|
17
|
+
from ipsw_parser.process import ProcessExecutionError, run
|
|
18
18
|
|
|
19
19
|
logger = logging.getLogger(__name__)
|
|
20
20
|
|
|
@@ -29,8 +29,6 @@ def extract_as(archive: Archive, member_name, output_path, chunk_size=64 * 1024)
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
def _extract_dmg(dmg: Path, output: Path, sub_path: Optional[Path] = None, pem_db: Optional[str] = None) -> None:
|
|
32
|
-
ipsw = local["ipsw"]
|
|
33
|
-
hdiutil = local["hdiutil"]
|
|
34
32
|
# darwin system statistically have problems cleaning up after detaching the mountpoint
|
|
35
33
|
with TemporaryDirectory() as temp_dir:
|
|
36
34
|
temp_dir = Path(temp_dir)
|
|
@@ -52,9 +50,9 @@ def _extract_dmg(dmg: Path, output: Path, sub_path: Optional[Path] = None, pem_d
|
|
|
52
50
|
temp_pem_db.write_text(requests.get(pem_db, verify=False).text)
|
|
53
51
|
pem_db = temp_pem_db
|
|
54
52
|
args += ["--pem-db", pem_db]
|
|
55
|
-
ipsw
|
|
53
|
+
run("ipsw", *args)
|
|
56
54
|
|
|
57
|
-
|
|
55
|
+
run("hdiutil", "attach", "-mountpoint", mnt, dmg)
|
|
58
56
|
|
|
59
57
|
try:
|
|
60
58
|
src = mnt if sub_path is None else mnt / sub_path
|
|
@@ -63,17 +61,16 @@ def _extract_dmg(dmg: Path, output: Path, sub_path: Optional[Path] = None, pem_d
|
|
|
63
61
|
# when overwriting the same files, some of them don't contain write permissions
|
|
64
62
|
pass
|
|
65
63
|
|
|
66
|
-
|
|
64
|
+
run("hdiutil", "detach", "-force", mnt)
|
|
67
65
|
|
|
68
66
|
|
|
69
67
|
def _decode_sandbox_profiles(kernel_output: Path, output: Path, profile_type: Optional[str] = None) -> None:
|
|
70
|
-
ipsw = local["ipsw"]
|
|
71
68
|
args = ["sb", "list", kernel_output]
|
|
72
69
|
if profile_type is not None:
|
|
73
70
|
args += ["--type", profile_type]
|
|
74
71
|
|
|
75
72
|
output.mkdir(exist_ok=True, parents=True)
|
|
76
|
-
profile_names = ipsw
|
|
73
|
+
profile_names = run("ipsw", *args).splitlines()
|
|
77
74
|
|
|
78
75
|
def decode_worker(profile_name: str) -> None:
|
|
79
76
|
profile_path = (output / profile_name).with_suffix(".sb")
|
|
@@ -81,7 +78,7 @@ def _decode_sandbox_profiles(kernel_output: Path, output: Path, profile_type: Op
|
|
|
81
78
|
if profile_type is not None:
|
|
82
79
|
decode_args += ["--type", profile_type]
|
|
83
80
|
try:
|
|
84
|
-
profile = ipsw
|
|
81
|
+
profile = run("ipsw", *decode_args)
|
|
85
82
|
except ProcessExecutionError as e:
|
|
86
83
|
logger.warning(f"failed to decode sandbox profile {profile_name}: {e}")
|
|
87
84
|
return
|
|
@@ -111,7 +108,7 @@ def _extract_kernelcache(build_identity: "BuildIdentity", output: Path) -> Path:
|
|
|
111
108
|
kernel_output.write_bytes(im4p.payload.output().data)
|
|
112
109
|
try:
|
|
113
110
|
# In case the kernel is a FAT image, extract the arm64 macho
|
|
114
|
-
|
|
111
|
+
run("ipsw", "macho", "lipo", "-a", "arm64", kernel_output)
|
|
115
112
|
next(iter(kernel_output.parent.glob("*.arm64"))).rename(kernel_output)
|
|
116
113
|
except ProcessExecutionError:
|
|
117
114
|
pass
|
|
@@ -196,7 +193,7 @@ class BuildIdentity(UserDict):
|
|
|
196
193
|
|
|
197
194
|
with TemporaryDirectory() as temp_dir:
|
|
198
195
|
kernel_output = Path(temp_dir) / "kernel"
|
|
199
|
-
|
|
196
|
+
run("ipsw", "macho", "lipo", "-a", arch, kernel_output)
|
|
200
197
|
return Path(next(kernel_output.parent.glob(f"*.{arch}"))).read_bytes()
|
|
201
198
|
|
|
202
199
|
def extract_sandbox_profiles(self, output: Path) -> None:
|
|
@@ -3,14 +3,13 @@ import plistlib
|
|
|
3
3
|
from datetime import datetime
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
|
|
6
|
-
from
|
|
6
|
+
from ipsw_parser.process import run
|
|
7
7
|
|
|
8
8
|
logger = logging.getLogger(__name__)
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
def split_dsc(root: Path) -> None:
|
|
12
12
|
"""Split dyld shared caches found under ``root`` using ``ipsw dyld split``."""
|
|
13
|
-
ipsw = local["ipsw"]
|
|
14
13
|
dsc_paths = [
|
|
15
14
|
root / "System/Library/Caches/com.apple.dyld/dyld_shared_cache_arm64",
|
|
16
15
|
root / "System/Library/Caches/com.apple.dyld/dyld_shared_cache_arm64e",
|
|
@@ -23,7 +22,7 @@ def split_dsc(root: Path) -> None:
|
|
|
23
22
|
continue
|
|
24
23
|
|
|
25
24
|
logger.info(f"splitting DSC: {dsc}")
|
|
26
|
-
|
|
25
|
+
run("ipsw", "dyld", "split", dsc, "-o", root)
|
|
27
26
|
|
|
28
27
|
|
|
29
28
|
def get_device_support_path(product_type: str, product_version: str, product_build_version: str) -> Path:
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import subprocess
|
|
3
|
+
from typing import Union
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ProcessExecutionError(OSError):
|
|
7
|
+
"""An external tool exited with a non-zero status."""
|
|
8
|
+
|
|
9
|
+
def __init__(self, argv: list[str], returncode: int, stdout: str, stderr: str) -> None:
|
|
10
|
+
self.argv = argv
|
|
11
|
+
self.returncode = returncode
|
|
12
|
+
self.stdout = stdout
|
|
13
|
+
self.stderr = stderr
|
|
14
|
+
message = f"Unexpected exit code: {returncode}\nCommand line: {' '.join(argv)}"
|
|
15
|
+
for name, output in (("Stdout", stdout), ("Stderr", stderr)):
|
|
16
|
+
if output.strip():
|
|
17
|
+
message += f"\n{name}: {output.strip()}"
|
|
18
|
+
super().__init__(message)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def run(tool: str, *args: Union[str, "os.PathLike[str]"]) -> str:
|
|
22
|
+
"""Run an external tool to completion and return what it printed to stdout.
|
|
23
|
+
|
|
24
|
+
:raises FileNotFoundError: if the tool is not installed.
|
|
25
|
+
:raises ProcessExecutionError: if it exits with a non-zero status.
|
|
26
|
+
"""
|
|
27
|
+
argv = [tool, *(os.fspath(arg) for arg in args)]
|
|
28
|
+
result = subprocess.run(argv, capture_output=True, text=True, errors="replace")
|
|
29
|
+
if result.returncode != 0:
|
|
30
|
+
raise ProcessExecutionError(argv, result.returncode, result.stdout, result.stderr)
|
|
31
|
+
return result.stdout
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ipsw-parser
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.8.0
|
|
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>
|
|
@@ -697,7 +697,6 @@ Description-Content-Type: text/markdown
|
|
|
697
697
|
License-File: LICENSE
|
|
698
698
|
Requires-Dist: construct>=2.9.29
|
|
699
699
|
Requires-Dist: coloredlogs
|
|
700
|
-
Requires-Dist: plumbum
|
|
701
700
|
Requires-Dist: pyimg4>=0.8.8
|
|
702
701
|
Requires-Dist: requests
|
|
703
702
|
Requires-Dist: remotezip2
|
|
@@ -23,6 +23,7 @@ ipsw_parser/dsc.py
|
|
|
23
23
|
ipsw_parser/exceptions.py
|
|
24
24
|
ipsw_parser/firmware.py
|
|
25
25
|
ipsw_parser/ipsw.py
|
|
26
|
+
ipsw_parser/process.py
|
|
26
27
|
ipsw_parser.egg-info/PKG-INFO
|
|
27
28
|
ipsw_parser.egg-info/SOURCES.txt
|
|
28
29
|
ipsw_parser.egg-info/dependency_links.txt
|
|
@@ -31,4 +32,5 @@ ipsw_parser.egg-info/requires.txt
|
|
|
31
32
|
ipsw_parser.egg-info/scm_file_list.json
|
|
32
33
|
ipsw_parser.egg-info/scm_version.json
|
|
33
34
|
ipsw_parser.egg-info/top_level.txt
|
|
34
|
-
tests/test_archive_backends.py
|
|
35
|
+
tests/test_archive_backends.py
|
|
36
|
+
tests/test_process.py
|
|
@@ -21,9 +21,11 @@
|
|
|
21
21
|
"ipsw_parser/exceptions.py",
|
|
22
22
|
"ipsw_parser/firmware.py",
|
|
23
23
|
"ipsw_parser/ipsw.py",
|
|
24
|
+
"ipsw_parser/process.py",
|
|
24
25
|
"pyproject.toml",
|
|
25
26
|
"pytest.ini",
|
|
26
27
|
"requirements.txt",
|
|
27
|
-
"tests/test_archive_backends.py"
|
|
28
|
+
"tests/test_archive_backends.py",
|
|
29
|
+
"tests/test_process.py"
|
|
28
30
|
]
|
|
29
31
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import pytest
|
|
5
|
+
|
|
6
|
+
from ipsw_parser.process import ProcessExecutionError, run
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def test_run_returns_stdout() -> None:
|
|
10
|
+
assert run(sys.executable, "-c", "import sys; print('out'); print('err', file=sys.stderr)").splitlines() == ["out"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def test_run_accepts_path_arguments(tmp_path: Path) -> None:
|
|
14
|
+
script = tmp_path / "script with space.py"
|
|
15
|
+
script.write_text("import sys; print(sys.argv[1])")
|
|
16
|
+
|
|
17
|
+
assert run(sys.executable, script, tmp_path).strip() == str(tmp_path)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_run_reports_a_failing_tool_with_its_output() -> None:
|
|
21
|
+
with pytest.raises(ProcessExecutionError) as excinfo:
|
|
22
|
+
run(sys.executable, "-c", "import sys; print('partial'); print('the reason', file=sys.stderr); sys.exit(3)")
|
|
23
|
+
|
|
24
|
+
error = excinfo.value
|
|
25
|
+
assert error.returncode == 3
|
|
26
|
+
assert error.stdout.strip() == "partial"
|
|
27
|
+
assert error.stderr.strip() == "the reason"
|
|
28
|
+
assert "Unexpected exit code: 3" in str(error)
|
|
29
|
+
assert "the reason" in str(error)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_a_failing_tool_is_an_oserror() -> None:
|
|
33
|
+
# Callers that guard an extraction with `except OSError` keep catching a failed tool
|
|
34
|
+
with pytest.raises(OSError):
|
|
35
|
+
run(sys.executable, "-c", "raise SystemExit(1)")
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def test_run_of_a_missing_tool_raises_file_not_found() -> None:
|
|
39
|
+
with pytest.raises(FileNotFoundError):
|
|
40
|
+
run("ipsw-parser-no-such-tool")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|