Summary: Text based document generation
Summary(ja): テキストベースのドキュメント生成
Name: asciidoc
Version: 9.1.0
Release: 2%{?_dist_release}
Group: office
Vendor: Project Vine
Distribution: Vine Linux
Packager: daisuke, kenta

License: GPLv2+
URL: https://asciidoc.org/
Source0: https://github.com/asciidoc-py/asciidoc-py/releases/download/%{version}/%{name}-%{version}.tar.gz

BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires: python3
BuildRequires: symlinks
Requires: python3
Requires: docbook-style-xsl
Requires: libxslt
Requires: graphviz
Requires: source-highlight

%description
AsciiDoc is a text document format for writing short documents,
articles, books and UNIX man pages. AsciiDoc files can be translated
to HTML and DocBook markups using the asciidoc(1) command.


%package doc
Summary:  Additional documentation and examples for asciidoc
Group: documentation
Requires: %{name} = %{version}-%{release}

%description doc
%{summary}.


%package latex
Summary:  Support for asciidoc latex output
Group: publishing
Requires: %{name} = %{version}-%{release}
Requires: dblatex

%description latex
%{summary}.


%prep
%setup -q
# Convert files to utf-8
for file in README.asciidoc doc/*.dict website/*.dict; do
    iconv -f ISO-8859-1 -t UTF-8 -o $file.new $file && \
    touch -r $file $file.new && \
    mv $file.new $file
done

# Remove music files
rm -rf %{buildroot}{%{_sysconfdir}/asciidoc/filters/music,%{_sysconfdir}/asciidoc/filters/music/*.conf,%{_sysconfdir}/asciidoc/filters/music/*.py}

# Fix python shebang
grep -rl '#!/usr/bin/env python' | xargs -r \
    sed -i -e '1s@#!/usr/bin/env python3\?$@#!%{__python3}@'


%build
autoreconf -v
%configure
%make_build


%install
make install docs DESTDIR=%{buildroot}

install -dm 755 %{buildroot}%{_datadir}/asciidoc/
# Real conf data goes to sysconfdir, rest to datadir; symlinks so asciidoc works
for d in dblatex docbook-xsl images javascripts stylesheets; do
    mv -v %{buildroot}%{_sysconfdir}/asciidoc/$d \
          %{buildroot}%{_datadir}/asciidoc/
    # Absolute symlink into buildroot is intentional, see below
    ln -s %{buildroot}%{_datadir}/%{name}/$d %{buildroot}%{_sysconfdir}/%{name}/

    # Let's symlink stuff for documentation as well so we don't duplicate things
    rm -rf %{buildroot}%{_docdir}/%{name}/$d
    # Absolute symlink into buildroot is intentional, see below
    ln -s %{buildroot}%{_datadir}/%{name}/$d %{buildroot}%{_docdir}/%{name}/
done

# Python API
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

# Make it easier to %%exclude these with both rpm < and >= 4.7
for file in %{buildroot}{%{_bindir},%{_sysconfdir}/asciidoc/filters/*}/*.py ; do
    touch ${file}{c,o}
done

# Clean up no needed doc files
rm -f %{buildroot}%{_pkgdocdir}/INSTALL.txt
rm -f %{buildroot}%{_mandir}/man1/testasciidoc.1*
rm -f %{buildroot}%{_bindir}/*.py[co]
rm -f %{buildroot}%{_sysconfdir}/asciidoc/filters/*/*.py[co]

# Absolute symlinks were used above to be able to detect dangling ones. Make
# them relative now (sane for being installed) and remove dangling symlinks.
for l in $(find %{buildroot} -type l); do symlinks -cdov $l; done


%pre
# fix conflict with asciidoc < 9.1.0
if [ ! -L %{_sysconfdir}/asciidoc/dblatex ]; then
	rm -rf %{_sysconfdir}/asciidoc/dblatex
fi


