Name: asciidoc
Version: 9.1.0
Release: 1
Summary: Python 3 port of Asciidoc Python.
License: GPLv2
URL: http://asciidoc.org
Source0: https://github.com/%{name}-py/asciidoc-py/archive/%{version}/%{name}-py-%{version}.tar.gz

BuildRequires: python3-devel docbook-style-xsl graphviz libxslt source-highlight
BuildRequires: texlive-dvisvgm-bin vim-filesystem symlinks automake autoconf

Requires: python3 docbook-style-xsl graphviz libxslt source-highlight vim-filesystem
Requires: %{name} = %{version}-%{release}

Obsoletes: %{name}-latex < %{version}-%{release} %{name}-music < %{version}-%{release}
Provides: %{name}-latex = %{version}-%{release} %{name}-music = %{version}-%{release}

BuildArch: noarch

%description
Python 3 port of Asciidoc Python, this is a development work in progress,
but passes all tests, real world testing is very much welcomed.

%package_help
Requires: %{name} = %{version}-%{release}

Obsoletes: %{name}-doc < %{version}-%{release}
Provides: %{name}-doc = %{version}-%{release}

%prep
%autosetup -n %{name}-py-%{version}

%build
autoreconf -v
%configure
%make_build

%install
make install docs DESTDIR=%{buildroot}
install -d -m 755 %{buildroot}%{_datadir}/%{name}/
for d in  docbook-xsl images javascripts stylesheets; do
    mv -v %{buildroot}%{_sysconfdir}/%{name}/$d %{buildroot}%{_datadir}/%{name}/
    ln -s %{buildroot}%{_datadir}/%{name}/$d %{buildroot}%{_sysconfdir}/%{name}/
    rm -rf %{buildroot}%{_docdir}/%{name}/$d
    ln -s %{buildroot}%{_datadir}/%{name}/$d %{buildroot}%{_docdir}/%{name}/
done

mkdir -p %{buildroot}%{python3_sitelib}/
sed '1d' asciidocapi.py > %{buildroot}%{python3_sitelib}/asciidocapi.py
chmod -x %{buildroot}%{python3_sitelib}/asciidocapi.py
touch -r asciidocapi.py %{buildroot}%{python3_sitelib}/asciidocapi.py

for file in %{buildroot}{%{_bindir},%{_sysconfdir}/%{name}/filters/*}/*.py ; do
    touch ${file}{c,o}
done

mkdir -p %{buildroot}/%{_datadir}/vim/vimfiles/{ftdetect,syntax}
for file in $(cd vim; find * -type f); do
    install -m 0644 vim/$file %{buildroot}/%{_datadir}/vim/vimfiles/$file
done

symlinks -cdr %{buildroot}

# Clean up no needed doc files
rm -f %{buildroot}/%{_pkgdocdir}/INSTALL.txt
rm -f %{buildroot}/%{_mandir}/man1/testasciidoc.1*

%check
export PATH="../:$PATH"
cd tests
%{__python3} testasciidoc.py update
%{__python3} testasciidoc.py run
cd ..

%pre

%preun

%post

%postun

%files
%doc BUGS.txt CHANGELOG.txt README.asciidoc
%license COPYRIGHT
%config(noreplace) %{_sysconfdir}/%{name}/
%dir %{_sysconfdir}/%{name}/filters/latex
%{_sysconfdir}/%{name}/filters/latex/*.py
%config(noreplace) %{_sysconfdir}/%{name}/filters/latex/*.conf
%dir %{_sysconfdir}/%{name}/filters/music
%config(noreplace) %{_sysconfdir}/%{name}/filters/music/*.conf
%{_sysconfdir}/%{name}/filters/music/*.py
%{_bindir}/a2x
%{_bindir}/a2x.py
%{_bindir}/%{name}
%{_bindir}/asciidoc.py
%{_datadir}/%{name}/
%{python3_sitelib}/asciidocapi.py*
%{python3_sitelib}/__pycache__/asciidocapi*
%exclude %{_bindir}/*.py[co]
%exclude %{_sysconfdir}/%{name}/filters/*/*.py[co]
%exclude %{_pkgdocdir}/doc
%exclude %{_pkgdocdir}/website
%exclude %{_pkgdocdir}/{docbook-xsl,images,javascripts,stylesheets}

%files help
%doc %{_mandir}/man1/a2x.1*
%doc %{_mandir}/man1/asciidoc.1*
%{_pkgdocdir}/doc
%{_pkgdocdir}/website
%{_pkgdocdir}/{dblatex,docbook-xsl,images,javascripts,stylesheets}
%exclude %{_docdir}/%{name}/{COPYING,COPYRIGHT,README.asciidoc}

%changelog
* Tue Jun 14 2022 dillon chen <dillon.chen@gmail.com> - 9.1.0-1
- upgrade to 9.1.0

* Thu Nov 12 2020 shixuantong <shixuantong@huawei.com> - 9.0.4-1
- Type:NA
- ID:NA
- SUG:NA
- DESC:Update to latest upstream release 9.0.4 and update Source0

* Mon Oct 28 2019 caomeng <caomeng5@huawei.com> - 8.6.10-3
- Type:NA
- ID:NA
- SUG:NA
- DESC:remove build requirement ImageMagick

* Mon Oct 21 2019 openEuler Buildteam <buildteam@openeuler.org> - 8.6.10-2
- Package rebuild.

* Mon Sep 09 2019 openEuler Buildteam <buildteam@openeuler.org> - 8.6.10-1
- Package init.
