%global commit 2d9c27b6af3fb0a1947fa8c6607a2781c5e51195 %global shortcommit %(c=%{commit}; echo ${c:0:7}) %define buildforkernels akmod %define debug_package %{nil} Name: nvhda-kmod Version: 1.0 Release: 1.git%{shortcommit}%{?dist} Summary: Kernel module for powering off discrete GPU on Optimus laptops License: GPLv2+ URL: https://github.com/hhfeuer/nvhda Source0: https://github.com/hhfeuer/nvhda/archive/%{commit}/nvhda-%{shortcommit}.tar.gz BuildRequires: kmodtool %{expand:%(kmodtool --target %{_target_cpu} %{?repo:--repo %{?repo}} --kmodname %{name} %{?buildforkernels:--%{buildforkernels}} %{?kernels:--for-kernels "%{?kernels}"} 2>/dev/null) } %description Linux kernel module to turn on/off Nvidia HD audio device on notebooks. Blatantly copied from Lekensteyn's bbswitch module. This package contains the nvhda kernel module for kernel %{kversion}. %package common Summary: Common files for nvhda kernel module Requires: %{name} = %{version}-%{release} BuildArch: noarch %description common This package contains the common files (license, documentation, etc.) for the nvhda kernel module. %prep %setup -q -T -c tar xf %{SOURCE0} # For common package cp nvhda-%{commit}/{COPYING,README.md} . %{?kmodtool_check} kmodtool --target %{_target_cpu} %{?repo:--repo %{?repo}} --kmodname %{name} %{?buildforkernels:--%{buildforkernels}} %{?kernels:--for-kernels "%{?kernels}"} 2>/dev/null for kernel_version in %{?kernel_versions}; do cp -al nvhda-%{commit} _kmod_build_${kernel_version%%___*} done %build for kernel_version in %{?kernel_versions}; do make %{?_smp_mflags} \ -C "${kernel_version##*___}" \ M=${PWD}/_kmod_build_${kernel_version%%___*} \ modules done %install for kernel_version in %{?kernel_versions}; do install -D -m 0755 _kmod_build_${kernel_version%%___*}/nvhda.ko \ %{buildroot}%{kmodinstdir_prefix}/${kernel_version%%___*}/%{kmodinstdir_postfix}/nvhda.ko done %{?akmod_install} %files common %doc README.md %license COPYING %changelog * Sun Apr 30 2023 Pavel Artsishevsky - 1.0-1 - Initial release