From 84400964edfbd17090bd5569ce4f2972164fde2a Mon Sep 17 00:00:00 2001 From: vxtls <187420201+vxtls@users.noreply.github.com> Date: Tue, 3 Mar 2026 19:10:38 -0500 Subject: [PATCH] fix(stage0-resume): wrap jump-resume init with dhcpcd bring-up before continuing scripts --- rootfs.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/rootfs.py b/rootfs.py index 485d0f93..4f1a3ebd 100755 --- a/rootfs.py +++ b/rootfs.py @@ -74,6 +74,7 @@ def update_stage0_image(image_path, mounted = True script = ''' import os +import re import shutil import sys @@ -108,6 +109,32 @@ lines.append("PAYLOAD_REQUIRED=False\\n") with open(config_path, "w", encoding="utf-8") as cfg: cfg.writelines(lines) +# Resumed jump init scripts look like "bash /steps*/N.sh" and miss network bring-up. +# Wrap only that form to keep normal /init behavior unchanged. +init_path = os.path.join(mountpoint, "init") +if os.path.isfile(init_path): + with open(init_path, "r", encoding="utf-8") as init_file: + init_text = init_file.read() + + if "dhcpcd --waitip=4" not in init_text: + resume_match = re.search( + r"^\\s*bash\\s+(/(?:steps|steps-guix)/[0-9]+\\.sh)\\s*$", + init_text, + re.MULTILINE, + ) + if resume_match: + resume_script = resume_match.group(1) + wrapped_init = f"""#!/usr/bin/bash +set -e +if command -v dhcpcd >/dev/null 2>&1; then + dhcpcd --waitip=4 || true +fi +exec bash {resume_script} +""" + with open(init_path, "w", encoding="utf-8") as init_file: + init_file.write(wrapped_init) + os.chmod(init_path, 0o755) + if build_guix_also: dest_steps_guix = os.path.join(mountpoint, "steps-guix") has_resume_scripts = False