#!/bin/bash # ============================================================================ # DarkForge Linux — Phase 0, Chapter 6: Tar # ============================================================================ # Purpose: Cross-compile GNU tar (archive utility). # Inputs: ${LFS}/sources/tar-latest.tar.xz (unversioned tarball from mirror) # Outputs: tar in ${LFS}/usr/bin/ # Ref: LFS 13.0 §6.15 # ============================================================================ set -euo pipefail source "${LFS}/sources/darkforge-env.sh" PACKAGE="tar" SRCDIR="${LFS}/sources" echo "=== Building ${PACKAGE} (Temporary Tool) ===" cd "${SRCDIR}" # The mirror provides tar-latest.tar.xz (unversioned). Auto-detect the # directory name inside the tarball. tar -xf tar-latest.tar.xz TARDIR=$(find . -maxdepth 1 -type d -name 'tar-[0-9]*' | head -1) if [ -z "${TARDIR}" ]; then echo "ERROR: Could not find tar-* directory after extraction" exit 1 fi VERSION="${TARDIR#./tar-}" echo " Detected version: ${VERSION}" cd "${TARDIR}" ./configure \ --prefix=/usr \ --host="${LFS_TGT}" \ --build="$(build-aux/config.guess)" make make DESTDIR="${LFS}" install cd "${SRCDIR}" rm -rf "${TARDIR}" echo "=== ${PACKAGE}-${VERSION} complete ==="