%global tcl_version %(echo 'puts $tcl_version' | tclsh)
%global tcl_sitelib %{_datadir}/tcl%{tcl_version}

Summary:       The standard Tcl library
Name:          tcllib
Version:       1.20
Release:       0
License:       BSD
URL:           http://tcllib.sourceforge.net/
Source:        https://downloads.sourceforge.net/tcllib/%{name}-%{version}.tar.xz
BuildArch:     noarch

Requires:      tcl(abi) = 8.6
BuildRequires: tcl >= 8.3.1

Patch0001:     0001-Fix-invalid-command-name-log.patch

%description
Tcllib, the Tcl Standard Library is a collection of Tcl packages
that provide utility functions useful to a large collection of Tcl
programmers.

%package       help
Requires:      tcl(abi) = 8.6
Summary:       help documentation for tcllib

%description   help
This package contains the help documentation for tcllib.

%prep
%autosetup -p1
chmod -x modules/doctools/mpformats/fr.msg

iconv --from=ISO-8859-1 --to=UTF-8 modules/struct/pool.html > modules/struct/pool.html.new
mv -f modules/struct/pool.html.new modules/struct/pool.html

%build

%install
%{_bindir}/tclsh installer.tcl -no-gui -no-wait -no-html -no-examples \
    -pkg-path %{buildroot}/%{tcl_sitelib}/%name-%version -app-path %{buildroot}%{_bindir} \
    -nroff-path %{buildroot}%_mandir/mann


find %{buildroot}/%{_datadir} -name \*.tcl | xargs chmod 0644

%files
%doc support/releases/PACKAGES ChangeLog
%doc modules/exif/*.html modules/ftp/docs/*.html modules/mime/*.html modules/stooop/*.html
%doc modules/textutil/*.html modules/struct/*.html
%license license.terms
%{tcl_sitelib}/%{name}-%{version}
%{_bindir}/dtplite
%{_bindir}/pt
%{_bindir}/nns*
%{_bindir}/page
%{_bindir}/tcldocstrip

%files help
%doc support/releases/history/README-1.9.txt
%{_mandir}/mann/*

%changelog
* Wed Jan 12 2022 wulei <wulei80@huawei.com> - 1.20-0
- Package update

* Thu Oct 15 2020 lingsheng <lingsheng@huawei.com> - 1.19-3
- Fix invalid command name log

* Wed Jan 08 2019 wanjiankang <wanjiankang@huawei.com> - 1.19-2
- Package Init.
