81 lines
2.6 KiB
Bash
Executable File
81 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Ubuntu HWE 6.17: apply SOF iDisp HDMI experiment patch (0002), build generic debs, optional install.
|
|
# Run on Ubuntu (Noble or host with linux-hwe-6.17 sources); requires sudo for apt/dpkg.
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
PATCH="${PATCH:-$REPO_ROOT/patches/ubuntu-hwe-6.17/0002-ASoC-intel-sof-idisp-hdmi-dpcm-trigger-post.patch}"
|
|
SRC="${SRC:-$REPO_ROOT/kernel-src/linux-hwe-6.17-6.17.0}"
|
|
JOBS="${CONCURRENCY_LEVEL:-$(nproc)}"
|
|
|
|
usage() {
|
|
echo "Usage: $0 [apply|deps|build|install|all]"
|
|
echo " apply - patch -p1 in SRC (PATCH=$PATCH)"
|
|
echo " deps - sudo apt build-dep linux-hwe-6.17 + build tools"
|
|
echo " build - fakeroot debian/rules clean && binary-generic"
|
|
echo " install- sudo dpkg -i newest linux-image-* and linux-modules-* in parent of SRC"
|
|
echo " all - apply deps build (install is manual: run install after reviewing debs)"
|
|
echo "Env: PATCH=path SRC=path to linux-hwe-6.17-6.17.0 tree"
|
|
}
|
|
|
|
if [[ ! -f "$SRC/debian/rules" ]]; then
|
|
echo "ERROR: kernel source not found at SRC=$SRC"
|
|
exit 1
|
|
fi
|
|
|
|
cmd_apply() {
|
|
cd "$SRC"
|
|
local f="sound/soc/intel/boards/sof_board_helpers.c"
|
|
if grep -q 'link->trigger\[0\] = SND_SOC_DPCM_TRIGGER_POST' "$f" 2>/dev/null; then
|
|
echo "Already patched: $f"
|
|
else
|
|
patch -p1 < "$PATCH"
|
|
fi
|
|
grep -n 'set_idisp_hdmi_link\|playback_only\|trigger\[0\]' "$f" | head -25 || true
|
|
}
|
|
|
|
cmd_deps() {
|
|
sudo apt-get update
|
|
sudo apt-get build-dep -y linux-hwe-6.17
|
|
sudo apt-get install -y fakeroot build-essential libncurses-dev libssl-dev ccache \
|
|
gawk debhelper libelf-dev flex bison bc python3-dev
|
|
}
|
|
|
|
cmd_build() {
|
|
cd "$SRC"
|
|
export CONCURRENCY_LEVEL="$JOBS"
|
|
fakeroot debian/rules clean
|
|
fakeroot debian/rules binary-generic
|
|
}
|
|
|
|
cmd_install() {
|
|
parent="$(dirname "$SRC")"
|
|
cd "$parent"
|
|
mapfile -t imgs < <(ls -t linux-image-*.deb 2>/dev/null || true)
|
|
mapfile -t mods < <(ls -t linux-modules-*.deb 2>/dev/null || true)
|
|
if [[ ${#imgs[@]} -eq 0 || ${#mods[@]} -eq 0 ]]; then
|
|
echo "No linux-image-*.deb or linux-modules-*.deb in $parent — build first."
|
|
exit 1
|
|
fi
|
|
echo "Installing: ${imgs[0]} ${mods[0]}"
|
|
sudo dpkg -i "${imgs[0]}" "${mods[0]}"
|
|
echo "Optional: sudo dpkg -i linux-headers-*.deb from same directory"
|
|
echo "Then: sudo reboot"
|
|
}
|
|
|
|
case "${1:-}" in
|
|
apply) cmd_apply ;;
|
|
deps) cmd_deps ;;
|
|
build) cmd_build ;;
|
|
install) cmd_install ;;
|
|
all)
|
|
cmd_apply
|
|
cmd_deps
|
|
cmd_build
|
|
echo "Build done. Debs should be in: $(dirname "$SRC")"
|
|
echo "Run: $0 install (after reviewing package names)"
|
|
;;
|
|
*) usage; exit 1 ;;
|
|
esac
|