File dkms-bbswitch.spec of Package dkms-bbswitch
#
# spec file for package dkms-bbswitch
#
#
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via bumblebee.obs@gmail.com
#
# norootforbuild
#
%define modname bbswitch
Name: dkms-%{modname}
Summary: Kernel module allowing to switch dedicated graphics on Optimus laptops
Version: 0.8
Release: 0.1
URL: http://github.com/Bumblebee-Project/bbswitch
Group: System/Kernel
License: GPL-2.0
Vendor: The Bumblebee Project
Source0: %{modname}-%{version}.tar.gz
Source1: %{modname}.conf
Patch0: %{modname}-%{version}.patch
%if 0%{?sle_version} >= 150600 && 0%{?is_opensuse}
Patch1: fix-deprecated-acpi_bus_get_device-in-5.18.patch
%endif
Source1000: %{name}-rpmlintrc
%if 0%{?suse_version}
Conflicts: bbswitch-kmp-default
Conflicts: bbswitch-kmp-desktop
Conflicts: bbswitch-kmp-pae
Conflicts: bbswitch-kmp-xen
Conflicts: bbswitch-kmp
%endif
Requires: binutils gcc make
%if 0%{?mdkversion}
Requires: dkms-minimal
%else
Requires: dkms
%endif
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
This package contains linux kernel module for switching Nvidia-Optimus
wrapped for the DKMS framework.
%prep
%setup -q -n %{modname}-%{version}
%patch0 -p1
%if 0%{?sle_version} >= 150600 && 0%{?is_opensuse}
%patch1 -p1
%endif
%build
%install
rm -rf %{buildroot}
#
install -d -m 755 %{buildroot}/usr/src/%{modname}-%{version}-%{release}
install -m 644 Makefile %{buildroot}/usr/src/bbswitch-%{version}-%{release}/Makefile
install -m 644 bbswitch.c %{buildroot}/usr/src/bbswitch-%{version}-%{release}/bbswitch.c
#
cat > %{buildroot}/usr/src/%{modname}-%{version}-%{release}/dkms.conf << EOF
PACKAGE_NAME=%{modname}
PACKAGE_VERSION=%{version}-%{release}
MAKE[0]="make KVERSION=\$kernelver"
DEST_MODULE_LOCATION[0]="/updates/"
BUILT_MODULE_NAME[0]=%{modname}
AUTOINSTALL="yes"
NO_WEAK_MODULES="yes"
EOF
#
install -d -m 755 %{buildroot}/etc/modprobe.d
install -m 755 %{SOURCE1} %{buildroot}/etc/modprobe.d/50-bbswitch.conf
%clean
rm -rf %{buildroot}
%post
if [ -x /usr/sbin/dkms ] && [ -z "`/usr/sbin/dkms status -m %{modname} -v %{version}-%{release}`" ] ; then
/usr/sbin/dkms add -m %{modname} -v %{version}-%{release} --rpm_safe_upgrade || :
/usr/sbin/dkms build -m %{modname} -v %{version}-%{release} || :
/usr/sbin/dkms install -m %{modname} -v %{version}-%{release} || :
#
if [ -e /sbin/depmod ] && [ -x /usr/bin/dracut ] ; then
/sbin/depmod -a "$(uname -r)"
/usr/bin/dracut -f --kver "$(uname -r)"
fi
fi
%preun
# rmmod can fail
if [ -x /sbin/rmmod ] ; then
/sbin/rmmod %{modname} >/dev/null 2>&1 || :
fi
#
if [ -x /usr/sbin/dkms ] && [ -n "`/usr/sbin/dkms status -m %{modname} -v %{version}-%{release}`" ] ; then
/usr/sbin/dkms remove -m %{modname} -v %{version}-%{release} --all --rpm_safe_upgrade || :
fi
%files
%defattr(-,root,root)
%dir /etc/modprobe.d
%dir /usr/src/%{modname}-%{version}-%{release}
/usr/src/%{modname}-%{version}-%{release}/*
/etc/modprobe.d/50-bbswitch.conf
%changelog