ipsw-parser 1.7.5__tar.gz → 1.8.1__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 (40) hide show
  1. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/PKG-INFO +1 -2
  2. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/ipsw_parser/_version.py +3 -3
  3. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/ipsw_parser/build_identity.py +11 -12
  4. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/ipsw_parser/dsc.py +2 -3
  5. ipsw_parser-1.8.1/ipsw_parser/process.py +31 -0
  6. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/ipsw_parser.egg-info/PKG-INFO +1 -2
  7. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/ipsw_parser.egg-info/SOURCES.txt +4 -1
  8. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/ipsw_parser.egg-info/requires.txt +0 -1
  9. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/ipsw_parser.egg-info/scm_file_list.json +4 -1
  10. ipsw_parser-1.8.1/ipsw_parser.egg-info/scm_version.json +8 -0
  11. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/requirements.txt +0 -1
  12. ipsw_parser-1.8.1/tests/test_process.py +40 -0
  13. ipsw_parser-1.8.1/tests/test_sandbox_profiles.py +49 -0
  14. ipsw_parser-1.7.5/ipsw_parser.egg-info/scm_version.json +0 -8
  15. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/.gitattributes +0 -0
  16. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  17. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  18. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/.github/workflows/codeql.yml +0 -0
  19. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/.github/workflows/python-app.yml +0 -0
  20. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/.github/workflows/python-publish.yml +0 -0
  21. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/.gitignore +0 -0
  22. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/.pre-commit-config.yaml +0 -0
  23. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/CODE_OF_CONDUCT.md +0 -0
  24. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/LICENSE +0 -0
  25. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/README.md +0 -0
  26. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/ipsw_parser/__init__.py +0 -0
  27. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/ipsw_parser/__main__.py +0 -0
  28. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/ipsw_parser/archive.py +0 -0
  29. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/ipsw_parser/build_manifest.py +0 -0
  30. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/ipsw_parser/component.py +0 -0
  31. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/ipsw_parser/exceptions.py +0 -0
  32. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/ipsw_parser/firmware.py +0 -0
  33. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/ipsw_parser/ipsw.py +0 -0
  34. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/ipsw_parser.egg-info/dependency_links.txt +0 -0
  35. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/ipsw_parser.egg-info/entry_points.txt +0 -0
  36. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/ipsw_parser.egg-info/top_level.txt +0 -0
  37. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/pyproject.toml +0 -0
  38. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/pytest.ini +0 -0
  39. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/setup.cfg +0 -0
  40. {ipsw_parser-1.7.5 → ipsw_parser-1.8.1}/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.7.5
3
+ Version: 1.8.1
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.7.5'
22
- __version_tuple__ = version_tuple = (1, 7, 5)
21
+ __version__ = version = '1.8.1'
22
+ __version_tuple__ = version_tuple = (1, 8, 1)
23
23
 
24
- __commit_id__ = commit_id = 'g06957d9d9'
24
+ __commit_id__ = commit_id = 'gaa9b8c1bd'
@@ -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(args)
53
+ run("ipsw", *args)
56
54
 
57
- hdiutil("attach", "-mountpoint", mnt, dmg)
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,25 +61,26 @@ 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
- hdiutil("detach", "-force", mnt)
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(*args).splitlines()
73
+ profile_names = run("ipsw", *args).splitlines()
77
74
 
78
75
  def decode_worker(profile_name: str) -> None:
79
- profile_path = (output / profile_name).with_suffix(".sb")
76
+ # Not with_suffix(): it would cut a dotted name short, and com.apple.cloudd would share
77
+ # com.apple.sb with every other com.apple.* profile
78
+ profile_path = output / f"{profile_name}.sb"
80
79
  decode_args = ["sb", "dec", kernel_output, profile_name]
81
80
  if profile_type is not None:
82
81
  decode_args += ["--type", profile_type]
83
82
  try:
84
- profile = ipsw(*decode_args)
83
+ profile = run("ipsw", *decode_args)
85
84
  except ProcessExecutionError as e:
86
85
  logger.warning(f"failed to decode sandbox profile {profile_name}: {e}")
87
86
  return
@@ -111,7 +110,7 @@ def _extract_kernelcache(build_identity: "BuildIdentity", output: Path) -> Path:
111
110
  kernel_output.write_bytes(im4p.payload.output().data)
112
111
  try:
113
112
  # In case the kernel is a FAT image, extract the arm64 macho
114
- local["ipsw"]("macho", "lipo", "-a", "arm64", kernel_output)
113
+ run("ipsw", "macho", "lipo", "-a", "arm64", kernel_output)
115
114
  next(iter(kernel_output.parent.glob("*.arm64"))).rename(kernel_output)
