Blob Blame Raw
%global mydocs __tmp_docdir

# Build -pythonN subpackage
%bcond_without python3

# See also
%if %{with python3}
%global _privatelibs libpy%{name}[.]so.*
%global __provides_exclude ^(%{_privatelibs})$
%global __requires_exclude ^(%{_privatelibs})$

Name:           opentrep
Version:        0.07.4
Release:        3%{?dist}

Summary:        C++ library providing a clean API for parsing travel-focused requests

# The entire source code is LGPLv2+ except opentrep/basic/float_utils_google.hpp,
# which is BSD
License:        LGPLv2+ and BSD
URL:  {name}
Source0:        %{url}/archive/%{name}-%{version}.tar.gz

# For some reason, as of November 2019, it does not compile on ARMv7hl
# See
ExcludeArch:    armv7hl

BuildRequires:  gcc-c++
%if 0%{?fedora} || 0%{?rhel} > 7
BuildRequires:  cmake
BuildRequires:  cmake3
BuildRequires:  boost-devel
%if %{with python3}
BuildRequires:  python3-setuptools
BuildRequires:  python3-devel
BuildRequires:  boost-python3-devel
BuildRequires:  readline-devel
BuildRequires:  soci-mysql-devel
BuildRequires:  soci-sqlite3-devel
BuildRequires:  xapian-core-devel
BuildRequires:  sqlite-devel
BuildRequires:  mysql-devel
BuildRequires:  libicu-devel
BuildRequires:  protobuf-devel
BuildRequires:  protobuf-compiler

%{name} aims at providing a clean API, and the corresponding C++
implementation, for parsing travel-focused requests.
It powers the Web site.

%{name} uses Xapian ( for the Information Retrieval
part, on freely available travel-related data (e.g., country names and codes,
city names and codes, airline names and codes, etc.), mainly to be found in
the OpenTravelData project (

The data files are available from

%{name} exposes a simple, clean and object-oriented, API. For instance,
the OPENTREP::interpretTravelRequest() method takes, as input, a string
containing the travel request, and yields, as output, the list of the
recognized terms as well as their corresponding types.
As an example, the travel request
'Washington DC Beijing Monday a/r +AA -UA 1 week 2 adults 1 dog' would give
the following list:
 * Origin airport: Washington, DC, USA
 * Destination airport: Beijing, China
 * Date of travel: next Monday
 * Date of return: 1 week after next Monday
 * Preferred airline: American Airlines; non-preferred airline: United Airlines
 * Number of travelers: 2 adults and a dog

The output can then be used by other systems, for instance to book the
corresponding travel or to visualize it on a map and calendar and to
share it with others.

%{name} makes an extensive use of existing open-source libraries for
increased functionality, speed and accuracy. In particular the
Boost (C++ Standard Extensions: and
SOCI ( libraries are used.

Note that %{name} currently only recognizes points of reference (POR),
as to be found in the following file:
A good complementary tool is GeoBase (,
a Python-based software able to access to any travel-related data source.

%package        devel
Summary:        Header files, libraries and development helper tools for %{name}
Requires:       %{name}%{?_isa} = %{version}-%{release}
Requires:       pkgconfig

%description    devel
This package contains the header files, shared libraries and
development helper tools for %{name}. If you would like to develop
programs using %{name}, you will need to install %{name}-devel.

%if %{with python3}

%package    -n python3-%{name}
Summary:    Python bindings for %{name}
Group:      System Environment/Libraries
Requires:   %{name}%{?_isa} = %{version}-%{release}

%description -n python3-%{name}
This package contains Python libraries for %{name}

%package -n python3-%{name}-devel
Summary: Shared object symbolic links for OpenTREP Python 3
Requires: python3-%{name}%{?_isa} = %{version}-%{release}
Requires: %{name}-devel%{?_isa} = %{version}-%{release}

%description -n python3-%{name}-devel

Shared object symbolic links for Python 3 variant of OpenTREP.


%package        doc
Summary:        HTML documentation for the %{name} library
BuildArch:      noarch
BuildRequires:  tex(latex), tex(sectsty.sty), tex(tocloft.sty), tex(xtab.sty)
#BuildRequires:  texlive-collection-langcyrillic, texlive-cyrillic
BuildRequires:  doxygen
BuildRequires:  ghostscript

%description    doc
This package contains HTML pages for %{name}. All that documentation
is generated thanks to Doxygen ( The content is
the same as what can be browsed online (
Note that the PDF form of the reference manual is mainly available online
(, as the one present in that
package is usually corrupted: it depends on the building conditions,
and it is therefore not reliable.

%setup -q -n %{name}-%{name}-%{version}

mkdir tmpbuild
pushd tmpbuild
%if 0%{?fedora} || 0%{?rhel} > 7
%cmake ..
%cmake3 ..


pushd tmpbuild

# From rpm version > 4.9.1, it may no longer be necessary to move the
# documentation out of the docdir path, as the %%doc macro no longer
# deletes the full directory before installing files into it.
mkdir -p %{mydocs}
mv %{buildroot}%{_docdir}/%{name}/html %{mydocs}
rm -f %{mydocs}/html/installdox

# Remove additional documentation files (those files are already available
# in the project top directory)
rm -f %{buildroot}%{_docdir}/%{name}/{NEWS,,AUTHORS}

%if %{with python3}
# (Pure) Python OpenTREP executable
install -d %{buildroot}%{python3_sitearch}/py%{name}
install -pm 0755 %{buildroot}%{_bindir}/py%{name} %{buildroot}%{python3_sitearch}/py%{name}/
rm -f %{buildroot}%{_bindir}/py%{name}
chmod a-x %{buildroot}%{python3_sitearch}/py%{name}/


%if 0%{?rhel} <= 7
%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%if %{with python3}
%post -n python3-%{name}
ln -s -f %{python3_sitearch}/py%{name}/py%{name} %{_bindir}/py%{name}

%postun -n python3-%{name}
rm -f %{_bindir}/py%{name}

%license COPYING
%doc AUTHORS ChangeLog NEWS
%dir %{_datadir}/%{name}
%dir %{_datadir}/%{name}/data
%dir %{_datadir}/%{name}/data/por

%files devel

%files doc
%doc %{mydocs}/html
%license COPYING

%if %{with python3}
%files -n python3-%{name}

* Sun Nov 24 2019 Denis Arnaud <> - 0.07.4-3
- Fixed a few typos in Pythn dependencies

* Fri Nov 15 2019 Denis Arnaud <> - 0.07.4-2
- Fixed the too long description line

* Mon Nov 11 2019 Denis Arnaud <> - 0.07.4-1
- Upstream update to 0.07.4