Files
zosbuilder/test-initramfs.sh

73 lines
2.1 KiB
Bash

#!/bin/bash
set -e
echo "[+] Quick initramfs rebuild test..."
# Run just the initramfs setup in the existing container
docker run --rm \
-v "$(pwd)/scripts:/build/scripts" \
-v "$(pwd)/configs:/build/configs" \
-v "$(pwd)/output:/build/output" \
-v "$(pwd)/configs/zinit:/mnt/zinit" \
zero-os-alpine-builder:latest \
/bin/sh -c "
echo '[+] Setting up build environment...'
source /build/build.conf
# Only run the Alpine package installation and initramfs setup
echo '[+] Installing packages...'
/build/scripts/install-packages.sh
echo '[+] Setting up initramfs...'
/build/scripts/setup-initramfs.sh
echo '[+] Quick initramfs rebuild complete!'
ls -la /build/output/initramfs.*
"
echo "[+] Testing initramfs structure..."
echo "Checking for symlink loops in the initramfs..."
# Extract and examine the initramfs structure
cd output
if [ -f "initramfs.cpio" ]; then
mkdir -p test-extract
cd test-extract
cpio -idmv < ../initramfs.cpio >/dev/null 2>&1
echo "=== Checking /run and /var/run structure ==="
if [ -L "run" ]; then
echo "/run is a symlink to: $(readlink run)"
elif [ -d "run" ]; then
echo "/run is a directory"
else
echo "/run does not exist"
fi
if [ -L "var/run" ]; then
echo "/var/run is a symlink to: $(readlink var/run)"
elif [ -d "var/run" ]; then
echo "/var/run is a directory"
else
echo "/var/run does not exist"
fi
# Check for circular symlinks
echo "=== Checking for symlink loops ==="
if [ -L "run" ] && [ -L "var/run" ]; then
run_target=$(readlink run)
var_run_target=$(readlink var/run)
echo "Symlinks: /run -> $run_target, /var/run -> $var_run_target"
if [[ "$run_target" == *"var/run"* ]] && [[ "$var_run_target" == *"run"* ]]; then
echo "❌ CIRCULAR SYMLINK DETECTED!"
else
echo "✅ No circular symlinks detected"
fi
fi
cd ..
rm -rf test-extract
fi
echo "[+] Quick test complete!"