xy-forever 0.1.0.dev135__tar.gz → 0.1.0.dev136__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.
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/PKG-INFO +1 -1
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/pyproject.toml +1 -1
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/host_write.py +25 -0
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/modsend.py +7 -3
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/package_store.py +31 -10
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/usb_proto_ids.py +11 -3
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/LICENSE +0 -0
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/README.md +0 -0
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/__init__.py +0 -0
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/bounds.py +0 -0
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/depth.py +0 -0
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/dev_entry.py +0 -0
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/device_client.py +0 -0
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/device_lock.py +0 -0
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/host_trust.py +0 -0
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/ldr.py +0 -0
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/modconfig.py +0 -0
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/moddev.py +0 -0
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/modsend_local.py +0 -0
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/modstore.py +0 -0
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/mtp_read.py +0 -0
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/native_json.py +0 -0
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/no_device.py +0 -0
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/package_records.py +0 -0
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/paths.py +0 -0
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/startup_ready.py +0 -0
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/transport.py +0 -0
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/usb_proto.py +0 -0
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/xyf.py +0 -0
- {xy_forever-0.1.0.dev135 → xy_forever-0.1.0.dev136}/xy_forever/xyf_entry.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: xy-forever
|
|
3
|
-
Version: 0.1.0.
|
|
3
|
+
Version: 0.1.0.dev136
|
|
4
4
|
Summary: Boot your Open-XY build once on an OP-XY running XY Forever: xyf stock-os, xyf dev, xyf logs
|
|
5
5
|
Project-URL: Homepage, https://xy-forever.trappar.com
|
|
6
6
|
Project-URL: Source, https://github.com/trappar/xy-forever
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# project is ../pyproject.toml.
|
|
5
5
|
[project]
|
|
6
6
|
name = "xy-forever"
|
|
7
|
-
version = "0.1.0.
|
|
7
|
+
version = "0.1.0.dev136" # the lowest the next normal version may be: scripts/xyf_dist.py version picks the real one
|
|
8
8
|
description = "Boot your Open-XY build once on an OP-XY running XY Forever: xyf stock-os, xyf dev, xyf logs"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -57,6 +57,31 @@ def streams(dev):
|
|
|
57
57
|
return info is None or info.answers(P.ids.WRITE_BEGIN)
|
|
58
58
|
|
|
59
59
|
|
|
60
|
+
def hashes(dev):
|
|
61
|
+
"""The device hashes a stored file itself (file.hash, 1.32): a check needs no read-back over USB."""
|
|
62
|
+
info = getattr(dev, 'hello_info', None)
|
|
63
|
+
return info is not None and not info.pre_v1 and info.answers(P.ids.HASH_FILE)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def stored_sha256(dev, path, size=0):
|
|
67
|
+
"""(status, SHA-256) of the file stored at path, hashed on the device (file.hash, 1.32); size: the bytes expected
|
|
68
|
+
(the time the host waits)."""
|
|
69
|
+
code, body = dev.call(P.ids.HASH_FILE, path.encode('utf-8') + b'\0', timeout=60.0 + size / 20000.0)
|
|
70
|
+
return code, body[4:36]
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def holds(dev, path, data, read):
|
|
74
|
+
"""(status, whether the file stored at path holds exactly data): compared by SHA-256, hashed on the device from 1.32
|
|
75
|
+
(stored_sha256), before it read back whole over USB with read(path) -> (status, bytes)."""
|
|
76
|
+
want = hashlib.sha256(data).digest()
|
|
77
|
+
if hashes(dev):
|
|
78
|
+
code, sha = stored_sha256(dev, path, len(data))
|
|
79
|
+
else:
|
|
80
|
+
code, back = read(path)
|
|
81
|
+
sha = hashlib.sha256(back).digest()
|
|
82
|
+
return code, not code and sha == want
|
|
83
|
+
|
|
84
|
+
|
|
60
85
|
def write_staged(dev, path, data, progress=None):
|
|
61
86
|
"""Before 1.18 (the throughput table's "before" row): stage, then file.write_staged (in place, staging-sized)."""
|
|
62
87
|
code = dev.stage(data, progress)
|
|
@@ -122,8 +122,9 @@ def package_line(result):
|
|
|
122
122
|
def push_package(dev, session, folder, name, files, verify=False):
|
|
123
123
|
"""One package of a push. Up to date (nothing sent) when the device holds the same stored files, by name and size,
|
|
124
124
|
and the same files.sha256: one read (stored names carry each file's SHA-256; files.sha256 is published last and
|
|
125
|
-
lists every file's), every file
|
|
126
|
-
sent; the others move over from the published package on the device
|
|
125
|
+
lists every file's), every file checked only with verify (its SHA-256, hashed on the device from 1.32). Otherwise
|
|
126
|
+
only the files whose content changed are sent; the others move over from the published package on the device
|
|
127
|
+
(package_store publish keep)."""
|
|
127
128
|
stored = modstore.stored_files(name, files)
|
|
128
129
|
physical = {stored_name: data for stored_name, _, data in stored}
|
|
129
130
|
existing = remote_tree(dev, folder)
|
|
@@ -131,7 +132,10 @@ def push_package(dev, session, folder, name, files, verify=False):
|
|
|
131
132
|
remote = session.read(folder + '/' + LIST, optional=True) if LIST in held else None
|
|
132
133
|
same = held == {n: len(d) for n, d in physical.items()} and remote == physical[LIST]
|
|
133
134
|
if same and verify:
|
|
134
|
-
same = all(
|
|
135
|
+
same = all(
|
|
136
|
+
session.sha256(folder + '/' + rel, len(data)) == hashlib.sha256(data).digest()
|
|
137
|
+
for rel, data in physical.items()
|
|
138
|
+
)
|
|
135
139
|
result = dict(name=name, of=len(stored), sent=0, bytes=0, paths=[], removed=0)
|
|
136
140
|
if same:
|
|
137
141
|
return result
|
|
@@ -143,13 +143,32 @@ class Session:
|
|
|
143
143
|
check(code, 'list %s' % path)
|
|
144
144
|
return entries
|
|
145
145
|
|
|
146
|
-
def
|
|
146
|
+
def sha256(self, path, size=0, optional=False):
|
|
147
|
+
"""The SHA-256 digest of the file stored at path (None: missing, with optional); size: the bytes expected. Hashed
|
|
148
|
+
on the device (file.hash, 1.32: nothing comes back over USB), else read back whole and hashed here."""
|
|
149
|
+
if not host_write.hashes(self.dev):
|
|
150
|
+
data = self.read(path, optional)
|
|
151
|
+
return None if data is None else hashlib.sha256(data).digest()
|
|
152
|
+
self.command(1)
|
|
153
|
+
code, sha = host_write.stored_sha256(self.dev, path, size)
|
|
154
|
+
if optional and code == MISSING:
|
|
155
|
+
return None
|
|
156
|
+
check(code, 'hash %s' % path)
|
|
157
|
+
return sha
|
|
158
|
+
|
|
159
|
+
def put(self, path, data):
|
|
160
|
+
"""Writes data to path. The device checks the bytes it received (CRC-32, SHA-256) and the file it read back
|
|
161
|
+
(CRC-32) before it renames the file onto path (host_write.put)."""
|
|
147
162
|
self.command(1)
|
|
148
163
|
if depth.refusal(path):
|
|
149
164
|
raise StoreError(depth.refusal(path))
|
|
150
165
|
code = host_write.put(self.dev, data, path, say=lambda _: None)
|
|
151
166
|
check(code, 'write %s' % path)
|
|
152
|
-
|
|
167
|
+
|
|
168
|
+
def write(self, path, data):
|
|
169
|
+
"""put, then the stored file checked by its SHA-256."""
|
|
170
|
+
self.put(path, data)
|
|
171
|
+
if self.sha256(path, len(data)) != hashlib.sha256(data).digest():
|
|
153
172
|
raise StoreError('read-back SHA-256 differs: %s' % path)
|
|
154
173
|
|
|
155
174
|
def change(self, kind, path):
|
|
@@ -197,10 +216,11 @@ class Session:
|
|
|
197
216
|
live_hashes = set()
|
|
198
217
|
for sha, rel in references:
|
|
199
218
|
live_path = '/yaffs2/content/' + rel
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
219
|
+
want = bytes.fromhex(sha)
|
|
220
|
+
live = self.sha256(live_path, optional=True) if factory else None
|
|
221
|
+
if factory and rel == 'op1_factory.json' and live != want:
|
|
222
|
+
live = self.sha256(ROOT + '/content-official/op1_factory.json', optional=True)
|
|
223
|
+
if live == want:
|
|
204
224
|
live_hashes.add(sha)
|
|
205
225
|
continue
|
|
206
226
|
if sha in existing or sha in live_hashes:
|
|
@@ -220,7 +240,7 @@ class Session:
|
|
|
220
240
|
|
|
221
241
|
def publish(self, target, files, keep=()):
|
|
222
242
|
"""Publishes files ({rel: bytes}) as target. keep: rels the published target already holds with these bytes (the
|
|
223
|
-
caller checked them): moved over from it on the device after the rest is staged and
|
|
243
|
+
caller checked them): moved over from it on the device after the rest is staged and checked, never sent."""
|
|
224
244
|
if not package_name(target.rsplit('/', 1)[-1]):
|
|
225
245
|
raise StoreError('unsafe package name')
|
|
226
246
|
if not target.startswith((LIBRARY + '/', ROOT + '/mods/')):
|
|
@@ -232,10 +252,11 @@ class Session:
|
|
|
232
252
|
raise StoreError('package exceeds storage depth')
|
|
233
253
|
sent = {rel: data for rel, data in files.items() if rel not in keep}
|
|
234
254
|
for rel, data in sorted(sent.items()):
|
|
235
|
-
self.
|
|
236
|
-
#
|
|
255
|
+
self.put(scratch + '/' + rel, data)
|
|
256
|
+
# Check the entire staged result, as stored now, before the sole publication rename: one SHA-256 per file, hashed
|
|
257
|
+
# on the device from 1.32 (#327), else read back over USB.
|
|
237
258
|
for rel, data in sorted(sent.items()):
|
|
238
|
-
if self.
|
|
259
|
+
if self.sha256(scratch + '/' + rel, len(data)) != hashlib.sha256(data).digest():
|
|
239
260
|
raise StoreError('staged package changed: %s' % rel)
|
|
240
261
|
old = scratch + '-old'
|
|
241
262
|
parent, name = target.rsplit('/', 1)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Generated by scripts/protogen.py from protocol/v1.json: do not edit.
|
|
2
2
|
|
|
3
|
-
XY Forever serial protocol 1.
|
|
3
|
+
XY Forever serial protocol 1.32 (docs/PROTOCOL.md): constants, message types, status codes and
|
|
4
4
|
field tables. A field is (name, type, bytes, optional, encoding): type u8/u16/u32/bytes/cstr/
|
|
5
5
|
text/rest, bytes the size of a fixed field (None for cstr/text/rest), encoding ascii/utf-8 for
|
|
6
6
|
cstr/text (None otherwise); optional fields come last, all present or none. Reply fields follow
|
|
@@ -11,7 +11,7 @@ Replies and events are decoded leniently (bytes after the known fields are ignor
|
|
|
11
11
|
extensible=False layout ends in rest/text and never gains fields.
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
|
-
VERSION = '1.
|
|
14
|
+
VERSION = '1.32'
|
|
15
15
|
MAGIC = b'XF'
|
|
16
16
|
HEADER_BYTES = 8
|
|
17
17
|
TRAILER_BYTES = 4
|
|
@@ -46,6 +46,7 @@ COPY_FILE = 0x19 # file.copy
|
|
|
46
46
|
WRITE_BEGIN = 0x1a # file.write_begin
|
|
47
47
|
WRITE_DATA = 0x1b # file.write_data
|
|
48
48
|
WRITE_END = 0x1c # file.write_end
|
|
49
|
+
HASH_FILE = 0x1d # file.hash
|
|
49
50
|
INSTALL = 0x20 # boot.install
|
|
50
51
|
UNINSTALL = 0x21 # boot.uninstall
|
|
51
52
|
REBOOT = 0x30 # device.reboot
|
|
@@ -119,7 +120,7 @@ HELLO_PREFIX = 'XYF1'
|
|
|
119
120
|
HELLO_KEYS = (
|
|
120
121
|
('service', '1.0', 'fixed', 'usb'),
|
|
121
122
|
('role', '1.0', 'fixed', 'b'),
|
|
122
|
-
('proto', '1.0', 'fixed', '1.
|
|
123
|
+
('proto', '1.0', 'fixed', '1.32'),
|
|
123
124
|
('install', '1.0', 'fixed', 'stock-88a06a7e'),
|
|
124
125
|
('version', '1.15', 'release', None),
|
|
125
126
|
('image', '1.15', 'image', None),
|
|
@@ -269,6 +270,13 @@ COMMANDS = {
|
|
|
269
270
|
request=(),
|
|
270
271
|
reply_size=(12, 12), reply_on_error='full', reply_extensible=True,
|
|
271
272
|
reply=(('written', 'u32', 4, False, None), ('readback_crc', 'u32', 4, False, None), ('error', 'u32', 4, False, None))),
|
|
273
|
+
0x1d: dict(
|
|
274
|
+
name='file.hash', symbol='hash_file', cls='product', test_only=False, switch='XYF_USB_FILE_WRITE',
|
|
275
|
+
destructive=False, timeout_ms=120000, errors=('bad_request', 'refused', 'link', 'storage', 'not_found', 'too_large'),
|
|
276
|
+
request_size=(10, 240), request_ignored=False,
|
|
277
|
+
request=(('path', 'cstr', None, False, 'utf-8'),),
|
|
278
|
+
reply_size=(36, 36), reply_on_error='status', reply_extensible=True,
|
|
279
|
+
reply=(('size', 'u32', 4, False, None), ('sha256', 'bytes', 32, False, None))),
|
|
272
280
|
0x20: dict(
|
|
273
281
|
name='boot.install', symbol='install', cls='product', test_only=False, switch=None,
|
|
274
282
|
destructive=True, timeout_ms=900000, errors=('state', 'sha', 'image', 'link', 'too_large', 'install'),
|
|
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
|