fix(resume): regenerate step scripts on stage0-image boot so manifest and break-after updates take effect

This commit is contained in:
vxtls 2026-03-07 15:11:26 -05:00
parent be9b32beae
commit 076a70976a
3 changed files with 43 additions and 3 deletions

View file

@ -186,11 +186,21 @@ with open(config_path, "w", encoding="utf-8") as cfg:
# Ensure resumed stage0-image init scripts have minimal early mounts and # Ensure resumed stage0-image init scripts have minimal early mounts and
# only restore networking after get_network has run. # only restore networking after get_network has run.
mount_marker = "# LB_STAGE0_EARLY_MOUNTS" mount_marker = "# LB_STAGE0_EARLY_MOUNTS"
regen_marker = "# LB_STAGE0_REGENERATE_SCRIPTS"
legacy_network_block = ( legacy_network_block = (
'if [ "${CHROOT}" = False ] && command -v dhcpcd >/dev/null 2>&1; then\\n' 'if [ "${CHROOT}" = False ] && command -v dhcpcd >/dev/null 2>&1; then\\n'
'dhcpcd --waitip=4 || true\\n' 'dhcpcd --waitip=4 || true\\n'
'fi\\n' 'fi\\n'
) )
regen_block = (
regen_marker + "\\n"
+ 'if [ -x /script-generator ] && [ -f /steps/manifest ]; then\\n'
+ '/script-generator /steps/manifest\\n'
+ 'fi\\n'
+ 'if [ -x /script-generator ] && [ -f /steps-guix/manifest ]; then\\n'
+ '/script-generator /steps-guix/manifest /steps\\n'
+ 'fi\\n'
)
gated_network_block = ( gated_network_block = (
'if [ -f /steps/env ]; then\\n' 'if [ -f /steps/env ]; then\\n'
'. /steps/env\\n' '. /steps/env\\n'
@ -226,6 +236,15 @@ for init_name in os.listdir(mountpoint):
if legacy_network_block in init_content and gated_network_block not in init_content: if legacy_network_block in init_content and gated_network_block not in init_content:
init_content = init_content.replace(legacy_network_block, gated_network_block) init_content = init_content.replace(legacy_network_block, gated_network_block)
if regen_marker not in init_content:
first_newline = init_content.find("\\n")
if first_newline != -1:
init_content = (
init_content[: first_newline + 1]
+ regen_block
+ init_content[first_newline + 1 :]
)
with open(init_path, "w", encoding="utf-8") as init_file: with open(init_path, "w", encoding="utf-8") as init_file:
init_file.write(init_content) init_file.write(init_content)

View file

@ -8,17 +8,20 @@ src_prepare() {
src_configure() { src_configure() {
local host_triplet pkg_config_path local host_triplet pkg_config_path
host_triplet="$(gcc -dumpmachine)" host_triplet="$(gcc -dumpmachine)"
pkg_config_path="${LIBDIR}/pkgconfig" pkg_config_path="${LIBDIR}/pkgconfig:${PREFIX}/lib/pkgconfig:${PREFIX}/share/pkgconfig"
PATH="${PREFIX}/bin:/usr/bin:/bin" \ PATH="${PREFIX}/bin:/usr/bin:/bin" \
PKG_CONFIG="/usr/bin/pkg-config" \
PKG_CONFIG_LIBDIR="${pkg_config_path}:${PREFIX}/lib/pkgconfig" \ PKG_CONFIG_LIBDIR="${pkg_config_path}:${PREFIX}/lib/pkgconfig" \
PKG_CONFIG_PATH="${pkg_config_path}:${PREFIX}/lib/pkgconfig" \ PKG_CONFIG_PATH="${pkg_config_path}:${PREFIX}/lib/pkgconfig" \
LD_LIBRARY_PATH="${LIBDIR}:${LD_LIBRARY_PATH}" \ LD_LIBRARY_PATH="${LIBDIR}:${PREFIX}/lib:${LD_LIBRARY_PATH}" \
./configure \ ./configure \
--prefix="${PREFIX}" \ --prefix="${PREFIX}" \
--libdir="${LIBDIR}" \ --libdir="${LIBDIR}" \
--host="${host_triplet}" \ --host="${host_triplet}" \
--build="${host_triplet}" --build="${host_triplet}" \
'--with-guile-site-dir=$(datarootdir)/guile/site/$(GUILE_EFFECTIVE_VERSION)' \
'--with-guile-site-ccache-dir=$(libdir)/guile/$(GUILE_EFFECTIVE_VERSION)/site-ccache'
} }
src_compile() { src_compile() {
@ -28,3 +31,20 @@ src_compile() {
src_install() { src_install() {
default_src_install default_src_install
} }
src_postprocess() {
local guile_site_path guile_site_ccache guile_core_ccache
default_src_postprocess
guile_site_path="${DESTDIR}${PREFIX}/share/guile/site/3.0:${PREFIX}/share/guile/site/3.0:${PREFIX}/share/guile/3.0"
guile_site_ccache="${DESTDIR}${LIBDIR}/guile/3.0/site-ccache:${LIBDIR}/guile/3.0/site-ccache"
guile_core_ccache="${LIBDIR}/guile/3.0/ccache"
PATH="${PREFIX}/bin:/usr/bin:/bin" \
GUILE_LOAD_PATH="${guile_site_path}" \
GUILE_LOAD_COMPILED_PATH="${guile_site_ccache}:${guile_core_ccache}" \
GUILE_SYSTEM_PATH="${guile_site_path}" \
GUILE_SYSTEM_COMPILED_PATH="${guile_site_ccache}:${guile_core_ccache}" \
"${PREFIX}/bin/guile" -c '(use-modules (semver)) (display "semver-module-ok\n")'
}

View file

@ -169,6 +169,7 @@ src_configure() {
probe_guile_module git probe_guile_module git
probe_guile_module zlib probe_guile_module zlib
probe_guile_module lzlib probe_guile_module lzlib
probe_guile_module semver
PATH="${PREFIX}/bin:/usr/bin:/bin" \ PATH="${PREFIX}/bin:/usr/bin:/bin" \
PKG_CONFIG="/usr/bin/pkg-config" \ PKG_CONFIG="/usr/bin/pkg-config" \