You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ONIE still shipped python2-only code throughout the tree. Port every
python asset to python3 so the build no longer needs a python2
interpreter (a prerequisite for moving to a modern Debian build host)
and so nothing in contrib/ or the machine tests is left on a dead
runtime. This change deliberately does NOT touch the CI Dockerfile, so
the cross-toolchain cache key is preserved (the Debian-13 build-host
bump is deferred to the toolchain-upgrade step, where it must land
alongside crosstool-NG/GCC -- the current GCC 8.3.0 toolchain cannot be
built on a GCC 14 host).
Build path:
- build-config/scripts/mk-part-table.py (the only python invoked by
the image build -- it writes the recovery ISO MBR partition table):
env python3 shebang, integer division (/ -> //) so CHS values stay
ints, and the ISO opened in binary mode ('r+b') so struct.pack()
bytes are written correctly. A shebang-only change is insufficient;
without the // and binary fixes the script silently writes a wrong
partition table under python3. Verified to emit a correct MBR
(0xaa55 signature, 0x80 boot flag, 0xEF EFI type) on a test image.
- build-config/Makefile: retarget $(PYTHON) from python2 to python3.
grub's autogen.sh invokes "${PYTHON:-python}", and a bare "python"
no longer exists once python2 is gone, so the build must export
PYTHON=python3 (grub's gentpl.py/import_gcry.py are python3-safe).
The old block only set PYTHON=python2 when "python" was absent;
replace it with an exported `PYTHON ?= python3`. Also switch
DEBIAN_BUILD_HOST_PACKAGES from python-all-dev/python-sphinx to
python3-all-dev/python3-sphinx.
Tooling and tests (mechanical 2to3, behaviour preserved):
- contrib/oce, contrib/onie-server, contrib/git-stats/gitdm (vendored),
and the machine/*/test DUT scripts: python3 shebangs; print()
functions; `except E, e` -> `except E as e`; iteritems/iterkeys/
itervalues -> items/keys/values; has_key -> `in`; raw_input -> input;
cStringIO/StringIO -> io; py2 stdlib renames (Queue->queue,
SimpleHTTPServer/SocketServer->http.server/socketserver, thread->
_thread); sort(cmp=...) -> key=cmp_to_key(...); list() wrapping of
views/maps that are indexed or sorted; onie-server.py spawns its
helpers with "python3" instead of "python".
- contrib/onie-server/proxy-server.py was cp1252-encoded; re-encode it
as UTF-8 and update the coding declaration so its (Portuguese)
comments survive the python3 port intact.
Every python file in the tree now passes `python3 -m py_compile`, all
shebang scripts use `#!/usr/bin/env python3`, and no python2-only syntax
remains.
Signed-off-by: Brad House <bhouse@nexthop.ai>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
0 commit comments