ipsw-parser 1.8.2__tar.gz → 1.8.3__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 (41) hide show
  1. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/PKG-INFO +2 -2
  2. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/ipsw_parser/_version.py +3 -3
  3. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/ipsw_parser/ipsw.py +38 -35
  4. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/ipsw_parser.egg-info/PKG-INFO +2 -2
  5. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/ipsw_parser.egg-info/requires.txt +1 -1
  6. ipsw_parser-1.8.3/ipsw_parser.egg-info/scm_version.json +8 -0
  7. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/requirements.txt +1 -1
  8. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/tests/test_archive_backends.py +34 -1
  9. ipsw_parser-1.8.2/ipsw_parser.egg-info/scm_version.json +0 -8
  10. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/.gitattributes +0 -0
  11. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  12. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  13. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/.github/workflows/codeql.yml +0 -0
  14. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/.github/workflows/python-app.yml +0 -0
  15. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/.github/workflows/python-publish.yml +0 -0
  16. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/.gitignore +0 -0
  17. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/.pre-commit-config.yaml +0 -0
  18. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/CODE_OF_CONDUCT.md +0 -0
  19. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/LICENSE +0 -0
  20. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/README.md +0 -0
  21. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/ipsw_parser/__init__.py +0 -0
  22. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/ipsw_parser/__main__.py +0 -0
  23. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/ipsw_parser/archive.py +0 -0
  24. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/ipsw_parser/build_identity.py +0 -0
  25. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/ipsw_parser/build_manifest.py +0 -0
  26. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/ipsw_parser/component.py +0 -0
  27. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/ipsw_parser/dsc.py +0 -0
  28. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/ipsw_parser/exceptions.py +0 -0
  29. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/ipsw_parser/firmware.py +0 -0
  30. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/ipsw_parser/process.py +0 -0
  31. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/ipsw_parser.egg-info/SOURCES.txt +0 -0
  32. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/ipsw_parser.egg-info/dependency_links.txt +0 -0
  33. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/ipsw_parser.egg-info/entry_points.txt +0 -0
  34. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/ipsw_parser.egg-info/scm_file_list.json +0 -0
  35. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/ipsw_parser.egg-info/top_level.txt +0 -0
  36. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/pyproject.toml +0 -0
  37. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/pytest.ini +0 -0
  38. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/setup.cfg +0 -0
  39. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/tests/test_dsc.py +0 -0
  40. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/tests/test_process.py +0 -0
  41. {ipsw_parser-1.8.2 → ipsw_parser-1.8.3}/tests/test_sandbox_profiles.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ipsw-parser
3
- Version: 1.8.2
3
+ Version: 1.8.3
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>
@@ -695,7 +695,7 @@ Classifier: Programming Language :: Python :: 3 :: Only
695
695
  Requires-Python: >=3.9
696
696
  Description-Content-Type: text/markdown
697
697
  License-File: LICENSE
698
- Requires-Dist: construct>=2.9.29
698
+ Requires-Dist: bytestruct>=0.1.0
699
699
  Requires-Dist: coloredlogs
700
700
  Requires-Dist: pyimg4>=0.8.8
701
701
  Requires-Dist: requests
@@ -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.8.2'
22
- __version_tuple__ = version_tuple = (1, 8, 2)
21
+ __version__ = version = '1.8.3'
22
+ __version_tuple__ = version_tuple = (1, 8, 3)
23
23
 
24
- __commit_id__ = commit_id = 'g7fae59bd2'
24
+ __commit_id__ = commit_id = 'gc9b1581ba'
@@ -1,11 +1,12 @@
1
1
  import logging
2
2
  from contextlib import contextmanager
3
+ from dataclasses import dataclass, field
3
4
  from functools import cached_property
4
5
  from pathlib import Path
5
- from typing import Optional
6
+ from typing import Annotated, Optional
6
7
  from zipfile import ZipFile
7
8
 
8
- from construct import Const, Default, PaddedString, Struct
9
+ from bytestruct import BinaryStruct, Bytes, Const
9
10
  from remotezip2 import RemoteZip
10
11
 
11
12
  from ipsw_parser.archive import Archive, ArchiveMember, DirectoryArchive, ZipArchive
@@ -15,23 +16,39 @@ from ipsw_parser.firmware import Firmware
15
16
 
