File aria2.spec of Package aria2

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


%if 0%{?suse_version} > 0 && 0%{?suse_version} > 1140
 %define with_nettle 1
%else
 %if 0%{?_with_gnutls:1}
  %define with_gnutls 1
  %undefine with_openssl
 %else
  %define with_openssl 1
  %undefine with_gnutls
 %endif
%endif

%if 0%{?suse_version} > 0 && 0%{?suse_version} >= 1020
%define with_sqlite 1
%else
%define with_sqlite 0
%endif

%if 0%{?sles_version} > 10 && 0%{?sles_version} < 12
%define with_bashcomp 0
%else
%define with_bashcomp 1
%endif

Name:           aria2
Version:        1.13.0
Release:        1
Summary:        Parallelizing Multi-Protocol Utility for Downloading Files
Source:         http://prdownloads.sourceforge.net/aria2/aria2-%{version}.tar.bz2
Patch1:         aria2-cares-static.patch
Patch2:         aria2-cares-lib64.patch
Patch4:         aria2-atoi.patch
Url:            http://sourceforge.net/projects/aria2
Group:          Productivity/Networking/Other
License:        GNU General Public License (GPL)
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version:1}
%if %{?with_nettle:1}0
BuildRequires:  gmp-devel libnettle-devel
%endif
%if %{?with_gnutls:1}0
BuildRequires:  libgcrypt-devel
%if %suse_version > 1030
BuildRequires:  libgnutls-devel
%else
BuildRequires:  gnutls-devel
%endif #%suse_version > 1030
%endif #with_gnutls
%if %{?with_openssl:1}0
%if %suse_version >= 1030
BuildRequires:  libopenssl-devel
%else
BuildRequires:  openssl-devel
%endif #%suse_version >= 1030
%endif #with_openssl
%if %suse_version >= 1030
BuildRequires:  libexpat-devel
%else
BuildRequires:  expat
%endif #expat
%else
%if %{?with_gnutls:1}0
BuildRequires:  expat
%endif #with_gnutls
%if %{?with_openssl:1}0
BuildRequires:  openssl-devel
%endif #with_openssl
BuildRequires:  expat-devel
%endif #0%{?suse_version:1}
%if 0%{?!suse_version:1} || 0%{?suse_version} >= 1020
BuildRequires:  cppunit-devel
%endif
BuildRequires:  zlib-devel
BuildRequires:  gettext gettext-devel intltool
BuildRequires:  gcc-c++ glibc-devel libstdc++-devel make
%if 0%{?suse_version} >= 1130
BuildRequires:  libcares-devel
%endif #cares
%if 0%{?with_sqlite}
%if 0%{?suse_version} < 1100
BuildRequires:  sqlite-devel
%else
BuildRequires:  sqlite3-devel
%endif #suse_version
%endif #with_sqlite
BuildRequires:  autoconf automake libtool
BuildRequires:  bash
Provides:       aria2c = %{version}-%{release}
%if %with_bashcomp
# Not actually required for build, but makes the build fail if
# it is not available:
BuildRequires:  bash-completion
%endif #with_bashcomp

%description
aria2 is a utility for downloading files. It has completely new design
concept from its predecessor, Aria, and is written from scratch. aria2 has
a segmented downloading engine in its core. It can download one file from
multiple URLs or multiple connections from one URL. This results in very
high speed downloading, much faster than ordinary browsers. This engine in
was implemented in a single-thread model. The architecture is clean and easy
to extend.

aria2 currently supports HTTP, FTP, and BitTorrent.

%if %with_bashcomp

%package bash-completion
License:        GNU General Public License (GPL)
Summary:        Bash Completion for %{name}
Group:          Productivity/Networking/Other
Requires:       %{name} = %{version}
Requires:       bash-completion

%description bash-completion
Provides bash command line completion support for aria2c, a parallelizing
multi-protocol utility for downloading files.
%endif #with_bashcomp

%prep
%setup -q -n "aria2-%{version}"
%if 0%{?with_cares}
%patch1
%if "%{_lib}"=="lib64"
%patch2
%endif #%_lib==lib64
%endif #cares
%patch4

%build
export CFLAGS="%{optflags} -DPIC -fPIC"
export CXXFLAGS="${CFLAGS}"
%configure \
	--with%{?!with_gnutls:out}-gnutls \
	--with%{?!with_openssl:out}-openssl \
	--with%{?!with_cares:out}-libcares \
	--without-libxml2 \
%if 0%{?with_sqlite}
    --with-sqlite3 \
%else
    --without-sqlite3 \
%endif
    --enable-epoll \
	--enable-bittorrent \
    --with-openssl-prefix="%{_usr}" \
    --with-libgnutls-prefix="%{_usr}" \
    --with-libgcrypt-prefix="%{_usr}" \
    --with-libz-prefix="%{_usr}" \
    --with-xml-prefix="%{_usr}" \
    --with-sqlite3-prefix="%{_usr}"
# a buglet in the configure script causes this directive to cause the opposite, so comment it out
# poeml, Mon Aug  4 16:30:55 CEST 2008
	#--enable-metalink

# fix fallocate64 usage on 32bit: fallocate is broken because of a glibc bug
# (but only on < 11.3 and i586), but posix_fallocate works:
%if 0%{?suse_version} > 0 && 0%{?suse_version} < 1130
%if 0%{?suse_version} >= 1120 && "%{_lib}"=="lib"
# openSUSE 11.2, 32bit
%__sed -i '/ HAVE_FALLOCATE /d' config.h
%else
# openSUSE <= 11.2
%if 0%{?suse_version} < 1120
# openSUSE < 11.2
%__sed -i '/ HAVE_FALLOCATE /d' config.h
%__sed -i '/ HAVE_SOME_FALLOCATE /d' config.h
%__sed -i '/ HAVE_POSIX_FALLOCATE /d' config.h
%endif # < 1120
%endif # 1120 32bit
%endif # openSUSE

%__make %{?_smp_mflags}

%install
%makeinstall

%if %with_bashcomp
%__install -D -m0644 doc/bash_completion/aria2c "%{buildroot}/etc/bash_completion.d/%{name}"
%endif #with_bashcomp

%__rm -rf "%{buildroot}%{_datadir}/doc"
for l in "en@boldquot" "en@quot"; do
    %__rm -rf "%{buildroot}%{_datadir}/locale/${l}"
done
%if 0%{?suse_version}
%find_lang aria2
%else
# for some reason, find_lang fails to find anything and
# breaks the build on Fedora 9
echo -n > aria2.lang
%endif

#check
#__make check

%files -f "aria2.lang"
%defattr(-,root,root)
%doc AUTHORS ChangeLog COPYING NEWS README
%doc README.html
%doc doc/aria2c.1.html
%{_bindir}/aria2c
%doc %{_mandir}/man1/aria2c.1%{ext_man}
%if 0%{?suse_version} <= 1120
%dir %{_mandir}/*/man1
%dir %{_mandir}/??
%endif
%doc %{_mandir}/*/man1/aria2c.1%{ext_man}

%if %with_bashcomp

%files bash-completion
%defattr(-,root,root)
%config /etc/bash_completion.d/%{name}
%endif #with_bashcomp

%changelog
openSUSE Build Service is sponsored by