File dante.spec of Package dante

#
# spec file for package dante
#
# 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/
#


Name:           dante
%define lname	libsocks0
BuildRequires:  autoconf >= 2.61
BuildRequires:  cyrus-sasl-devel
BuildRequires:  krb5-devel
BuildRequires:  libtool
BuildRequires:  pam-devel
BuildRequires:  pkgconfig(systemd)
Summary:        A Free Socks v4 and v5 Client Implementation
License:        BSD-3-Clause
Group:          Productivity/Networking/Security
Version:        1.4.0
Release:        0
Url:            http://www.inet.no/dante/
# http://www.inet.no/dante/files/dante-%%{version}.tar.gz
Source:         dante-%{version}.tar.gz
Source1:        sockd.service
Source2:        baselibs.conf
Source3:        %name-rpmlintrc
Patch:          dante-1.4.0-64bit_portability.patch
Patch2:         dante-1.4.0-sockd_conf_man_format.patch
Patch3:         dante-1.4.0-socksify_man_format.patch
Patch4:         dante-1.4.0-glibc-2.17.patch
Patch5:         dante-1.4.0-sendbuf_macro.patch
# SuSE series: sec

%description
Dante is a free implementation of the following proxy protocols: socks
version 4, socks version 5 (rfc1928), and msproxy. It can be used as a
firewall between networks. It is being developed by Inferno Nettverk
A/S, a Norwegian consulting company. Commercial support is available.

%package -n %lname
Summary:        A Free Socks v4 and v5 Client Implementation
Group:          Productivity/Networking/Security

%description -n %lname
Dante is a free implementation of the following proxy protocols: socks
version 4, socks version 5 (rfc1928), and msproxy. It can be used as a
firewall between networks. It is being developed by Inferno Nettverk
A/S, a Norwegian consulting company. Commercial support is available.

This package contains the dynamic libraries required to make existing
applications become socks clients.

%package -n dante-server
Provides:       dantesrv = %{version}
Obsoletes:      dantesrv < %{version}
Summary:        A Free Socks v4/v5 Server Implementation
Group:          Productivity/Networking/Other
Requires:       dante
%{?systemd_requires}

%description -n dante-server
This package contains the socks proxy daemon and its documentation. The
sockd is the server part of the Dante socks proxy package and allows
socks clients to connect through it to the network.

%package -n dante-devel
Provides:       dantedev = %{version}
Obsoletes:      dantedev < %{version}
Summary:        Include Files and Libraries mandatory for Development
Group:          Development/Libraries/C and C++
Requires:       %lname = %version

%description -n dante-devel
This package contains all necessary include files and libraries needed
to develop applications that require these.

%prep
%setup -q
%patch
%patch2
%patch3
%if 0%{?suse_version} > 1220
%patch4 
%endif
%patch5 -p1

%build
DANTELIBC=`find /%{_lib}/ -maxdepth 1 -iname "libc.so.*"`
echo >> acinclude.m4
autoreconf --force --install --verbose

# optflags contains -grecord-gcc-switches which is breaking configure
#CFLAGS="%{optflags} -fno-strict-aliasing" \
CFLAGS=$(echo "%{optflags}" | sed "s|-grecord-gcc-switches||")
%configure --disable-static --with-pic --enable-shared --with-libc=$DANTELIBC
make %{?_smp_mflags} V=1

%install
make install DESTDIR=${RPM_BUILD_ROOT}
#set library as executable - prevent ldd from complaining
chmod +x %{buildroot}%{_libdir}/*.so.*.*
install -d 	%{buildroot}%{_unitdir} \
	   	%{buildroot}%{_bindir} \
	   	%{buildroot}%{_sbindir} \
        %{buildroot}%{_sysconfdir}
install -m 644 example/socks.conf %{buildroot}/%{_sysconfdir}
install -m 644 example/sockd.conf %{buildroot}/%{_sysconfdir}
install -m 755 %{S:1}	 	%{buildroot}/%{_unitdir}/sockd.service
ln -sf          ../../%{_unitdir}/sockd.service	%{buildroot}%{_sbindir}/rcsockd
#
# fix bug #23141
#
mv %{buildroot}%{_bindir}/socksify %{buildroot}%{_bindir}/socksify.old
#
%ifarch alpha
sed -e 's|libdl.so|/lib/libdl.so.2.1|' < %{buildroot}%{_bindir}/socksify.old > %{buildroot}%{_bindir}/socksify
%else
sed -e 's|libdl.so|/%{_lib}/libdl.so.2|' < %{buildroot}%{_bindir}/socksify.old > %{buildroot}%{_bindir}/socksify
%endif
#
rm %{buildroot}%{_bindir}/socksify.old
%{__rm} -f %{buildroot}%{_libdir}/*.la

%__rm Makefile* SPECS/Makefile*

%pre -n dante-server
%service_add_pre sockd.service

%preun -n dante-server
%service_del_preun sockd.service

%post -n %lname -p /sbin/ldconfig

%postun -n %lname -p /sbin/ldconfig

%post -n dante-server
%service_add_post sockd.service

%postun -n dante-server
%service_del_postun sockd.service

%files
%defattr(-,root,root)
#files beginning with two capital letters are docs: BUGS, README.foo etc.
%doc [A-Z][A-Z]*
%{_libdir}/libdsocks.so
%attr(755,root,root) %{_bindir}/socksify
%doc %{_mandir}/man1/socksify.1.gz
%doc %{_mandir}/man5/socks.conf.5.gz
%config(noreplace) %{_sysconfdir}/socks.conf

%files -n %lname
%defattr(-,root,root)
%{_libdir}/libsocks.so.0.1.1
%{_libdir}/libsocks.so.0

%files -n dante-server
%defattr(-,root,root)
#doc [A-Z][A-Z]*
%doc %{_mandir}/man8/sockd.8.gz
%doc %{_mandir}/man5/sockd.conf.5.gz
%attr(755,root,root) %{_sbindir}/sockd
%config(noreplace) %{_sysconfdir}/sockd.conf
%attr(755,root,root) %{_unitdir}/sockd.service
%{_sbindir}/rcsockd

%files -n dante-devel
%defattr(-,root,root)
#doc [A-Z][A-Z]*
%{_libdir}/libsocks.so
%{_includedir}/*.h

%changelog