#!/usr/bin/env python3 """env-patch.py IN OUT KEY=VALUE ... : set variables in a U-Boot env image (non-redundant: CRC32 LE of the data area, then NUL-separated vars, 00-padded). An empty VALUE deletes the variable. Size is kept; fails if it no longer fits.""" import sys, struct, zlib src, dst, sets = sys.argv[1], sys.argv[2], sys.argv[3:] d = open(src, 'rb').read() size = len(d) if struct.unpack(' size - 4: sys.exit(f'env too big: {len(data)} > {size - 4}') data += b'\x00' * (size - 4 - len(data)) open(dst, 'wb').write(struct.pack('