File lftp.spec of Package lftp

#
# spec file for package lftp
#
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2012 Pascal Bleser <pascal.bleser@opensuse.org>
#
# 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/
#


%if %suse_version >= 1100
%define with_gnutls  1
%else
%define with_openssl 1
%endif

Name:           lftp
Version:        4.3.7
Release:        0
%define vi_version 1.1
Url:            http://lftp.yar.ru/
Summary:        LFTP Command Line File Transfer Program
License:        GPL-2.0+
Group:          Productivity/Networking/Ftp/Clients
Source:         http://ftp.yars.free.net/pub/source/lftp/lftp-%{version}.tar.bz2
Source1:        lftp.desktop
Source2:        http://michael.stapelberg.de/lftp_vi/lftp-vi.%{vi_version}.tar.gz
Source3:        lftp.png
Source99:       lftp-rpmlintrc
Patch1:         lftp-compat-addfiles.patch
Patch2:         lftp-wrapper+edit+compat-modify.patch
Patch4:         lftp-autoconf-req.patch
Patch6:         http://michael.stapelberg.de/lftp_vi/lftp-completion.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  gcc-c++
BuildRequires:  gzip
BuildRequires:  libstdc++-devel
BuildRequires:  libtool
BuildRequires:  make
BuildRequires:  ncurses-devel
BuildRequires:  openssl-devel
BuildRequires:  pkgconfig
BuildRequires:  readline-devel
BuildRequires:  tar
BuildRequires:  update-alternatives
BuildRequires:  update-desktop-files
%if %{?with_gnutls:1}0
BuildRequires:  libgnutls-devel
%endif
%if %{?with_openssl:1}0
BuildRequires:  openssl-devel
%endif
Obsoletes:      lftp-beta < %{version}
Provides:       lftp-beta = %{version}-%{release}
Conflicts:      ftp
Provides:       nkitb:/usr/bin/ftp
PreReq:         update-alternatives
PreReq:         /bin/rm
Requires:       /usr/bin/less

%description
LFTP is a reliable shell-like command line FTP client. It can retry
operations and does reget automatically. It can do several transfers
simultaneously in the background. With LFTP, you can start a transfer
in the background and continue browsing that FTP site or another one.
This is all done in one process. Background jobs are completed in nohup
mode if you exit or close the modem connection. LFTP has reput, mirror,
and reverse mirror among its features. Since version 2.0, it also
supports the HTTP protocol. Other features include IPV6 support,
context sensitive completion, output redirection to files or to pipe,
FTP and HTTP proxy support, transfer rate throttling for each
connection and for all connections in sum, job queueing, job execution
at specified times, opie and skey support in the FTP protocol, SSL for
HTTP and FTP, and FXP transfers.

%prep
%setup -q
pushd src
%__tar xzf "%{SOURCE2}"
popd
%patch1
%patch2 -p1
%patch4
pushd src
%patch6
popd #src

# replace AC_CHECK_FUNCS_ONCE with AC_CHECK_FUNCS on SLE 9+10
# as they're not supported by the autotools environment there:
%if 0%{?suse_version} > 0 && 0%{?suse_version} < 1020
%__sed -i '
s|AC_CHECK_FUNCS_ONCE|AC_CHECK_FUNCS|g
;
s|AC_CHECK_HEADERS_ONCE|AC_CHECK_HEADERS|g
;
s|AC_CHECK_DECLS_ONCE|AC_CHECK_DECLS|g
' m4/*.m4
%endif

%build
aclocal -I m4
automake

%if 0%{?suse_version:1} && %suse_version >= 1010
CFLAGS="-DUSE_VARARGS -DPREFER_STDARGS %{optflags} -fstack-protector"
%else
CFLAGS="-DUSE_VARARGS -DPREFER_STDARGS %{optflags}"
%endif
CFLAGS="$CFLAGS" \
CXXFLAGS="$CFLAGS" \
LDFLAGS=' ' \
%configure \
   --with-modules \
%if %{?with_gnutls:1}0
   --with-gnutls --without-openssl \
%endif
%if %{?with_openssl:1}0
   --with-openssl --without-gnutls \
%endif
   --with-modules \
   --with-debug \
   --without-profiling \
   --enable-largefile \
   --with-pager=/usr/bin/less \
   --with-libresolv

%__make %{?jobs:-j%jobs} \
	STRIP=touch

%install
%makeinstall STRIP=touch

touch "%{buildroot}%{_bindir}/ftp"
%__chmod 0755 "%{buildroot}%{_bindir}/ftp"

# We don't package the .la files
%__rm -f "%{buildroot}/%{_libdir}"/{lftp/*/,}*.la

%__install -D -m 0644 "%{SOURCE1}" "%{buildroot}%{_datadir}/applications/%{name}.desktop"
%__install -D -m 0644 "%{SOURCE3}" "%{buildroot}%{_datadir}/pixmaps/%{name}.png"
%suse_update_desktop_file "%{name}" Network FileTransfer

%find_lang "%{name}"

%post
/sbin/ldconfig
test -L "%{_bindir}/ftp" || %__rm -f "%{_bindir}/ftp"
/usr/sbin/update-alternatives --install "%{_bindir}/ftp" ftp "%{_bindir}/lftp_wrapper" 5 \
  --slave "%{_mandir}/man1/ftp.1%{ext_man}" ftp.1 "%{_mandir}/man1/lftp.1%{ext_man}"
/usr/sbin/update-alternatives --auto ftp

%postun -p /sbin/ldconfig

%preun
if [ $1 -eq 0 ]; then
  /usr/sbin/update-alternatives --remove ftp "%{_bindir}/lftp_wrapper"
fi

%files -f "lftp.lang"
%defattr(-,root,root)
%doc BUGS COPYING ChangeLog FAQ FEATURES README* NEWS THANKS TODO lftp.lsm
%config %{_sysconfdir}/lftp.conf
%{_bindir}/lftp
%{_bindir}/lftpget
%{_bindir}/lftp_wrapper
%{_datadir}/lftp
%dir %{_libdir}/lftp
%dir %{_libdir}/lftp/%{version}
%{_libdir}/lftp/%{version}/cmd-edit.so
%{_libdir}/lftp/%{version}/cmd-mirror.so
%{_libdir}/lftp/%{version}/cmd-sleep.so
%{_libdir}/lftp/%{version}/cmd-torrent.so
%{_libdir}/lftp/%{version}/compat-mode.so
%{_libdir}/lftp/%{version}/liblftp-network.so
%{_libdir}/lftp/%{version}/liblftp-pty.so
%{_libdir}/lftp/%{version}/proto-file.so
%{_libdir}/lftp/%{version}/proto-fish.so
%{_libdir}/lftp/%{version}/proto-ftp.so
%{_libdir}/lftp/%{version}/proto-http.so
%{_libdir}/lftp/%{version}/proto-sftp.so
%{_libdir}/liblftp-*.so
%{_libdir}/liblftp-*.so.*
%doc %{_mandir}/man1/lftp.1%{ext_man}
%doc %{_mandir}/man1/lftpget.1%{ext_man}
%doc %{_mandir}/man5/lftp.conf.5%{ext_man}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/pixmaps/%{name}.png
%ghost %{_bindir}/ftp
%ghost %doc %attr(0444,root,root) %{_mandir}/man1/ftp.1%{ext_man}

%clean
%{?buildroot:%__rm -rf "%{buildroot}"}

%changelog