116
115
  except ProcessExecutionError:
117
116
  pass
@@ -196,7 +195,7 @@ class BuildIdentity(UserDict):
196
195
 
197
196
  with TemporaryDirectory() as temp_dir:
198
197
  kernel_output = Path(temp_dir) / "kernel"
199
- local["ipsw"]("macho", "lipo", "-a", arch, kernel_output)
198
+ run("ipsw", "macho", "lipo", "-a", arch, kernel_output)
200
199
  return Path(next(kernel_output.parent.glob(f"*.{arch}"))).read_bytes()
201
200
 
202
201
  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 plumbum import local
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
- ipsw("dyld", "split", dsc, "-o", root)
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.7.5
3
+ Version: 1.8.1
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,6 @@ 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
37
+ tests/test_sandbox_profiles.py
@@ -1,6 +1,5 @@
1
1
  construct>=2.9.29
2
2
  coloredlogs
3
- plumbum
4
3
  pyimg4>=0.8.8
5
4
  requests
6
5
  remotezip2
@@ -21,9 +21,12 @@
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",
30
+ "tests/test_sandbox_profiles.py"
28
31
  ]
29
32
  }
@@ -0,0 +1,8 @@
1
+ {
2
+ "tag": "1.8.1",
3
+ "distance": 0,
4
+ "node": "gaa9b8c1bd4f082171d75db2cf05ae21f5a9548ea",
5
+ "dirty": false,
6
+ "branch": "HEAD",
7
+ "node_date": "2026-10-11"
8
+ }
@@ -1,6 +1,5 @@
1
1
  construct>=2.9.29
2
2
  coloredlogs
3
- plumbum
4
3
  pyimg4>=0.8.8
5
4
  requests
6
5
  remotezip2
@@ -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")
@@ -0,0 +1,49 @@
1
+ from pathlib import Path
2
+
3
+ import pytest
4
+
5
+ from ipsw_parser import build_identity
6
+ from ipsw_parser.process import ProcessExecutionError
7
+
8
+ PROFILES = ["baseline", "com.apple.cloudd", "com.apple.homed", "spotlightknowledged", "spotlightknowledged.updater"]
9
+
10
+
11
+ def _fake_ipsw(calls: list) -> object:
12
+ def run(tool: str, *args: object) -> str:
13
+ calls.append((tool, *map(str, args)))
14
+ assert tool == "ipsw"
15
+ if args[1] == "list":
16
+ return "\n".join(PROFILES) + "\n"
17
+ name = str(args[3])
18
+ if name == "com.apple.homed":
19
+ raise ProcessExecutionError(["ipsw", "sb", "dec"], 1, "", "cannot decode")
20
+ return f"(profile {name})\n"
21
+
22
+ return run
23
+
24
+
25
+ def test_every_profile_gets_a_file_of_its_own(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
26
+ calls: list = []
27
+ monkeypatch.setattr(build_identity, "run", _fake_ipsw(calls))
28
+ output = tmp_path / "profiles"
29
+
30
+ build_identity._decode_sandbox_profiles(tmp_path / "kernelcache", output)
31
+
32
+ # A dotted name keeps all of its parts, and a profile that fails to decode is skipped
33
+ assert {path.name: path.read_text() for path in output.iterdir()} == {
34
+ "baseline.sb": "(profile baseline)\n",
35
+ "com.apple.cloudd.sb": "(profile com.apple.cloudd)\n",
36
+ "spotlightknowledged.sb": "(profile spotlightknowledged)\n",
37
+ "spotlightknowledged.updater.sb": "(profile spotlightknowledged.updater)\n",
38
+ }
39
+
40
+
41
+ def test_profile_type_is_passed_to_list_and_decode(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
42
+ calls: list = []
43
+ monkeypatch.setattr(build_identity, "run", _fake_ipsw(calls))
44
+ kernel = tmp_path / "kernelcache"
45
+
46
+ build_identity._decode_sandbox_profiles(kernel, tmp_path / "protobox", profile_type="protobox")
47
+
48
+ assert calls[0] == ("ipsw", "sb", "list", str(kernel), "--type", "protobox")
49
+ assert ("ipsw", "sb", "dec", str(kernel), "spotlightknowledged.updater", "--type", "protobox") in calls
@@ -1,8 +0,0 @@
1
- {
2
- "tag": "1.7.5",
3
- "distance": 0,
4
- "node": "g06957d9d95e7064ed2e7ae592fba92ebebf7806a",
5
- "dirty": false,
6
- "branch": "HEAD",
7
- "node_date": "2026-08-25"
8
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes