File dateutils.spec of Package dateutils

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


%define build_release_tarball 1

%define have_octave 0
%if 0%{?suse_version} >= 1220 && 0%{?suse_version} != 1315
%define have_octave 1
%ifarch aarch64
%if 0%{?suse_version} <= 1310
%define have_octave 0
%endif
%endif
%ifnarch i586 x86_64
%if 0%{?suse_version} < 1310
%define have_octave 0
%endif
%endif
%endif
%if 0%{?fedora_version} >= 19
%define have_octave 1
%endif
Name:           dateutils
Version:        0.4.10.git12.0ee12
Release:        0
Summary:        Nifty command line date and time utilities
License:        BSD-3-Clause
Group:          Productivity/Text/Utilities
Url:            https://github.com/hroptatyr/dateutils/
Source:         %{name}-%{version}.tar.xz
%if %{build_release_tarball}
Source1:        %{name}-rpmlintrc
%endif
# required for git builds only
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  bison
BuildRequires:  flex
BuildRequires:  gperf
BuildRequires:  libtool
%if 0%{?suse_version} >= 1220
BuildRequires:  makeinfo
%endif
# required for dist builds
BuildRequires:  pkgconfig
BuildRequires:  xz
%if 0%{?suse_version}
BuildRequires:  timezone
%endif
%if %{have_octave}
BuildRequires:  octave-devel
%endif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Requires(pre):  info

%description
Dateutils are a bunch of tools that revolve around fiddling with dates
and times in the command line with a strong focus on use cases that
arise when dealing with large amounts of financial data. Their target
market is shell scripts that need date calculations or calendar
conversions, and as such they are highly pipe-able and modeled after
their well-known cousins (e.g. dtest vs. test, or dgrep vs. grep).

%if %{have_octave}
%package octave
Summary:        Dateutils functions for matlab and octave
Group:          Development/Libraries/Other
Requires:       %{name} = %{version}
Requires:       octave

%description octave
Dateutils can be used from within matlab or ocatave.
%endif

%if %{build_release_tarball}
%package release-tarball
Summary:        Tarball to be released by upstream
Group:          Development/Libraries/Other
Requires:       do_not_install_this_but_unrpm

%description release-tarball
This packackge contains a clean "make dist" tarball to be released by
upstream maintainers. Do not install this package. Just unrpm it. In
doubt you'll never need it at all.
%endif

%prep
%setup -q

%build
# set git version number for yuck
test -f .version || echo %{version} > .version
autoreconf -vfi
%configure \
    --docdir=%{_docdir}/%{name} \
%if %{have_octave}
    --enable-contrib \
%endif
    ignorethisline=xxx
make %{?_smp_mflags} V=1

%install
%{?make_install} %{!?make_install:make install DESTDIR=%{buildroot}}
rm -f %{buildroot}%{_infodir}/dir
rm -f %{buildroot}%{_libdir}/octave/site/oct/*/dateutils/tzconv.la
# install dist tarball and create file list for release-tarball package
%if %{build_release_tarball}
make dist
dist_tarball="$(find -maxdepth 1 -name "%{name}-*.tar.xz")"
dist_tarball_dst="$(echo "%{distribution}" | sed 's,.* ,/release_obs_,g')"
mkdir -p "%{buildroot}${dist_tarball_dst}"
cp -a "${dist_tarball}" "%{buildroot}${dist_tarball_dst}"
echo "%dir ${dist_tarball_dst}" > /tmp/files_release_tarball
echo "${dist_tarball_dst}/${dist_tarball}" >> /tmp/files_release_tarball
%endif

%check
if ! make check; then
    cat test/test-suite.log
    exit 1
fi
%if %{build_release_tarball}
# redirect distcheck output to not confuse our rpmlint
if ! make distcheck DVIS="" &> make_distcheck.log ;then
    cat make_distcheck.log
    echo "make distcheck failed"
    exit 1
fi
%endif

%clean
rm -rf %{buildroot}

# How to make that info stuff portable?
%if 0%{?install_info:1} > 0
%post
%install_info --info-dir=%{_infodir} %{_infodir}/%{name}.info*

%postun
%install_info_delete --info-dir=%{_infodir} %{_infodir}/%{name}.info*
%endif

%files
%defattr(-,root,root)
%doc %{_docdir}/%{name}
%{_bindir}/dadd
%{_bindir}/dconv
%{_bindir}/ddiff
%{_bindir}/dgrep
%{_bindir}/dround
%{_bindir}/dseq
%{_bindir}/dsort
%{_bindir}/dtest
%{_bindir}/dzone
%{_bindir}/dateadd
%{_bindir}/dateconv
%{_bindir}/datediff
%{_bindir}/dategrep
%{_bindir}/dateround
%{_bindir}/dateseq
%{_bindir}/datesort
%{_bindir}/datetest
%{_bindir}/datezone
%{_bindir}/strptime
%dir %{_datadir}/dateutils/
%{_datadir}/dateutils/locale
%{_infodir}/%{name}.info*
%{_mandir}/man1/%{name}.1*
%{_mandir}/man1/dadd.1*
%{_mandir}/man1/dconv.1*
%{_mandir}/man1/ddiff.1*
%{_mandir}/man1/dgrep.1*
%{_mandir}/man1/dround.1*
%{_mandir}/man1/dseq.1*
%{_mandir}/man1/dsort.1*
%{_mandir}/man1/dtest.1*
%{_mandir}/man1/dzone.1*
%{_mandir}/man1/dateadd.1*
%{_mandir}/man1/dateconv.1*
%{_mandir}/man1/datediff.1*
%{_mandir}/man1/dategrep.1*
%{_mandir}/man1/dateround.1*
%{_mandir}/man1/dateseq.1*
%{_mandir}/man1/datesort.1*
%{_mandir}/man1/datetest.1*
%{_mandir}/man1/datezone.1*
%{_mandir}/man1/strptime.1*

%if %{have_octave}
%files octave
%defattr(-,root,root)
%dir %{_libdir}/octave/site/oct/*/dateutils/
%{_libdir}/octave/site/oct/*/dateutils/tzconv.m
%{_libdir}/octave/site/oct/*/dateutils/tzconv.mex
%endif

%if %{build_release_tarball}
%files release-tarball -f /tmp/files_release_tarball
%defattr(-,root,root)
%endif

%changelog
openSUSE Build Service is sponsored by