Files
omarchy-pkgs/pkgbuilds/omarchy-ane-dkms/PKGBUILD
T
Joshua Warren 5ef9ebdcac omarchy-ane-dkms: check() passes on kernels with the in-tree ANE driver
dkms.conf sets BUILD_EXCLUSIVE_CONFIG="!CONFIG_DRM_ACCEL_ANE", so on a kernel
that ships the in-tree driver "dkms build" exits 77 and builds nothing.
check() treated that as a failure, and makepkg stopped in check().

check() now takes exit 77 as "no DKMS build" when the kernel's config sets
CONFIG_DRM_ACCEL_ANE, and prints it. After a build it lists ane.ko and
ane_t6021.ko from the DKMS tree. Every other dkms exit status still fails
check().
2026-10-03 13:52:22 -05:00

101 lines
4.3 KiB
Bash

# Maintainer: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
pkgname=omarchy-ane-dkms
_srcname=omarchy-ane
pkgver=0.4.2
pkgrel=1
pkgdesc='Apple Neural Engine driver for Apple Silicon Macs (DKMS)'
arch=('aarch64')
groups=('omarchy-platform-apple-silicon')
url='https://github.com/joshuaswarren/omarchy-ane'
license=('GPL-2.0-only OR MIT')
# dtc 1.7.1 is the first release that keeps a labelled node's phandle when it
# applies an overlay (libfdt 1fad0650, 61e88fdc). Arch's dtc carries epoch 1.
depends=('dkms' 'dtc>=1:1.7.1' 'python')
# libdrm: drm.h for libane, which omarchy-ane-run links statically.
makedepends=('dtc' 'libdrm')
checkdepends=('fakeroot' 'linux-aurora-headers')
optdepends=('linux-aurora-headers: build the modules for linux-aurora'
'linux-asahi-headers: build the modules for linux-asahi')
# ANE_ABI_MAJOR of ane.ko (ane/src/uapi/drm/ane_accel.h). omarchy-mlx depends on
# the ABI, not on a package version.
provides=('omarchy-ane-abi=1')
install=omarchy-ane-dkms.install
source=("$_srcname-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz")
sha256sums=('c26179882e1e78b446c8062a9826acca1776130f452ae970fd1fc9ca150a9566')
prepare() {
# The DKMS source tree: dkms.conf, ane/Makefile, ane/ane_stats_show.c,
# ane/include/, ane/src/ and ane/t6021/.
# PACKAGE_VERSION becomes /sys/module/ane/version.
local src="$_srcname-$pkgver" dst="dkms/$_srcname-$pkgver"
rm -rf dkms
install -d "$dst/ane"
cp -r "$src/dkms.conf" "$dst/"
cp -r "$src/ane/Makefile" "$src/ane/ane_stats_show.c" "$src/ane/include" \
"$src/ane/src" "$src/ane/t6021" "$dst/ane/"
sed -i "s/@PKGVER@/$pkgver/" "$dst/dkms.conf"
}
build() {
make -C "$_srcname-$pkgver/tools" ane-run
}
check() {
cd "$_srcname-$pkgver"
python tools/test_ane_dt.py
python tools/test_ane_firmware_fetch.py
python tools/test_ane_m2.py
python tools/test_ane_smoke.py
python tools/test_ane_probe.py
python tools/test_validate_ane_soc.py
python tools/test_promotion_check.py
local build=(/usr/lib/modules/*/build)
local kver=${build[0]%/build}
kver=${kver##*/}
rm -rf "$srcdir/check"
mkdir -p "$srcdir/check/dkms" "$srcdir/check/src"
local dkms_options=(--dkmstree "$srcdir/check/dkms" --sourcetree "$srcdir/check/src" -k "$kver")
fakeroot dkms "${dkms_options[@]}" add "$srcdir/dkms/$_srcname-$pkgver"
local rc=0
fakeroot dkms "${dkms_options[@]}" build "$_srcname/$pkgver" || rc=$?
case $rc in
0) ls "$srcdir/check/dkms/$_srcname/$pkgver/$kver"/*/module/{ane,ane_t6021}.ko* ;;
77)
# dkms.conf BUILD_EXCLUSIVE_CONFIG="!CONFIG_DRM_ACCEL_ANE": a kernel that
# ships the in-tree ANE driver keeps its own modules.
grep -qs '^CONFIG_DRM_ACCEL_ANE=[ym]' "${build[0]}"/{include/config/auto.conf,.config} ||
{ echo "check: dkms skipped $kver, which has no CONFIG_DRM_ACCEL_ANE" >&2; return 1; }
echo "check: no DKMS build: $kver ships the in-tree ANE driver (CONFIG_DRM_ACCEL_ANE)" ;;
*) return "$rc" ;;
esac
}
package() {
cd "$_srcname-$pkgver"
install -d "$pkgdir/usr/src"
cp -r --no-preserve=ownership "$srcdir/dkms/$_srcname-$pkgver" "$pkgdir/usr/src/"
install -Dm755 -t "$pkgdir/usr/bin" \
packaging/omarchy-ane-check packaging/omarchy-ane-dt \
packaging/omarchy-ane-firmware-fetch packaging/omarchy-ane-smoke
install -Dm755 tools/omarchy-ane-probe "$pkgdir/usr/bin/omarchy-ane-probe"
# omarchy-ane-smoke runs omarchy-ane-run from its own directory with these programs.
install -Dm755 tools/ane-run "$pkgdir/usr/bin/omarchy-ane-run"
install -Dm644 fixtures/h14-anec/add/program-0.anec \
"$pkgdir/usr/share/omarchy-ane/fixtures/h14-anec/add/program-0.anec"
install -Dm644 fixtures/h13-anec/add/program-0.anec \
"$pkgdir/usr/share/omarchy-ane/fixtures/h13-anec/add/program-0.anec"
install -Dm644 packaging/update-m1n1-dtbs "$pkgdir/usr/lib/omarchy-ane/update-m1n1-dtbs"
install -Dm644 -t "$pkgdir/usr/share/libalpm/hooks" \
packaging/90-omarchy-ane-dt.hook packaging/90-omarchy-ane-dt-remove.hook \
packaging/90-omarchy-ane-firmware.hook
# Overlays to /usr/share/omarchy-platform/dtb-overlays/PREFIX/omarchy-NAME.dtbo,
# and data/ane-soc/SOC.json to /usr/share/omarchy-ane/soc/. The data-only
# overlays compile as a check and are never installed.
packaging/build-dtbo "$pkgdir"
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}