File stunnel.spec of Package stunnel

#
# spec file for package stunnel
#
# Copyright (c) 2016 SUSE LINUX 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 fu_dir %{?_fillupdir}%{!?_fillupdir:%{_localstatedir}/adm/fillup-templates}
%define fu_template %{fu_dir}/sysconfig.syslog-stunnel

Name:           stunnel
Version:        5.57
Release:        0
Summary:        Universal SSL Tunnel
License:        GPL-2.0+
Group:          Productivity/Networking/Security
Url:            http://www.stunnel.org/
Source:         %{name}-%{version}.tar.gz
Source1:        stunnel.conf
Source2:        stunnel.README
Source3:        sysconfig.syslog-stunnel
Source4:        stunnel.init
Source97:       %{name}-rpmlintrc
Source98:       %{name}.keyring
Source99:       %{name}-%{version}.tar.gz.asc
BuildRequires:  openssl
BuildRequires:  openssl-devel
BuildRequires:  tcpd-devel
BuildRequires:  xz
BuildRequires:  zlib-devel
Requires(post): %insserv_prereq %fillup_prereq
Requires(pre):  pwdutils
%if 0%{?suse_version} < 1130
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%endif


%description
The stunnel program is designed to work as an SSL encryption wrapper
between a remote client and the local (inetd-startable) or remote
server. The concept is that by having non-SSL aware daemons running on
your system, you can easily set them to communicate with clients over a
secure SSL channel. Stunnel can be used to add SSL functionality to
commonly used inetd daemons, such as POP-2, POP-3, and IMAP servers,
without any changes to the program code.


%prep
%setup -q


%build
#autoreconf -fi
sed -i 's/-m 1770 -g nogroup//g' tools/Makefile.in
fPIE="-fPIE"
pie="-pie"
export CFLAGS="%{optflags} $fPIE"
%configure \
  --localstatedir=%{_localstatedir} \
  --enable-ipv6 \
  --disable-systemd
#echo -e ".\n.\n.\n.\n.\n" | make LDADD="$pie -Wl,-z,defs,-z,relro"
make %{?_smp_mflags} \
	confdir=%{_sysconfdir}/%{name} \
	sbindir=%{_sbindir} \
	libdir=%{_libdir} \
	mandir=%{_mandir} \
	docdir=%{_docdir}/%{name} \
	LDADD="$pie -Wl,-z,defs,-z,relro"


%install
make %{?_smp_mflags} \
	confdir=%{_sysconfdir}/%{name} \
	sbindir=%{_sbindir} \
	libdir=%{_libdir} \
	mandir=%{_mandir} \
	docdir=%{_docdir}/%{name} \
	DESTDIR=%{buildroot} \
	install
mkdir -p %{buildroot}/%{_sbindir}
mkdir -p %{buildroot}/%{_localstatedir}/lib/%{name}/{etc,dev,bin,sbin,%{_lib}}
mkdir -p %{buildroot}/%{_localstatedir}/lib/%{name}
mkdir -p %{buildroot}%{_initddir}/
mkdir -p %{buildroot}%{fu_dir}
mkdir -p doc/examples
mv -vi tools/ca.* tools/importCA.* tools/openssl.cnf doc/examples/
cp -p %{SOURCE1} doc/examples/stunnel.conf-sample
cp -p %{SOURCE2} README.SUSE
cp -p %{SOURCE3} %{buildroot}%{fu_template}
install -m 755 %{SOURCE4} %{buildroot}%{_initddir}/stunnel
ln -s ../..%{_initddir}/stunnel %{buildroot}%{_sbindir}/rcstunnel
ln -s stunnel3 %{buildroot}%{_sbindir}/stunnel3_wrapper
mv %{buildroot}/%{_bindir}/* %{buildroot}/%{_sbindir}
rm %{buildroot}/%{_sysconfdir}/%{name}/stunnel.conf-sample
cp %{SOURCE1} %{buildroot}/%{_sysconfdir}/%{name}/stunnel.conf
rm %{buildroot}/%{_docdir}/%{name}/INSTALL.{FIPS,W32,WCE}.md


%pre
getent group stunnel >/dev/null || groupadd -r stunnel
getent passwd stunnel >/dev/null \
  || %{_sbindir}/useradd -r -g stunnel -c 'Universal SSL tunnel daemon' \
        -d %{_localstatedir}/lib/%{name} stunnel
exit 0


%post
%{fillup_and_insserv -f}
%{fillup_only -ans syslog stunnel}
/sbin/ldconfig


%preun
%stop_on_removal stunnel


%postun
%restart_on_update stunnel
%insserv_cleanup


%files
%defattr(-, root, root)
%{_sbindir}/*
%{_libdir}/%{name}
%{_mandir}/man8/*
%dir %attr(700,root,root) %{_sysconfdir}/%{name}
%dir %attr(755,root,root) %{_localstatedir}/lib/%{name}
%dir %attr(755,root,root) %{_localstatedir}/lib/%{name}/bin
%dir %attr(755,root,root) %{_localstatedir}/lib/%{name}/etc
%dir %attr(755,root,root) %{_localstatedir}/lib/%{name}/dev
%dir %attr(755,root,root) %{_localstatedir}/lib/%{name}/%{_lib}
%dir %attr(755,root,root) %{_localstatedir}/lib/%{name}/sbin
%{fu_template}
%config %{_initddir}/*
%config(noreplace) %{_sysconfdir}/%{name}/stunnel.conf


# ----------------------------------------------------------------------------

%package doc
Summary:        Documentation for the stunnel daemon
Group:          Documentation/Other
Requires:       %{name} = %{version}
%if 0%{?suse_version} > 1110
BuildArch:      noarch
%endif

%description doc
Documentation for the stunnel daemon.

The stunnel program is designed to work as an SSL encryption wrapper
between a remote client and the local (inetd-startable) or remote
server. The concept is that by having non-SSL aware daemons running on
your system, you can easily set them to communicate with clients over a
secure SSL channel. Stunnel can be used to add SSL functionality to
commonly used inetd daemons, such as POP-2, POP-3, and IMAP servers,
without any changes to the program code.

%files doc
%defattr(-, root, root)
%{_docdir}/%{name}


# ----------------------------------------------------------------------------

%changelog
openSUSE Build Service is sponsored by