Name:              units
Version:           2.21
Release:           1
Summary:           A utility for converting amounts from one unit to another
License:           GPLv3+
URL:               https://www.gnu.org/software/units/units.html
Source:            https://ftp.gnu.org/gnu/units/%{name}-%{version}.tar.gz

BuildRequires:     automake bison gcc ncurses-devel python3-devel readline-devel
Requires:          python3-requests
Requires(post):    /sbin/install-info
Requires(preun):   /sbin/install-info

%description
Units is a program for units conversion and units calculation.
The program converts quantities expressed in various scales to
their equivalents in other scales.
Units can only handle multiplicative scale changes.
For example, it cannot convert Celsius to Fahrenheit
but it can convert temperature differences between those temperature scales.

%package           help
Summary:           Help documents for units

%description       help
The units-help package conatins manual pages and other related files for units.

%prep
%autosetup -p1

sed -e 's|^AC_PATH_PROG(PYTHON, .*$|PYTHON=%{__python3}\nAC_SUBST(PYTHON)|' \
    -i configure.ac
autoreconf -fiv

%build
%configure
%make_build

%install
%make_install

gzip $RPM_BUILD_ROOT%{_infodir}/units.info
ln -s units.1 %{buildroot}%{_mandir}/man1/units_cur.1

%check
make check

%post
if [ -e %{_infodir}/units.info.gz ]; then
  /sbin/install-info %{_infodir}/units.info.gz %{_infodir}/dir || :
fi

%preun
if [ $1 = 0 -a -e %{_infodir}/units.info.gz ]; then
  /sbin/install-info --delete %{_infodir}/units.info.gz %{_infodir}/dir || :
fi

%files
%doc COPYING ChangeLog NEWS README
%{_bindir}/*
%{_datadir}/units
%{_sharedstatedir}/units

%files help
%{_infodir}/*
%{_mandir}/man1/*

%changelog
* Tue Jan 18 2022 SimpleUpdate Robot <tc@openeuler.org> - 2.21-1
- Upgrade to version 2.21

* Fri Feb 07 2020 lihao <lihao129@huawei.com> - 2.17-8
- Package init