16
17
  logger = logging.getLogger(__name__)
17
18
 
18
- cpio_odc_header = Struct(
19
- "c_magic" / Const("070707", PaddedString(6, "utf8")),
20
- "c_dev"
21
- / Default(
22
- PaddedString(6, "utf8"),
23
- "0" * 6,
24
- ),
25
- "c_ino" / PaddedString(6, "utf8"),
26
- "c_mode" / PaddedString(6, "utf8"),
27
- "c_uid" / Default(PaddedString(6, "utf8"), "0" * 6),
28
- "c_gid" / Default(PaddedString(6, "utf8"), "0" * 6),
29
- "c_nlink" / PaddedString(6, "utf8"),
30
- "c_rdev" / Default(PaddedString(6, "utf8"), "0" * 6),
31
- "c_mtime" / Default(PaddedString(11, "utf8"), "0" * 11),
32
- "c_namesize" / PaddedString(6, "utf8"),
33
- "c_filesize" / Default(PaddedString(11, "utf8"), "0" * 11),
34
- )
19
+
20
+ @dataclass
21
+ class CpioOdcHeader(BinaryStruct):
22
+ """A POSIX.1 portable ("odc") cpio header: every field is zero-padded octal ASCII."""
23
+
24
+ c_magic: Annotated[bytes, Bytes(6), Const(b"070707")] = field(default=b"070707", init=False)
25
+ c_dev: Annotated[bytes, Bytes(6)]
26
+ c_ino: Annotated[bytes, Bytes(6)]
27
+ c_mode: Annotated[bytes, Bytes(6)]
28
+ c_uid: Annotated[bytes, Bytes(6)]
29
+ c_gid: Annotated[bytes, Bytes(6)]
30
+ c_nlink: Annotated[bytes, Bytes(6)]
31
+ c_rdev: Annotated[bytes, Bytes(6)]
32
+ c_mtime: Annotated[bytes, Bytes(11)]
33
+ c_namesize: Annotated[bytes, Bytes(6)]
34
+ c_filesize: Annotated[bytes, Bytes(11)]
35
+
36
+
37
+ def _build_cpio_odc_header(ino: int, mode: int, nlink: int, namesize: int, filesize: int = 0) -> bytes:
38
+ """Build an odc cpio header; device, owner, rdev and mtime are always zero."""
39
+ zero6 = b"0" * 6
40
+ return CpioOdcHeader(
41
+ c_dev=zero6,
42
+ c_ino=f"{ino:06o}".encode(),
43
+ c_mode=f"{mode:06o}".encode(),
44
+ c_uid=zero6,
45
+ c_gid=zero6,
46
+ c_nlink=f"{nlink:06o}".encode(),
47
+ c_rdev=zero6,
48
+ c_mtime=b"0" * 11,
49
+ c_namesize=f"{namesize:06o}".encode(),
50
+ c_filesize=f"{filesize:011o}".encode(),
51
+ ).build()
35
52
 
36
53
 
37
54
  class IPSW:
@@ -105,13 +122,7 @@ class IPSW:
105
122
  filename = subpath
106
123
  filename = f"{filename}\0".encode()
107
124
  mode = e.external_attr >> 16
108
- result += cpio_odc_header.build({
109
- "c_ino": f"{inode:06o}",
110
- "c_nlink": f"{nlink:06o}",
111
- "c_mode": f"{mode:06o}",
112
- "c_namesize": f"{len(filename):06o}",
113
- "c_filesize": f"{e.file_size:011o}",
114
- })
125
+ result += _build_cpio_odc_header(inode, mode, nlink, len(filename), e.file_size)
115
126
  inode += 1
116
127
  result += filename
117
128
  if not e.file_size:
@@ -123,15 +134,7 @@ class IPSW:
123
134
  filename = b"TRAILER!!!\0"
124
135
  inode = 0
125
136
  mode = 0
126
- result += (
127
- cpio_odc_header.build({
128
- "c_ino": f"{inode:06o}",
129
- "c_mode": f"{mode:06o}",
130
- "c_nlink": f"{nlink:06o}",
131
- "c_namesize": f"{len(filename):06o}",
132
- })
133
- + filename
134
- )
137
+ result += _build_cpio_odc_header(inode, mode, nlink, len(filename)) + filename
135
138
  return result
