#!/bin/bash -e

# Pre-chroot script: Copy LED patch into the rootfs
# This runs on the host before the chroot script

# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"

PATCH_SRC="${SCRIPT_DIR}/led-pwm-control.patch"
PATCH_DST="${ROOTFS_DIR}/tmp/led-pwm-control.patch"

if [ -f "$PATCH_SRC" ]; then
    echo "Copying LED PWM control patch to rootfs..."
    cp "$PATCH_SRC" "$PATCH_DST"
    echo "✓ Patch copied to $PATCH_DST"
else
    echo "✗ WARNING: LED patch not found at $PATCH_SRC"
fi
