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/
#
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:  python3-devel
BuildRequires:  python3-distutils-extra
BuildRequires:  systemd
BuildRequires:  pwdutils
BuildRequires:  update-desktop-files
BuildRequires:  libfaketime
Requires:       gdk-pixbuf-loader-rsvg
Requires:       python-gtk
Requires:       python-notify
Requires:       python-Twisted
# WARNING: This is much more a python-Twisted dependency than a Epoptes one.
Requires:       python-service_identity
Requires:       typelib-1_0-Notify-0_7
Requires:       python3-netifaces
Requires:       pwdutils
Requires:       libfaketime
Requires:       tightvnc
Requires:       iperf
Requires:       openssl
Requires:       python-pycha
Requires:       python-netifaces
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:       python-gtk
Requires:       iperf
Requires:       screen
Requires:       socat
Requires:       tightvnc
Requires:       x11vnc
Requires:       xset
Requires:       xwininfo
Requires:       python3-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}
# %%patch0 -p0
%patch3 -p0
# %%patch4 -p0
%patch5 -p0

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

%build

%install
./setup.py install --root=%{buildroot} --prefix=%{_prefix}
# ui files do not get installed automatically
mkdir -p %{buildroot}%{_datadir}/%{name}
for f in $(ls epoptes/ui/gtk/*.ui); do
  %__install -m 644 $f %{buildroot}%{_datadir}/%{name}/${f#epoptes/ui/gtk/}
done
find %{buildroot} \( -name \*.a -o -name \*.la -o -name \*.orig \) -print0 | xargs -0 rm -f
mkdir -p %{buildroot}%{_fillupdir}
%__install -m 644 %{SOURCE4} %{buildroot}%{_fillupdir}/sysconfig.%{name}
%__install -m 644 %{SOURCE5} %{buildroot}%{_fillupdir}/sysconfig.%{name}-client
mkdir -p %{buildroot}%{_unitdir}
%__install -m 644 %{SOURCE2} %{buildroot}%{_unitdir}
%__install -m 644 %{SOURCE3} %{buildroot}%{_unitdir}
install -Dm644 %{SOURCE20} %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{name}
%find_lang %{name}

%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}
# %%{python_sitelib}/
/usr/lib/python3.6/site-packages
%{_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