fix script
This commit is contained in:
parent
fd2df1ece5
commit
07da0122b5
|
|
@ -26,14 +26,22 @@ if [ ! -f "$CONFIG" ]; then
|
|||
echo "Could not find $CONFIG" >&2
|
||||
exit 1
|
||||
fi
|
||||
FIRMWARE_DIR="$(dirname "$CONFIG")"
|
||||
|
||||
OVERLAYS="/boot/firmware/overlays"
|
||||
# Ubuntu 25.10+ piboot-try layout sets "os_prefix=current/" (or similar) in
|
||||
# config.txt, and the firmware reads overlays from that prefix. Older layouts
|
||||
# (e.g. Ubuntu 24.04, Raspberry Pi OS) read directly from <firmware>/overlays.
|
||||
OS_PREFIX="$(awk -F= '/^[[:space:]]*os_prefix[[:space:]]*=/ { gsub(/[[:space:]]/,"",$2); print $2; exit }' "$CONFIG")"
|
||||
if [ -n "$OS_PREFIX" ]; then
|
||||
OVERLAYS="${FIRMWARE_DIR}/${OS_PREFIX%/}/overlays"
|
||||
else
|
||||
OVERLAYS="${FIRMWARE_DIR}/overlays"
|
||||
fi
|
||||
mkdir -p "$OVERLAYS"
|
||||
|
||||
RESTORE_HELPER="/usr/local/sbin/barepi-audio-restore"
|
||||
RESTORE_SERVICE="/etc/systemd/system/barepi-audio-restore.service"
|
||||
MODULES_LOAD_FILE="/etc/modules-load.d/barepi-audio.conf"
|
||||
NEED_KERNEL_REBOOT=0
|
||||
|
||||
have_audio_modules() {
|
||||
modinfo snd-soc-simple-card >/dev/null 2>&1 \
|
||||
|
|
@ -41,19 +49,10 @@ have_audio_modules() {
|
|||
&& modinfo snd-soc-ics43432 >/dev/null 2>&1
|
||||
}
|
||||
|
||||
install_pkg_if_available() {
|
||||
local pkg="$1"
|
||||
if apt-cache show "$pkg" >/dev/null 2>&1; then
|
||||
apt-get install -y "$pkg"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
echo "=== barepi audio setup ==="
|
||||
echo "User: $TARGET_USER Home: $TARGET_HOME"
|
||||
echo "Config: $CONFIG"
|
||||
echo "Overlays: $OVERLAYS"
|
||||
echo "Overlays: $OVERLAYS${OS_PREFIX:+ (os_prefix=$OS_PREFIX)}"
|
||||
echo ""
|
||||
|
||||
# 1. Install packages
|
||||
|
|
@ -63,38 +62,23 @@ apt-get install -y alsa-utils libasound2-plugins swh-plugins i2c-tools device-tr
|
|||
|
||||
if ! have_audio_modules; then
|
||||
KERNEL_MODULES_PKG="linux-modules-$(uname -r)"
|
||||
if install_pkg_if_available "$KERNEL_MODULES_PKG"; then
|
||||
if apt-cache show "$KERNEL_MODULES_PKG" >/dev/null 2>&1; then
|
||||
apt-get install -y "$KERNEL_MODULES_PKG"
|
||||
echo " Installed $KERNEL_MODULES_PKG"
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! have_audio_modules && [ -r /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
if [ "${ID:-}" = "ubuntu" ] && install_pkg_if_available linux-image-raspi-6.8; then
|
||||
install_pkg_if_available linux-headers-raspi-6.8 || true
|
||||
NEED_KERNEL_REBOOT=1
|
||||
echo " Installed Ubuntu raspi 6.8 kernel fallback for ASoC modules."
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! have_audio_modules; then
|
||||
if [ "$NEED_KERNEL_REBOOT" -eq 1 ]; then
|
||||
echo " Current kernel still lacks the required ASoC modules; continuing because a compatible kernel was installed." >&2
|
||||
echo " Reboot into the new kernel after setup completes." >&2
|
||||
else
|
||||
echo "Missing required audio kernel modules: snd-soc-simple-card, snd-soc-tlv320aic31xx, snd-soc-ics43432" >&2
|
||||
echo "Install a raspi kernel package that provides them, then rerun this script." >&2
|
||||
echo "Install a kernel package that provides them (e.g. linux-modules-\$(uname -r)) and rerun." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
{
|
||||
echo "i2c-dev"
|
||||
for mod in snd-soc-simple-card snd-soc-tlv320aic31xx snd-soc-ics43432; do
|
||||
if [ "$NEED_KERNEL_REBOOT" -eq 1 ] || modinfo "$mod" >/dev/null 2>&1; then
|
||||
echo "$mod"
|
||||
fi
|
||||
done
|
||||
echo "snd-soc-simple-card"
|
||||
echo "snd-soc-tlv320aic31xx"
|
||||
echo "snd-soc-ics43432"
|
||||
} > "$MODULES_LOAD_FILE"
|
||||
|
||||
modprobe i2c-dev || true
|
||||
|
|
@ -748,10 +732,7 @@ echo "=== Done ==="
|
|||
if [ "$CHANGED" -eq 1 ]; then
|
||||
echo "config.txt was modified."
|
||||
fi
|
||||
if [ "$NEED_KERNEL_REBOOT" -eq 1 ]; then
|
||||
echo "A compatible Ubuntu raspi kernel was installed."
|
||||
fi
|
||||
echo "Reboot to load the updated overlay and audio kernel/module state."
|
||||
echo "Reboot to load the updated overlay and audio module state."
|
||||
echo "Speaker routing defaults and mic GPIO defaults will be restored automatically after boot."
|
||||
echo "Manual speaker check/adjust: $TARGET_HOME/volume.sh"
|
||||
echo "Manual mic test: $TARGET_HOME/test-mics.sh"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user