File bumblebee.spec of Package bumblebee

#
# spec file for package bumblebee
#
# Copyright (c) 2016 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:           bumblebee
Version:        3.2.1
Release:        0
Summary:        NVidia Optimus support for GNU/Linux aimed at stability
License:        GPL-3.0+
Group:          Hardware/Other
Url:            https://github.com/Bumblebee-Project/bumblebee
Source0:        http://bumblebee-project.org/%{name}-%{version}.tar.gz
Patch0:         nvidia-uvm-modeset-drm-support.patch
BuildRequires:  glib2-devel
BuildRequires:  help2man
BuildRequires:  pciutils
BuildRequires:  pkg-config
BuildRequires:  pwdutils
BuildRequires:  systemd
BuildRequires:  xorg-x11-libX11-devel
Requires:       VirtualGL
Requires:       pciutils
Requires:       primus
Requires:       pwdutils
Requires:       shadow
Requires:       sudo
Requires:       xorg-x11-libX11
Recommends:     bbswitch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%{?systemd_requires}
# Always want 32b version on 64b system
%ifarch x86_64
Recommends:     VirtualGL-32bit
%endif
# Always want 32b version on 64b system
%ifarch x86_64
Recommends:     primus-32bit
%endif
%if 0%{?suse_version} < 1315
Requires:       module-init-tools
%else
Requires:       kmod-compat
%endif

%description
Bumblebee daemon is a rewrite of the original Bumblebee service,
providing an elegant and stable means of managing Optimus hybrid
graphics chipsets. A primary goal of this project is to not only
enable use of the discrete GPU for rendering, but also to enable
smart power management of the dGPU when it's not in use.

%prep
# extract the source and go into the bumblebee directory
%setup -q
# Apply patch to add support for nvidia-uvm
%patch0 -p1

%build
%configure \
	--without-pidfile \
	--with-udev-rules=%{_libexecdir}/udev/rules.d/ \
	CONF_DRIVER_MODULE_NVIDIA=nvidia CONF_LDPATH_NVIDIA=%{_libdir}/nvidia:%{_libexecdir}/nvidia \
	CONF_MODPATH_NVIDIA=%{_libdir}/nvidia/xorg/,%{_libdir}/xorg/modules \
	CONF_PRIMUS_LD_PATH=%{_libdir}/primus:%{_libexecdir}/primus

make %{?_smp_mflags}

%install
make DESTDIR=%{buildroot} install %{?_smp_mflags}
install -d 755 %{buildroot}%{_libexecdir}/systemd
install -D -m644 "%{_builddir}/%{name}-%{version}/scripts/systemd/bumblebeed.service" "%{buildroot}%{_libexecdir}/systemd/system/bumblebeed.service"
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcbumblebeed
# Fix service to run after dkms and modules leading service
sed -i '3i After=dkms.service systemd-modules-load.service' %{buildroot}%{_libexecdir}/systemd/system/bumblebeed.service

%pre
getent group bumblebee >/dev/null || groupadd -r bumblebee || :
%service_add_pre bumblebeed.service

%post
%service_add_post bumblebeed.service
# Notify user about the groups
mkdir -p %{_localstatedir}/adm/update-messages
cat > %{_localstatedir}/adm/update-messages/%{name}-%{version}-%{release} << EOF
INFO: Please ensure that users using bublebee/video card are in following group(s):
INFO:     gpasswd -a <USER> bumblebee
INFO:   If going to use nvidia binary driver:
INFO:     gpasswd -a <USER> video
INFO: Also ensure the nouveau module is blacklisted (even if you plan to use it):
INFO:     echo "blacklist nouveau" >> /etc/modprobe.d/50-blacklist.conf
INFO:     mkinitrd
EOF

%preun
%service_del_preun bumblebeed.service

%postun
%service_del_postun bumblebeed.service

%files
%defattr(-,root,root)
%doc README.markdown COPYING
%dir %{_sysconfdir}/bumblebee
%config %{_sysconfdir}/bumblebee/xorg.conf.nouveau
%config %{_sysconfdir}/bumblebee/xorg.conf.nvidia
%config %{_sysconfdir}/bumblebee/bumblebee.conf
%dir %{_sysconfdir}/bumblebee/xorg.conf.d
%config %{_sysconfdir}/bumblebee/xorg.conf.d/10-dummy.conf
%dir %{_libexecdir}/systemd/system
%{_libexecdir}/systemd/system/bumblebeed.service
%{_sbindir}/rcbumblebeed
%dir %{_libexecdir}/udev
%dir %{_libexecdir}/udev/rules.d
%{_libexecdir}/udev/rules.d/99-bumblebee-nvidia-dev.rules
%config %{_sysconfdir}/bash_completion.d/bumblebee
%{_datadir}/doc/bumblebee
%{_sbindir}/bumblebeed
%{_bindir}/optirun
%{_bindir}/bumblebee-bugreport
%{_mandir}/man1/bumblebeed.1.*
%{_mandir}/man1/optirun.1.*

%changelog
openSUSE Build Service is sponsored by