Files
darkforge/toolchain/scripts/109-file.sh
2026-03-20 15:09:30 +01:00

56 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.11: File
# ============================================================================
# Purpose: Build and install the file command and libmagic library.
# The file command determines file types by examining their content.
# libmagic is used by many programs for file type detection.
# Inputs: /sources/file-5.47.tar.gz
# Outputs: /usr/bin/file, /usr/lib/libmagic.so
# Ref: LFS 13.0 §8.11
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="file"
VERSION="5.47"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
# Configure file for the target system
./configure --prefix=/usr
# Build file
make
# Run tests (optional)
make check || true
# Install file
make install
# Verify installation
if [ -x /usr/bin/file ]; then
echo "PASS: file binary installed"
else
echo "FAIL: file binary not found"
exit 1
fi
if [ -f /usr/lib/libmagic.so ]; then
echo "PASS: libmagic.so installed"
else
echo "FAIL: libmagic.so not found"
exit 1
fi
# Test file command
/usr/bin/file /bin/bash > /dev/null && echo "PASS: file command works"
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="