aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Serov <me@cab404.ru>2021-09-16 01:31:47 +0300
committerGitHub <noreply@github.com>2021-09-15 18:31:47 -0400
commit4b5d1c85c01db789da08390f7c87799d5fd7cf51 (patch)
tree57fc821c9fa2ff13977fe6eca82e5bdfcbc888b9
parent8cf1b512233857ec74a4a8fb9ed3245b3daac84b (diff)
downloadkutter-4b5d1c85c01db789da08390f7c87799d5fd7cf51.tar.gz
kutter-4b5d1c85c01db789da08390f7c87799d5fd7cf51.tar.xz
kutter-4b5d1c85c01db789da08390f7c87799d5fd7cf51.zip
update_chitu: generating update uuid based on file hash (#4663)
This makes update_chitu a pure function: same file in — same file out. That's something I need to make Nix builds for firmware itself reproducible. Signed-off-by: Vladimir Serov <me@cab404.ru>
-rwxr-xr-xscripts/update_chitu.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/scripts/update_chitu.py b/scripts/update_chitu.py
index 2da78276..1d993b46 100755
--- a/scripts/update_chitu.py
+++ b/scripts/update_chitu.py
@@ -6,10 +6,10 @@
# Licensed under GPL-3.0
import os
-import random
import struct
import uuid
import sys
+import hashlib
def calculate_crc(contents, seed):
accumulating_xor_value = seed;
@@ -69,7 +69,9 @@ def encode_file(input, output_file, file_length):
block_size = 0x800
key_length = 0x18
- uid_value = uuid.uuid4()
+ file_digest = hashlib.md5(input_file).digest()
+ uid_value = uuid.UUID(bytes=file_digest)
+ print("Update UUID ", uid_value)
file_key = int(uid_value.hex[0:8], 16)
xor_crc = 0xef3d4323;