136
139
 
137
140
  def read(self, path: str) -> bytes:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ipsw-parser
3
- Version: 1.8.2
3
+ Version: 1.8.3
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>
@@ -695,7 +695,7 @@ Classifier: Programming Language :: Python :: 3 :: Only
695
695
  Requires-Python: >=3.9
696
696
  Description-Content-Type: text/markdown
697
697
  License-File: LICENSE
698
- Requires-Dist: construct>=2.9.29
698
+ Requires-Dist: bytestruct>=0.1.0
699
699
  Requires-Dist: coloredlogs
700
700
  Requires-Dist: pyimg4>=0.8.8
701
701
  Requires-Dist: requests
@@ -1,4 +1,4 @@
1
- construct>=2.9.29
1
+ bytestruct>=0.1.0
2
2
  coloredlogs
3
3
  pyimg4>=0.8.8
4
4
  requests
@@ -0,0 +1,8 @@
1
+ {
2
+ "tag": "1.8.3",
3
+ "distance": 0,
4
+ "node": "gc9b1581ba6a4a572309d7cde07c1d0dba36c8c16",
5
+ "dirty": false,
6
+ "branch": "HEAD",
7
+ "node_date": "2026-10-17"
8
+ }
@@ -1,4 +1,4 @@
1
- construct>=2.9.29
1
+ bytestruct>=0.1.0
2
2
  coloredlogs
3
3
  pyimg4>=0.8.8
4
4
  requests
@@ -1,6 +1,6 @@
1
1
  import plistlib
2
2
  from pathlib import Path
3
- from zipfile import ZipFile
3
+ from zipfile import ZipFile, ZipInfo
4
4
 
5
5
  from ipsw_parser.archive import DirectoryArchive, ZipArchive
6
6
  from ipsw_parser.ipsw import IPSW
@@ -68,3 +68,36 @@ def test_directory_extractall_copies_requested_members(tmp_path: Path) -> None:
68
68
 
69
69
  assert (output / "Firmware" / "devel-file.bin").read_bytes() == b"dev"
70
70
  assert not (output / "Release" / "normal-file.bin").exists()
71
+
72
+
73
+ def _cpio_header(ino: int, mode: int, namesize: int, filesize: int) -> bytes:
74
+ return f"070707000000{ino:06o}{mode:06o}000000000000000001000000{0:011o}{namesize:06o}{filesize:011o}".encode()
75
+
76
+
77
+ def test_bootability_builds_odc_cpio_archive(tmp_path: Path) -> None:
78
+ archive_path = tmp_path / "sample.ipsw"
79
+ with ZipFile(archive_path, "w") as archive:
80
+ archive.writestr("BuildManifest.plist", _build_manifest())
81
+ for name, mode, data in (
82
+ ("BootabilityBundle/Restore/Bootability/payload.bin", 0o100644, b"hello"),
83
+ ("BootabilityBundle/Restore/Bootability/empty", 0o100600, b""),
84
+ ("BootabilityBundle/Restore/Firmware/Bootability.dmg.trustcache", 0o100644, b"trust"),
85
+ ("Firmware/unrelated.bin", 0o100644, b"ignored"),
86
+ ):
87
+ info = ZipInfo(name)
88
+ info.external_attr = mode << 16
89
+ archive.writestr(info, data)
90
+
91
+ with ZipFile(archive_path) as archive:
92
+ bootability = IPSW(ZipArchive(archive)).bootability
93
+
94
+ assert bootability == (
95
+ _cpio_header(1, 0o100644, 12, 5)
96
+ + b"payload.bin\0hello"
97
+ + _cpio_header(2, 0o100600, 6, 0)
98
+ + b"empty\0"
99
+ + _cpio_header(3, 0o100644, 23, 5)
100
+ + b"Bootability.trustcache\0trust"
101
+ + _cpio_header(0, 0, 11, 0)
102
+ + b"TRAILER!!!\0"
103
+ )
@@ -1,8 +0,0 @@
1
- {
2
- "tag": "1.8.2",
3
- "distance": 0,
4
- "node": "g7fae59bd2f7f087145f91cc5978c17d00dc983ba",
5
- "dirty": false,
6
- "branch": "HEAD",
7
- "node_date": "2026-10-12"
8
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes