File xrdp.spec of Package xrdp

#
# spec file for package xrdp
#
# Copyright (c) 2014 SUSE LINUX Products 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/
#


%define _fwdefdir /etc/sysconfig/SuSEfirewall2.d/services
Name:           xrdp
Version:        0.6.1
Release:        0
Summary:        Open Source remo desktop protocol (RDP) server
License:        Apache-2.0 and GPL-2.0+
Group:          System/X11/Utilities
Url:            http://xrdp.sourceforge.net/
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  libX11-devel
BuildRequires:  libXfixes-devel
BuildRequires:  libavahi-devel
BuildRequires:  libtool
BuildRequires:  openssl-devel
BuildRequires:  pam-devel
BuildRequires:  pkg-config
BuildRequires:  pkgconfig(systemd)
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Source0:        http://sourceforge.net/projects/xrdp/files/xrdp/%{version}/xrdp-v%{version}.tar.gz
Source1:        xrdp.fw
Source2:        sysconfig.xrdp
Patch1:         xrdp-avahi.diff
# PATCH-FIX-OPENSUSE xrdp-lsb.patch bnc#442211 - hfiguiere@novell.com
Patch2:         xrdp-lsb.patch
# PATCH-FIX-OPENSSUE xrdp-pam.patch bnc#441750 - hfiguiere@novell.com
Patch3:         xrdp-pam.patch
Patch4:         xrdp-filter-tab-from-mstsc-on-focus-change.patch
Patch5:         xrdp-tab-from-mstsc-updated.patch
# set the default crypto level to high bnc#764044 - lzwang@suse.com
Patch6:         xrdp-change-default-crypto_level.patch
Patch7:         xrdp-add-systemd-support.patch
Patch8:         xrdp-fix-segfaults-in-xrdp-chansrv-code.patch
Patch9:         xrdp-some-minor-changes-to-arch.h.patch

%description
A full functionnal Linux terminal server, capable of accepting
connection from rdesktop and Microsoft's own terminal server / remote
desktop clients.

%prep
%setup -q
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1

%build
sh ./bootstrap
%configure \
   --with-systemdsystemunitdir=%{_unitdir}
make %{?_smp_mflags}

%install
make install DESTDIR=%{buildroot}
find %{buildroot} -name '*.a' -exec rm {} \;
find %{buildroot} -name '*.la' -exec rm -f {} ';'
mkdir -p $RPM_BUILD_ROOT/%{_fwdefdir}
install -m 644 %{S:1} $RPM_BUILD_ROOT/%{_fwdefdir}/xrdp

mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/adm/fillup-templates
install -m 644 %{S:2} $RPM_BUILD_ROOT/%{_localstatedir}/adm/fillup-templates/sysconfig.xrdp

%clean
rm -rf %{buildroot}

%pre
%service_add_pre xrdp-sesman.service
%service_add_pre xrdp.service

%post
/sbin/ldconfig
%service_add_post xrdp-sesman.service
%service_add_post xrdp.service
%{fillup_only -n xrdp}
if [ ! -e %{_sysconfdir}/xrdp/rsakeys.ini ]; then
    xrdp-keygen xrdp %{_sysconfdir}/xrdp/rsakeys.ini
    if [ $? -eq 0 ]; then
        echo "Could not generate rsakeys.ini, please check manually!"
    fi
fi
exit 0

%preun
%service_del_preun xrdp.service
%service_del_preun xrdp-sesman.service

%postun
/sbin/ldconfig
%service_del_postun xrdp.service
%service_del_postun xrdp-sesman.service
%restart_on_update

%files
%defattr(-,root,root)
%{_libdir}/xrdp
%{_bindir}/xrdp*
%{_sbindir}/xrdp*
%{_unitdir}/xrdp*
%config(noreplace) %{_sysconfdir}/xrdp/
%ghost %config(noreplace) %{_sysconfdir}/xrdp/rsakeys.ini
%config(noreplace) %{_sysconfdir}/pam.d/xrdp-sesman
%config %{_localstatedir}/adm/fillup-templates/sysconfig.xrdp
%doc COPYING *.txt
%doc %{_mandir}/man5/*.5*
%doc %{_mandir}/man8/*.8*
%{_datadir}/xrdp
%config %{_fwdefdir}/xrdp

%changelog
openSUSE Build Service is sponsored by