File epoptes.spec of Package epoptes

#
# spec file for package epoptes
#
# Copyright (c) 2012 CyberOrg Info
#
# 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/
#

%define skip_python2 1
%{?!python_module:%define python_module() python-%{**} python3-%{**}}


Name:           epoptes
Version:        0
Release:        1
License:        GPL-2.0+
Summary:        Computer lab management tool
Url:            http://www.epoptes.org
Group:          System/X11/Utilities
Source:         %{name}-%{version}.tar.xz
Source1:        epoptes-rpmlintrc
Source2:        epoptes.service
Source3:        epoptes-client.service
Source4:        epoptes.sysconfig
Source5:        epoptes-client.sysconfig
%if 0%{?suse_version}
Source20:       epoptes-SuSEfirewall2
%endif
Patch0:         epoptes-client-workaround-multiseat-broadcasting.patch
Patch3:         epoptes-client-x11vnc-wrapper.patch
Patch4:         epoptes_config.py_sysconfig_support.patch
Patch5:         epoptes-client_sysconfig_support.patch
BuildRequires:  intltool
BuildRequires:  openssl
BuildRequires:  %{python_module devel}
BuildRequires:  python-rpm-macros
BuildRequires:  %{python_module distutils-extra}
BuildRequires:  systemd
BuildRequires:  pwdutils
BuildRequires:  update-desktop-files
BuildRequires:  libfaketime

BuildRequires:  %{python_module pyOpenSSL}
BuildRequires:  %{python_module Twisted}
BuildRequires:  %{python_module netifaces}
BuildRequires:  %{python_module gobject}

BuildRequires:  typelib(GIRepository)
BuildRequires:	typelib(Gtk) = 3.0

Requires:       gdk-pixbuf-loader-rsvg

# WARNING: This is much more a python-Twisted dependency than a Epoptes one.
Requires:       %{python_module service_identity}
Requires:       typelib-1_0-Notify-0_7
Requires:       %{python_module pycha}

Requires:       pwdutils
Requires:       libfaketime
Requires:       tightvnc
Requires:       iperf
Requires:       openssl
Requires:       socat
Requires:       x11vnc
Requires:       xset
Requires:       xwininfo

%{?systemd_requires}

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

%description
Epoptes (Επόπτης  - a Greek word for overseer) is an open source computer lab
management and monitoring tool. It allows for screen broadcasting and
monitoring, remote command execution, message sending, imposing restrictions
like screen locking or sound muting the clients and much more!

Visit http://epoptes.org for more information.

%package client
Summary:        Epoptes client
Requires:       gdk-pixbuf-loader-rsvg
Requires:	typelib(Gtk) = 3.0
Requires:       iperf
Requires:       screen
Requires:       socat
Requires:       tightvnc
Requires:       x11vnc
Requires:       xset
Requires:       xwininfo
Requires:       %{python_module cairo}
%systemd_requires

%description client
This is a client part of Epoptes Computer lab management tool

%define __sysconfdir %{_sysconfdir}/%{name}

%prep
%setup -q -n %{name}-%{version}
# %%patch -P 0 -p 0
%patch -P 3 -p 0
# %%patch -P 4 -p 0
%patch -P 5 -p 0

for file in $(find . -type f -name "*.py" ); do
	sed -i "s|/usr/bin/env python|%{_bindir}/python|g" $file
done

%build
%python_build

%install
%python_install


%clean
%__rm -rf %{buildroot}

%pre
%service_add_pre %{name}.service

%pre client
%service_add_pre %{name}-client.service

%post
%{fillup_only -n %{name}}
if ! getent group %{name} >/dev/null; then
    groupadd --system %{name}
fi

if ! [ -f %{__sysconfdir}/server.key ] || ! [ -f %{__sysconfdir}/server.crt ] || ! [ -s %{__sysconfdir}/server.crt ]; then
    if ! [ -d %{__sysconfdir} ]; then
        %{__mkdir_p} %{__sysconfdir}
    fi
    faketime '1970-01-01 00:00:00 UTC' openssl req -batch -x509 -nodes -newkey rsa:1024 -days $(($(date --utc +%s) / 86400 + 3652)) -keyout %{__sysconfdir}/server.key -out %{__sysconfdir}/server.crt ||
    openssl req -batch -x509 -nodes -newkey rsa:1024 -days $(($(date --utc +%s) / 86400 + 3652)) -keyout %{__sysconfdir}/server.key -out %{__sysconfdir}/server.crt
    chmod 600 %{__sysconfdir}/server.key
fi

%service_add_post %{name}.service

%post client
%{fillup_only -n %{name}-client}
%service_add_post %{name}-client.service

%preun
%service_del_preun %{name}.service

%preun client
%service_del_preun %{name}-client.service

%postun
%service_del_postun %{name}.service

%postun client
%service_del_postun %{name}-client.service

%files -f %{name}.lang
%defattr(-, root, root)
%config(noreplace) %{_fillupdir}/sysconfig.%{name}
%config %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{name}
%{_unitdir}/%{name}.service
%{_bindir}/%{name}

%{python3_sitelib}/*

%{_datadir}/applications/*
%{_datadir}/icons/*
%{_datadir}/ltsp/
%{_datadir}/%{name}/
%dir %{_datadir}/doc/%{name}
%{_datadir}/doc/%{name}/README.md
%{_mandir}/man1/%{name}.1.gz

%files client
%defattr(-, root, root)
%config(noreplace) %{_fillupdir}/sysconfig.%{name}-client
%{_sysconfdir}/xdg/autostart/%{name}-client.desktop
%{_unitdir}/%{name}-client.service
%{_sbindir}/%{name}-client
%{_datadir}/%{name}-client/
%attr(755, -, -) %{_datadir}/%{name}-client/x11vnc-wrapper
%{_mandir}/man8/%{name}-client.8.gz

%changelog
openSUSE Build Service is sponsored by