#!/usr/bin/env python3 """Copy a GPU addon (NGPUADD2, see UniXNU scripts/make-gpu-addon.py) and add the files of DIR below PREFIX. usage: addon-add-dir.py IN.bin OUT.bin PREFIX DIR [PREFIX DIR ...] [--addon FILE] Executables keep 0755, the rest 0644. --addon merges entries from another addon.""" import os import struct import sys import zlib from pathlib import Path def pad(b): return b + bytes(-len(b) % 8) def read(path): data = Path(path).read_bytes() assert data[:8] == b'NGPUADD2', 'not an addon' count = struct.unpack_from('