Integrate Red Bear boot and packaging updates

This commit is contained in:
2026-04-22 10:22:09 +01:00
parent dd68c4ba03
commit b5ae8b2760
77 changed files with 259225 additions and 16971 deletions
+53 -28
View File
@@ -5,7 +5,7 @@
# The resulting grub.efi chainloads the Redox bootloader.
#
# Output: /usr/lib/boot/grub.efi, /usr/lib/boot/grub.cfg
# Required local module: local/recipes/core/grub/modules/redoxfs.mod
# Required local source: ../grub-redoxfs/src/{redoxfs.c,redoxfs.h,seahash.c}
#
# Build: make r.grub
# Install into image (Phase 1): ./local/scripts/install-grub.sh build/x86_64/harddrive.img
@@ -37,6 +37,15 @@ for tool in gcc make bison flex; do
fi
done
# We patch Makefile.core.def for local RedoxFS support. Regenerate autotools
# files once to avoid version-skew failures in incremental rebuild rules.
for tool in autoreconf automake aclocal autoconf; do
if ! command -v "${tool}" &>/dev/null; then
echo "ERROR: Required host autotools component '${tool}' not found" >&2
exit 1
fi
done
# Out-of-tree build (GRUB requires this for some configurations)
mkdir -p "${COOKBOOK_BUILD}/grub-build" || exit 1
cd "${COOKBOOK_BUILD}/grub-build" || exit 1
@@ -44,6 +53,44 @@ cd "${COOKBOOK_BUILD}/grub-build" || exit 1
# GRUB release tarballs miss extra_deps.lst (normally generated by autogen.sh)
touch "${COOKBOOK_SOURCE}/grub-core/extra_deps.lst" || exit 1
# Inject local RedoxFS GRUB module source from sibling tree: ../grub-redoxfs
RBOS_ROOT="$(cd "${COOKBOOK_RECIPE}/../../../.." && pwd)"
GRUB_REDOXFS_ROOT="${RBOS_ROOT}/../grub-redoxfs"
GRUB_REDOXFS_SRC="${GRUB_REDOXFS_ROOT}/src"
for f in redoxfs.c redoxfs.h seahash.c; do
if [ ! -f "${GRUB_REDOXFS_SRC}/${f}" ]; then
echo "ERROR: missing ${GRUB_REDOXFS_SRC}/${f}" >&2
echo "grub-redoxfs source tree must exist at: ${GRUB_REDOXFS_ROOT}" >&2
exit 1
fi
done
cp "${GRUB_REDOXFS_SRC}/redoxfs.c" "${COOKBOOK_SOURCE}/grub-core/fs/redoxfs.c"
cp "${GRUB_REDOXFS_SRC}/seahash.c" "${COOKBOOK_SOURCE}/grub-core/fs/seahash.c"
cp "${GRUB_REDOXFS_SRC}/redoxfs.h" "${COOKBOOK_SOURCE}/grub-core/fs/redoxfs.h"
mkdir -p "${COOKBOOK_SOURCE}/include/grub"
cp "${GRUB_REDOXFS_SRC}/redoxfs.h" "${COOKBOOK_SOURCE}/include/grub/redoxfs.h"
echo "Injected GRUB RedoxFS sources from ${GRUB_REDOXFS_SRC}"
MAKEFILE_CORE_DEF="${COOKBOOK_SOURCE}/grub-core/Makefile.core.def"
if ! grep -q "name = redoxfs;" "${MAKEFILE_CORE_DEF}"; then
cat >> "${MAKEFILE_CORE_DEF}" <<'EOF'
module = {
name = redoxfs;
common = fs/redoxfs.c;
cflags = '-DGRUB_BUILD';
};
EOF
echo "Registered redoxfs module in Makefile.core.def"
fi
(
cd "${COOKBOOK_SOURCE}"
autoreconf -fiv
)
# Configure for host, targeting x86_64 EFI platform output.
# --target=x86_64 means "produce boot images for x86_64"
# --with-platform=efi means "EFI platform output"
@@ -118,34 +165,12 @@ for m in \
add_mod "${m}"
done
# RedoxFS module is mandatory for Red Bear GRUB first-class support.
# Prefer local tree artifact, then fall back to staged sysroot copy.
REDOXFS_MOD_CANDIDATES=(
"${COOKBOOK_RECIPE}/modules/redoxfs.mod"
"${COOKBOOK_SYSROOT}/usr/lib/grub/x86_64-efi/redoxfs.mod"
)
REDOXFS_MOD=""
for cand in "${REDOXFS_MOD_CANDIDATES[@]}"; do
if [ -f "${cand}" ]; then
REDOXFS_MOD="${cand}"
break
fi
done
if [ -z "${REDOXFS_MOD}" ]; then
echo "ERROR: redoxfs.mod not found." >&2
echo "Expected one of:" >&2
for cand in "${REDOXFS_MOD_CANDIDATES[@]}"; do
echo " - ${cand}" >&2
done
exit 1
fi
cp "${REDOXFS_MOD}" "${MOD_DIR}/redoxfs.mod"
echo "Using mandatory RedoxFS GRUB module: ${REDOXFS_MOD}"
if ! printf '%s\n' "${SELECTED_MODULES[@]}" | grep -qx "redoxfs"; then
if has_mod "redoxfs"; then
SELECTED_MODULES+=("redoxfs")
else
echo "ERROR: redoxfs.mod was not produced by GRUB build" >&2
echo "Expected at: ${MOD_DIR}/redoxfs.mod" >&2
exit 1
fi
if [ "${#SELECTED_MODULES[@]}" -eq 0 ]; then