File bbswitch.spec of Package bbswitch

#
# spec file for package bbswitch
#
# Copyright (c) 2017 SUSE LINUX 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 http://bugs.opensuse.org/
#


Name:           bbswitch
Version:        0.8
Release:        0
Summary:        Bumblebee ACPI kernel module
License:        GPL-2.0+
Group:          System/Kernel
Url:            http://github.com/Bumblebee-Project/bbswitch
Source0:        https://github.com/Bumblebee-Project/bbswitch/archive/v%{version}.tar.gz
BuildRequires:  %{kernel_module_package_buildreqs}
BuildRequires:  libelf-devel
BuildRequires:  systemd-devel
Requires:       bbswitch-kmp
# DKMSing this module has no point for us so obsolete the package
# Remove this after 13.2 release
Provides:       bbswitch-dkms = %{version}
Obsoletes:      bbswitch-dkms < %{version}
Provides:       dkms-bbswitch = %{version}
Obsoletes:      dkms-bbswitch < %{version}
ExclusiveArch:  %{ix86} x86_64
%kernel_module_package

%description
bbswitch is a kernel module which automatically detects the required
ACPI calls for two kinds of Optimus laptops.

%prep
%setup -q
set -- *
mkdir source
mv "$@" source/
mkdir obj

%build
for flavor in %{flavors_to_build}; do
        rm -rf obj/$flavor
        cp -r source obj/$flavor
        make %{?_smp_mflags} -C %{kernel_source $flavor} modules M=$PWD/obj/$flavor
done

%install
export INSTALL_MOD_PATH=%{buildroot}
export INSTALL_MOD_DIR=updates
for flavor in %{flavors_to_build}; do
        make -C %{kernel_source $flavor} modules_install M=$PWD/obj/$flavor
done
install -dm755 %{buildroot}%{_libexecdir}/modules-load.d
echo "bbswitch" >> %{buildroot}%{_libexecdir}/modules-load.d/bbswitch.conf
install -dm755 %{buildroot}%{_sysconfdir}/modprobe.d/
echo "options bbswitch load_state=0 unload_state=1" >> %{buildroot}%{_sysconfdir}/modprobe.d/50-bbswitch.conf

%files
%doc source/COPYING source/README.md source/NEWS
%dir %{_libexecdir}//modules-load.d
%config %{_libexecdir}/modules-load.d/bbswitch.conf
%config %{_sysconfdir}/modprobe.d/50-bbswitch.conf

%changelog