%files
%defattr(-,root,root,0755)
%license COPYRIGHT
%doc BUGS.txt CHANGELOG.txt README*
%dir %{_sysconfdir}/asciidoc
%config(noreplace) %{_sysconfdir}/asciidoc/*
%{_bindir}/*
%{_mandir}/man1/*
%{python3_sitelib}/asciidocapi.py*
%{_datadir}/asciidoc/
%exclude %{_sysconfdir}/asciidoc/dblatex
%exclude %{_sysconfdir}/asciidoc/filters/latex
%exclude %{_sysconfdir}/asciidoc/filters/music
%exclude %{_pkgdocdir}/website
%exclude %{_pkgdocdir}/doc
%exclude %{_pkgdocdir}/{dblatex,docbook-xsl,images,javascripts,stylesheets}

%files doc
%{_pkgdocdir}/website
%{_pkgdocdir}/doc
%{_pkgdocdir}/{dblatex,docbook-xsl,images,javascripts,stylesheets}
%exclude %{_docdir}/%{name}/{COPYRIGHT,README.asciidoc}

%files latex
%dir %{_sysconfdir}/asciidoc
%{_sysconfdir}/asciidoc/dblatex
%dir %{_sysconfdir}/asciidoc/filters/latex
%{_sysconfdir}/asciidoc/filters/latex/*.py
%config(noreplace) %{_sysconfdir}/asciidoc/filters/latex/*.conf


%changelog
* Tue Mar 23 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 9.1.0-2
- fixed conflict with asciidoc < 9.1.0.

* Mon Mar 22 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 9.1.0-1
- new upstream release.

* Tue Jan  6 2015 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 8.6.9-1
- new upstream version
- moved to Applications/Text Group

* Sun Feb 26 2012 Munehiro Yamamoto <munepi@vinelinux.org> 8.6.6-1
- new upstream version

* Sun Feb 19 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 8.6.4-2
- rebuild with python-2.7.2

* Tue Apr 26 2011 NAKAMURA Kenta <kenta@vinelinux.org> 8.6.4-1
- new upstream version 8.6.4

* Wed Aug 20 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 8.2.5-1
- initial build for Vine Linux

* Wed Dec 05 2007 Florian La Roche <laroche@redhat.com> - 8.2.5-2
- remove doc/examples from filelist due to dangling symlinks

* Tue Nov 20 2007 Florian La Roche <laroche@redhat.com> - 8.2.5-1
- new upstream version 8.2.5

* Mon Oct 22 2007 Florian La Roche <laroche@redhat.com> - 8.2.3-1
- new upstream version 8.2.3

* Sat Sep 01 2007 Florian La Roche <laroche@redhat.com> - 8.2.2-1
- new upstream version 8.2.2

* Mon Mar 19 2007 Chris Wright <chrisw@redhat.com> - 8.1.0-1
- update to asciidoc 8.1.0

* Thu Sep 14 2006 Chris Wright <chrisw@redhat.com> - 7.0.2-3
- rebuild for Fedora Extras 6

* Tue Feb 28 2006 Chris Wright <chrisw@redhat.com> - 7.0.2-2
- rebuild for Fedora Extras 5

* Mon Aug 29 2005 Chris Wright <chrisw@osdl.org> - 7.0.2-1
- convert spec file to UTF-8
- Source should be URL
- update to 7.0.2

* Fri Aug 19 2005 Chris Wright <chrisw@osdl.org> - 7.0.1-3
- consistent use of RPM_BUILD_ROOT

* Thu Aug 18 2005 Chris Wright <chrisw@osdl.org> - 7.0.1-2
- Update BuildRoot
- use _datadir
- use config and _sysconfdir

* Wed Jun 29 2005 Terje RÃ¸sten <terje.rosten@ntnu.no> - 7.0.1-1
- 7.0.1
- Drop patch now upstream
- Build as noarch (Petr KlÃ­ma)

* Sat Jun 11 2005 Terje RÃ¸sten <terje.rosten@ntnu.no> - 7.0.0-0.3
- Add include patch 

* Fri Jun 10 2005 Terje RÃ¸sten <terje.rosten@ntnu.no> - 7.0.0-0.2
- Fix stylesheets according to Stuart

* Fri Jun 10 2005 Terje RÃ¸sten <terje.rosten@ntnu.no> - 7.0.0-0.1
- Initial package
- Based on Debian package, thx!


