#!/usr/bin/env python3 """pad_for_optiplex.py — pad a UEFI bootloader PE for Optiplex 7010 The Optiplex 7010 AMI Aptio firmware rejects PEs smaller than ~160KB ("no bootable devices"). This pads the PE to match systemd-boot's size and sets SizeOfImage accordingly. """ import struct, sys, os def pad(path): try: with open(path, 'rb') as f: d = bytearray(f.read()) except IOError as e: print(f" ERROR: cannot read {path}: {e}") return False po = struct.unpack('= target: print(f" Already >= {target} bytes ({len(d)}), nothing to do") return True # Compute SizeOfImage: round current SizeOfImage to match file growth cur_si = struct.unpack('") sys.exit(1) if not pad(sys.argv[1]): sys.exit(1)