File turnpike.spec of Package turnpike

#
# spec file for package turnpike
#
# Copyright (c) 2011 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/
#

# norootforbuild


Name:           turnpike
BuildRequires:  gnome-common gtk2 gtk2-devel intltool libgcrypt-devel libxml2-devel novell-ipsec-tools-devel openssl-devel perl-XML-Parser update-desktop-files
%define prefix /usr
%define sysconfdir /etc
%define libexecdir %{prefix}/lib/turnpike
%define datadir /usr/share/turnpike
%define plugindir %prefix/lib/turnpike/plugins
%define gnome /gnome
Summary:        IKE Plugin framework for IPSec tools
Version:        0.1.2
Release:        13
License:        BSD3c(or similar)
Group:          Productivity/Networking/Security
Source:         %{name}-%{version}.tar.bz2
Source1:        vpnlogin.desktop
Source2:        vpnlogin.gif
Source3:        README.SuSE
Url:            http://forge.novell.com/modules/xfmod/project/?turnpike
Requires:       novell-ipsec-tools >= 0.7
PreReq:         coreutils
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Patch:          turnpike-0.1.2-missing-closedir.patch

%description
This package contains binaries for making use of ipsec-tools with a
plugin framework. This enables to write custom vendor plugins to
process IPSec packets for solutions like VPN.



%prep
%setup -q
%patch
cp -v %{S:3} .
# no point in having this in a package
sed -i -e 's,-Werror,,' configure

%build
# fix build in disabling as-needed
export SUSE_ASNEEDED=0
CFLAGS="$RPM_OPT_FLAGS" \
./configure \
    --prefix=%{prefix} \
    --exec-prefix=%{prefix}  \
    --mandir=%{_mandir} \
    --infodir=%{_infodir} \
    --sysconfdir=%{sysconfdir} \
    --datadir=%{datadir} \
    --sharedstatedir=/var/run \
    --localstatedir=/var/run \
    --mandir=%{prefix}/share/man \
    --infodir=%{prefix}/share/info \
    --libdir=%{prefix}/%_lib \
    --libexecdir=%{libexecdir} \
    --with-plugindir=%{plugindir}
%{__make} %{?jobs:-j%jobs}

%install
make install DESTDIR=%{buildroot}
mkdir -p %{buildroot}/%{sysconfdir}/turnpike
mkdir -p %{buildroot}/etc/racoon/cert
mkdir -p %{buildroot}/%{sysconfdir}/turnpike/usercerts
mkdir -p %{buildroot}/%{sysconfdir}/turnpike/profiles
mkdir -p %{buildroot}/%{sysconfdir}/turnpike/vendorprofiles
# desktop icon
install -d %{buildroot}/%{datadir}/pixmaps
install -m 644 %{S:2} %{buildroot}/%{datadir}/pixmaps/vpnlogin.gif
install -d %{buildroot}/usr/share/applications
install -m 644 %{S:1} %{buildroot}/usr/share/applications/vpnlogin.desktop
%suse_update_desktop_file vpnlogin

%post
if [ -L /usr/bin/vpnlogin ]; then
    rm -rf /usr/bin/vpnlogin
fi
if [ -L /usr/bin/nvpn ] ; then
    rm -rf /usr/bin/nvpn
fi
#remove it even if it doesnt exists 
%{libexecdir}/vpnUpdateMenu -u
%{libexecdir}/vpnUpdateMenu -i

%preun
#Do the following only if it is last uninstall
if [ "$1" = "0" ] ; then
    %{libexecdir}/vpnUpdateMenu -u
    rm -rf %{libexecdir}/vpnUpdateMenu
    rm -rf /usr/bin/vpnlogin
    rm -rf /usr/bin/nvpn
    rm -rf %{sysconfdir}/turnpike
fi

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root)
%{prefix}/bin/nvpn
%{prefix}/bin/vpnlogin
%dir %{sysconfdir}/turnpike
%dir %{sysconfdir}/turnpike/profiles
%dir %{sysconfdir}/turnpike/vendorprofiles
%dir %{sysconfdir}/turnpike/usercerts
%dir /etc/racoon
%dir /etc/racoon/cert
%dir %{datadir}
%dir %{datadir}/pixmaps
%{datadir}/pixmaps/vpnlogin.gif
/usr/share/applications/vpnlogin.desktop
%dir %{libexecdir}
%{libexecdir}/vpnUpdateMenu
%dir %{prefix}/include/turnpike
%{prefix}/include/turnpike/*
%doc README README.SuSE INSTALL

%changelog
openSUSE Build Service is sponsored by