Files
darkforge/toolchain/scripts/019-tar.sh
2026-03-20 12:03:59 +01:00

46 lines
1.3 KiB
Bash
Executable File

#!/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}"
# Cross-compile cache override: tar tests strnlen behavior at configure time.
./configure \
--prefix=/usr \
--host="${LFS_TGT}" \
--build="$(build-aux/config.guess)" \
ac_cv_func_strnlen_working=yes
make
make DESTDIR="${LFS}" install
cd "${SRCDIR}"
rm -rf "${TARDIR}"
echo "=== ${PACKAGE}-${VERSION} complete ==="