File xrdp.spec of Package xrdp

Name: 		xrdp
Version: 	0.9.8
Release: 	1
Summary:	An open source RDP server
License:	Apache-2.0
Source: 	https://github.com/neutrinolabs/xrdp/releases/download/v0.9.8/xrdp-0.9.8.tar.gz
Source1:    xrdp-daemon.service
Source2:    xrdp-sesman.service
Source3:    xrdp.target
Url: 		http://www.xrdp.org
BuildRequires: make gcc openssl-devel pam-devel libX11-devel libXfixes-devel libXrandr-devel
BuildRequires: autoconf automake libtool pkg-config
BuildRequires: nasm fdupes

# short name of the program
%define local_name %{name}

%description
Xrdp provides a graphical login to remote machines using Microsoft
Remote Desktop Protocol (RDP). xrdp accepts connections from a variety of
RDP clients: FreeRDP, rdesktop, NeutrinoRDP and Microsoft Remote Desktop
Client (for Windows, Mac OS, iOS and Android).

RDP transport is encrypted using TLS by default.


###### Sub packages
%package systemd
Summary: Systemd integration

%description systemd
Provides files to use xrdp as a system service (systemd)
Requires: %{name}


%package devel
Summary: Development files
Requires: %{name} = %{version}
Requires: libopenssl-devel glibc-devel

%description devel
Header files and libraries for development.


###### Setup build environment
%prep
%setup -n xrdp-%{version}


###### Build software
%build
./bootstrap
%configure
make %{?_smp_mflags} all


###### Install into build system
%install
make install DESTDIR="%{?buildroot}"

rm -rf $RPM_BUILD_ROOT/%_sysconfdir/init.d # remove unneeded SYSV init scripts

install -m644 -D %SOURCE1 $RPM_BUILD_ROOT/%_unitdir/%{local_name}-daemon.service
install -m644 -D %SOURCE2 $RPM_BUILD_ROOT/%_unitdir/%{local_name}-sesman.service
install -m644 -D %SOURCE3 $RPM_BUILD_ROOT/%_unitdir/%{local_name}.target

ln -snf %_prefix/sbin/service $RPM_BUILD_ROOT/%{_prefix}/sbin/rc%{local_name}-daemon
ln -snf %_prefix/sbin/service $RPM_BUILD_ROOT/%{_prefix}/sbin/rc%{local_name}-sesman
ln -snf %_prefix/sbin/service $RPM_BUILD_ROOT/%{_prefix}/sbin/rc%{local_name} 

# make logo accessible through a symlink for better configuration
mv $RPM_BUILD_ROOT/%_datadir/xrdp/xrdp_logo{,_orig}.bmp


###### Installation scripts
%post systemd
%service_add_post %{local_name}-daemon
%service_add_post %{local_name}-sesman


%postun systemd
%service_del_postun %{local_name}-daemon
%service_del_postun %{local_name}-sesman


%pre systemd
%service_add_pre %{local_name}-daemon
%service_add_pre %{local_name}-sesman


%preun systemd
%service_del_preun %{local_name}-daemon
%service_del_preun %{local_name}-sesman

%post
/sbin/ldconfig
# Add symlink to logo
if [ ! -e %_datadir/xrdp/xrdp_logo.bmp ]; then
	ln -snf %_datadir/xrdp/xrdp_logo{_orig,}.bmp
fi

%preun
# Remove symlink to logo when uninstalling
if [ $1 -eq 0 ]; then
	rm %_datadir/xrdp/xrdp_logo.bmp
fi

%postun
/sbin/ldconfig


###### File packaging
%files
%defattr(-,root, root, -)
## Executables
%_prefix/bin/*
%_prefix/sbin/%{local_name}
%_prefix/sbin/%{local_name}-chansrv
%_prefix/sbin/%{local_name}-sesman
## Runtime libraries
%dir %_libdir/%{local_name}
%_libdir/%{local_name}/*.so.*
%_libdir/*.so.*
## Plugin libraries
%_libdir/%{local_name}/*.so
## Configuration
%dir %_sysconfdir/%{local_name}
%config %_sysconfdir/%{local_name}/*
%config %_sysconfdir/default/%{local_name}
%config %_sysconfdir/pam.d/%{local_name}-sesman

## Shared data
%dir %_datadir/%{local_name}
%_datadir/%{local_name}/*
## Documentation
%doc %_mandir/*/*.gz


%files systemd
%defattr(-,root, root, -)
## Systemd units
%_unitdir/*
## Convenience rc scripts
%_prefix/sbin/rc*


%files devel
%defattr(-,root, root, -)
## header files
%_includedir/*
## Plugin libraries devel
%_libdir/%{local_name}/*.a
%_libdir/%{local_name}/*.la
## Runtime libraries devel
%_libdir/*.a
%_libdir/*.la
%_libdir/*.so
## Pkg-config
%_libdir/pkgconfig/*


%changelog
openSUSE Build Service is sponsored by