#!/bin/bash # ============================================================================ # DarkForge Linux — Phase 0, Chapter 6: File # ============================================================================ # Purpose: Cross-compile the file utility (determines file types via # magic numbers). Some build systems use file during configure. # Inputs: ${LFS}/sources/file-5.47.tar.gz # Outputs: file binary in ${LFS}/usr/bin/ # Ref: LFS 13.0 §6.7 # ============================================================================ set -euo pipefail source "${LFS}/sources/darkforge-env.sh" PACKAGE="file" VERSION="5.47" SRCDIR="${LFS}/sources" echo "=== Building ${PACKAGE}-${VERSION} (Temporary Tool) ===" cd "${SRCDIR}" tar -xf "${PACKAGE}-${VERSION}.tar.gz" cd "${PACKAGE}-${VERSION}" # Build a host-native 'file' first — needed during cross-compilation mkdir build pushd build ../configure --disable-bzlib --disable-libseccomp \ --disable-xzlib --disable-zlib make popd ./configure \ --prefix=/usr \ --host="${LFS_TGT}" \ --build="$(./config.guess)" make FILE_COMPILE="$(pwd)/build/src/file" make DESTDIR="${LFS}" install # Remove libtool archive rm -v "${LFS}/usr/lib/libmagic.la" 2>/dev/null || true cd "${SRCDIR}" rm -rf "${PACKAGE}-${VERSION}" echo "=== ${PACKAGE}-${VERSION} complete ==="