Added zlib

This commit is contained in:
2026-03-20 14:08:01 +01:00
parent 2ab24f9aea
commit bb5f9d05b3
4 changed files with 74 additions and 48 deletions

View File

@@ -75,6 +75,7 @@ echo "=== Chapter 7: Chroot Build Scripts ==="
echo ""
run_script "${SCRIPTS}/024-chroot-essentials.sh"
run_script "${SCRIPTS}/024a-zlib.sh"
run_script "${SCRIPTS}/025-gettext.sh"
run_script "${SCRIPTS}/026-bison.sh"
run_script "${SCRIPTS}/027-perl.sh"

View File

@@ -83,53 +83,13 @@ install -o root -g utmp -m 664 /dev/null /var/log/wtmp
echo "=== Essential files and symlinks created ==="
echo ""
# --- Verify compiler works inside chroot --------------------------------------
echo ">>> Verifying gcc works inside chroot..."
echo ">>> Checking gcc and ld are present..."
echo " gcc: $(ls /usr/bin/gcc 2>/dev/null && echo 'OK' || echo 'MISSING')"
echo " ld: $(ls /usr/bin/ld 2>/dev/null && echo 'OK' || echo 'MISSING')"
echo " ld-linux-x86-64.so.2: $(ls /lib64/ld-linux-x86-64.so.2 2>/dev/null && echo 'OK' || echo 'MISSING')"
echo " crt1.o: $(ls /usr/lib/crt1.o 2>/dev/null && echo 'OK' || echo 'MISSING')"
echo ""
# Show where gcc is
echo " which gcc: $(which gcc 2>&1 || echo 'NOT FOUND')"
echo " which cc: $(which cc 2>&1 || echo 'NOT FOUND')"
echo " which ld: $(which ld 2>&1 || echo 'NOT FOUND')"
echo " NOTE: gcc won't link until zlib is built (ld needs libz.so.1)."
echo " 024a-zlib.sh runs next to fix this."
echo ""
# Check for the dynamic linker
if [ -e /lib64/ld-linux-x86-64.so.2 ]; then
echo " /lib64/ld-linux-x86-64.so.2: EXISTS"
ls -la /lib64/ld-linux-x86-64.so.2
else
echo " WARNING: /lib64/ld-linux-x86-64.so.2 NOT FOUND"
echo " Checking /usr/lib..."
ls -la /usr/lib/ld-linux-x86-64.so.2 2>/dev/null || echo " /usr/lib/ld-linux-x86-64.so.2 NOT FOUND"
echo " Contents of /lib64/:"
ls -la /lib64/ 2>/dev/null || echo " /lib64 does not exist"
fi
echo ""
# Check for crt files
echo " crt1.o: $(find /usr/lib -name crt1.o 2>/dev/null || echo 'NOT FOUND')"
echo " crti.o: $(find /usr/lib -name crti.o 2>/dev/null || echo 'NOT FOUND')"
echo ""
# Try to compile a test program
echo " Testing: echo 'int main(){}' | gcc -x c - -o /tmp/test-gcc"
if echo 'int main(){}' | gcc -x c - -o /tmp/test-gcc 2>/tmp/gcc-test-error.log; then
echo " PASS: gcc can create executables"
rm -f /tmp/test-gcc
else
echo " FAIL: gcc cannot create executables!"
echo " Error output:"
cat /tmp/gcc-test-error.log
echo ""
echo " Trying with verbose output:"
echo 'int main(){}' | gcc -v -x c - -o /tmp/test-gcc 2>&1 | tail -30
echo ""
echo " gcc search dirs:"
gcc -print-search-dirs 2>&1 | head -10
exit 1
fi
rm -f /tmp/gcc-test-error.log
echo ""
echo "Next: Run the chroot build scripts (025-xxx) to build additional tools."
echo "Next: Build zlib, then the remaining chroot tools."

View File

@@ -0,0 +1,42 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 0, Chapter 7: Zlib (Chroot)
# ============================================================================
# Purpose: Build zlib inside the chroot. The binutils linker (ld) from pass 2
# was built with zlib support and dynamically links against libz.so.1.
# Without zlib installed, ld fails with:
# "error while loading shared libraries: libz.so.1"
# This must be the FIRST thing built in the chroot, before any
# package that needs to link (i.e., everything).
# Inputs: /sources/zlib-1.3.2.tar.xz
# Outputs: /usr/lib/libz.so.1
# Assumes: Running inside chroot
# ============================================================================
set -euo pipefail
PACKAGE="zlib"
VERSION="1.3.2"
echo "=== Building ${PACKAGE}-${VERSION} (Chroot — ld dependency) ==="
cd /sources
tar -xf "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
./configure --prefix=/usr
make
make install
# Verify libz.so.1 exists
if [ -f /usr/lib/libz.so.1 ]; then
echo " PASS: /usr/lib/libz.so.1 exists"
else
echo " FAIL: /usr/lib/libz.so.1 NOT FOUND after install!"
exit 1
fi
cd /sources
rm -rf "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="