#!/bin/bash # ============================================================================ # DarkForge Linux — Phase 3, Chapter 8.8: XZ Utils # ============================================================================ # Purpose: Build and install XZ utils (LZMA compression). # Needed for extracting and compressing .tar.xz archives. # Inputs: /sources/xz-5.8.1.tar.gz (from Phase 0 download as xz-5.8.1) # Outputs: /usr/bin/xz, /usr/lib/liblzma.so # Ref: LFS 13.0 §8.8 # ============================================================================ set -euo pipefail source /sources/toolchain-scripts/100-chroot-env.sh PACKAGE="xz" VERSION="5.8.1" echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ===" # The download may be named xz-5.8.1.tar.gz (from github releases) # Check for the tarball if [ -f "/sources/${PACKAGE}-${VERSION}.tar.gz" ]; then pkg_extract "${PACKAGE}-${VERSION}.tar.gz" elif [ -f "/sources/${PACKAGE}-${VERSION}.tar.xz" ]; then pkg_extract "${PACKAGE}-${VERSION}.tar.xz" else echo "FAIL: Could not find xz tarball" exit 1 fi cd "${PACKAGE}-${VERSION}" # Configure xz for the target system ./configure --prefix=/usr \ --disable-static \ --docdir=/usr/share/doc/xz-${VERSION} # Build xz make # Run tests (optional but recommended) make check || true # Install xz make install # Verify installation if [ -x /usr/bin/xz ]; then echo "PASS: xz binary installed" else echo "FAIL: xz binary not found" exit 1 fi if [ -f /usr/lib/liblzma.so ]; then echo "PASS: liblzma.so installed" else echo "FAIL: liblzma.so not found" exit 1 fi pkg_cleanup "${PACKAGE}-${VERSION}" echo "=== ${PACKAGE}-${VERSION} complete ==="