#!/usr/bin/env bash # SPDX-License-Identifier: GPL-2.0-only # # rtw89-steam-frame - standalone DKMS package register/installer. # # Pulls the steam-frame patches from upstream (Davenport-Physics/rtw89-steam-frame) # via git, stages the package into /usr/src, and runs dkms add/build/install so the # patched rtw89 modules are kept working and auto-rebuilt on every kernel upgrade. # # Run as root (one password prompt): run0 bash register.sh # Overrides (env): # RTW89_UPSTREAM= (default: https://github.com/Davenport-Physics/rtw89-steam-frame) # RTW89_UPSTREAM_REF= (default: master) # RTW89_KVER= (default: $(uname -r)) set -euo pipefail PACKAGE_NAME="rtw89-steam-frame" VERSION="0.1" UPSTREAM="${RTW89_UPSTREAM:-https://github.com/Davenport-Physics/rtw89-steam-frame}" UPSTREAM_REF="${RTW89_UPSTREAM_REF:-master}" KVER="${RTW89_KVER:-$(uname -r)}" HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" DST="/usr/src/$PACKAGE_NAME-$VERSION" for c in git dkms curl patch make gcc modinfo depmod; do command -v "$c" >/dev/null || { echo "error: '$c' not found"; exit 1; } done [ -d "/lib/modules/$KVER/build" ] || { echo "error: headers for $KVER not installed (install linux-headers)"; exit 1; } [ "$(id -u)" -eq 0 ] || { echo "error: run as root ('sudo ./register.sh')"; exit 1; } TMP="$(mktemp -d)" trap 'rm -rf "$TMP"' EXIT echo "== [1/5] pull patches from $UPSTREAM (@$UPSTREAM_REF)" git clone --quiet --depth 1 --branch "$UPSTREAM_REF" --single-branch "$UPSTREAM" "$TMP/upstream" ls "$TMP/upstream/patches/"*.patch >/dev/null 2>&1 || { echo "error: upstream has no patches/"; exit 1; } echo "== [2/5] stage package -> $DST (kernel: $KVER)" mkdir -p "$DST/patches" cp "$HERE/dkms.conf" "$HERE/build.sh" "$DST/" cp "$TMP/upstream/patches/"*.patch "$DST/patches/" chmod +x "$DST/build.sh" echo "== [3/5] dkms add (dropping any previous registration first)" dkms status | grep -q "^$PACKAGE_NAME/$VERSION" && dkms remove "$PACKAGE_NAME/$VERSION" --all || true dkms add "$DST" echo "== [4/5] dkms build + install -k $KVER" dkms build "$PACKAGE_NAME/$VERSION" -k "$KVER" dkms install "$PACKAGE_NAME/$VERSION" -k "$KVER" echo "== [5/5] verify" dkms status "$PACKAGE_NAME/$VERSION" echo " modinfo -n rtw89_core -> $(modinfo -n rtw89_core)" echo " installed: $(ls /lib/modules/$KVER/updates/dkms/rtw89_*.ko.zst 2>/dev/null | tr '\n' ' ')" echo echo "REGISTER DONE - patches @$UPSTREAM_REF ($(git -C "$TMP/upstream" rev-parse --short HEAD))"