File spice-vdagent.spec of Package spice-vdagent.17026

#
# spec file for package spice-vdagent
#
# Copyright (c) 2020 SUSE LLC
# Copyright (c) 2014 B1 Systems GmbH, Vohburg, 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 https://bugs.opensuse.org/
#


#This test doesn't work right in build service, but does outside of it
%bcond_with session_info_test

Name:           spice-vdagent
Version:        0.19.0
Release:        0
Summary:        Agent for Spice guests
License:        GPL-3.0-or-later
Group:          System/Daemons
URL:            https://spice-space.org/
Source:         https://spice-space.org/download/releases/%{name}-%{version}.tar.bz2
Source1:        https://spice-space.org/download/releases/%{name}-%{version}.tar.bz2.sig
Source2:        %{name}.keyring
Patch0:         vdagentd-Fix-session-lookup-for-new-GNOME-versions.patch
Patch1:         covscan-avoid-false-positive-on-g_clear_pointer.patch
Patch2:         virtio-port-handle_fds-make-read-and-write-code-cons.patch
Patch3:         introduce-VDAgentConnection.patch
Patch4:         udscs-server-split-initialization.patch
Patch5:         vdagentd-work-around-GLib-s-fork-issues.patch
Patch6:         vdagentd-init-static-uinput-before-fork.patch
Patch7:         systemd-login-Avoid-a-crash-on-container.patch
Patch8:         vdagentd-Automatically-release-agent_data.patch
Patch9:         vdagent-connection-Pass-err-to-g_credentials_get_uni.patch
Patch10:        vdagentd-Better-check-for-vdagent_connection_get_pee.patch
Patch11:        vdagentd-Avoid-calling-chmod.patch
Patch12:        Avoids-unchecked-file-transfer-IDs-allocation-and-us.patch
Patch13:        Avoids-uncontrolled-active_xfers-allocations.patch
Patch14:        Avoids-unlimited-agent-connections.patch
Patch15:        Avoids-user-session-hijacking.patch
Patch16:        Better-check-for-sessions.patch
Patch17:        vdagentd-Limit-number-of-agents-per-session-to-1.patch
Patch18:        cleanup-active_xfers-when-the-client-disconnects.patch
Patch19:        vdagentd-do-not-allow-to-use-an-already-used-file-xf.patch
Patch20:        Add-stdbool.h-to-vdagentd.c.patch
Patch21:        Switch-to-GIO2.patch
Patch22:        Need-to-include-gio-gio.h.patch
Patch23:        Add-content-from-more-recent-spice-protocol-devel.patch 
Patch24:        Add-a-test-for-session_info.patch
BuildRequires:  alsa-devel  >= 1.0.22
BuildRequires:  desktop-file-utils
BuildRequires:  glib2-devel
BuildRequires:  libXfixes-devel
BuildRequires:  libXinerama-devel
BuildRequires:  libXrandr-devel
BuildRequires:  libdrm-devel
BuildRequires:  libpciaccess-devel
BuildRequires:  libtool
BuildRequires:  spice-protocol-devel >= 0.12.8
BuildRequires:  systemd
BuildRequires:  systemd-devel
BuildRequires:  pkgconfig(dbus-1)
BuildRequires:  pkgconfig(glib-2.0) >= 2.50
BuildRequires:  pkgconfig(gtk+-3.0) >= 3.22
BuildRequires:  pkgconfig(udev)
Supplements:    modalias(xorg-x11-server:virtio:d00000003v*)
%{?systemd_requires}

%description
Spice agent for Linux guests offering the following features:

Features:
* Client mouse mode (no need to grab mouse by client, no mouse lag)
  this is handled by the daemon by feeding mouse events into the kernel
  via uinput. This will only work if the active X-session is running a
  spice-vdagent process so that its resolution can be determined.
* Automatic adjustment of the X-session resolution to the client resolution
* Support of copy and paste (text and images) between the active X-session
  and the client

%prep
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch20 -p1
%patch21 -p1
%patch22 -p1
%patch23 -p1
%if %{with session_info_test}
%patch24 -p1
%endif

%build
autoreconf
%configure \
  --with-gtk \
  --with-session-info=systemd \
  --with-init-script=systemd
make %{?_smp_mflags} V=2

%check
make check V=2

%install
make install DESTDIR=%{buildroot} V=2
# create rc symlink
ln -s  service %{buildroot}%{_sbindir}/rcspice-vdagentd

mkdir -p %{buildroot}%{_datadir}/gdm/greeter/autostart

mv %{buildroot}%{_datadir}/gdm/autostart/LoginWindow/*.desktop %{buildroot}%{_datadir}/gdm/greeter/autostart
rm -fr %{buildroot}%{_datadir}/gdm/autostart

%pre
%service_add_pre spice-vdagentd.service
%service_add_pre spice-vdagentd.socket

%post
%service_add_post spice-vdagentd.service
if [ "$1" -eq 1 ]; then
    systemctl -q enable spice-vdagentd.service || :
fi
%service_add_post spice-vdagentd.socket
%tmpfiles_create %_tmpfilesdir/spice-vdagentd.conf

%preun
%service_del_preun spice-vdagentd.service
%service_del_preun spice-vdagentd.socket

%postun
%service_del_postun spice-vdagentd.service
%service_del_postun spice-vdagentd.socket

%files
%defattr(-,root,root)
%doc CHANGELOG.md README.md
%license COPYING
%dir %{_libexecdir}/udev
%dir %{_libexecdir}/udev/rules.d
%ghost /run/spice-vdagentd
%{_libexecdir}/udev/rules.d/70-spice-vdagentd.rules
%{_unitdir}/spice-vdagentd.service
%{_unitdir}/spice-vdagentd.socket
%{_libexecdir}/tmpfiles.d/spice-vdagentd.conf
%{_bindir}/spice-vdagent
%{_sbindir}/spice-vdagentd
%{_sbindir}/rcspice-vdagentd
%{_sysconfdir}/xdg/autostart/spice-vdagent.desktop
# For /usr/share/gdm/autostart/LoginWindow/spice-vdagent.desktop
# We own the dir too, otherwise we must Require gdm
%{_datadir}/gdm
%{_mandir}/man1/%{name}*.1*

%changelog
openSUSE Build Service is sponsored by