File docbook2x.spec of Package docbook2x

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


Name:           docbook2x
BuildRequires:  automake
BuildRequires:  docbook_4
BuildRequires:  libxslt-devel
%if 0%{?suse_version} >= 1200
BuildRequires:  makeinfo
%endif
BuildRequires:  openjade
BuildRequires:  perl-XML-DOM
BuildRequires:  perl-XML-Parser
BuildRequires:  perl-XML-SAX
BuildRequires:  perl-libwww-perl
BuildRequires:  sgml-skel
BuildRequires:  tidy
Url:            http://docbook2x.sourceforge.net/
Provides:       db2x
Provides:       docbook2X
Requires:       docbook_4
Requires:       openjade
Requires:       opensp
Requires:       perl-URI
Requires:       perl-XML-DOM
Requires:       perl-XML-Parser
Requires:       perl-XML-RegExp
Requires:       perl-XML-SAX
Requires:       perl-libwww-perl
Requires:       sgml-skel
Requires:       tidy
%define regcat /usr/bin/sgml-register-catalog
PreReq:         %{regcat} /usr/bin/xmlcatalog /usr/bin/edit-xml-catalog
PreReq:         sed grep awk
Obsoletes:      db2x
Summary:        DocBook-to-Texinfo Converter
License:        GPL-2.0+
Group:          Productivity/Publishing/DocBook
Version:        0.8.8
Release:        0
Source:         http://downloads.sourceforge.net/docbook2x/docbook2X-%{version}.tar.bz2
#Source:       http://ftp1.sourceforge.net/sourceforge/docbook2x/docbook2X-%{version}.tar.gz
Source1:        docbook2x-README.SuSE
Patch:          docbook2X-0.8.8-catalog.diff
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
A new tool based on Perl modules.

%package doc
Summary:        DocBook-to-Texinfo Converter
Group:          Productivity/Publishing/DocBook
PreReq:         %install_info_prereq

%description doc
A new tool based on Perl modules.

%define INSTALL install -m755 -s
%define INSTALL_SCRIPT install -m755
%define INSTALL_DIR install -d -m755
%define INSTALL_DATA install -m644

%prep
#echo %{_docdir}
#echo %{_defaultdocdir}
%setup -q -n docbook2X-%{version}
cp %{S:1} README.SuSE
%patch -p 1
%define perl_site %(TMP=%{perl_sitearch}; echo ${TMP%/*})

%build
autoreconf --force --install
%configure --with-xmldecl=/usr/share/sgml/opensp/xml.dcl
sed -i.bak 's/${prefix}/\/usr/' perl/config.pl
# exit 1
make htmldir=%{_docdir}/%{name}/html %{?_smp_mflags}
%define FOR_ROOT_CAT for-catalog-%{name}-%{version}.xml
xmlcatbin=/usr/bin/xmlcatalog
CATALOG=usr/share/docbook2X/dtd/catalog.xml
rm -f %{FOR_ROOT_CAT}.tmp
$xmlcatbin --noout --create %{FOR_ROOT_CAT}.tmp
$xmlcatbin --noout --add "delegateSystem" \
  "http://docbook2x.sf.net/latest/" \
  "file:///$CATALOG" %{FOR_ROOT_CAT}.tmp
# Create tag
sed '/<catalog/a\
  <group id="%{name}-%{version}">
/<\/catalog/i\
  </group>' \
  %{FOR_ROOT_CAT}.tmp > %{FOR_ROOT_CAT}

%install
make install DESTDIR=$RPM_BUILD_ROOT \
  nsgmls_xmldecl=/usr/share/sgml/opensp/xml.dcl \
  htmldir=%{_docdir}/%{name}/html
install -m644 AUTHORS COPYING NEWS README README.SuSE \
  $RPM_BUILD_ROOT%{_docdir}/%{name}
rm -f $RPM_BUILD_ROOT/%{_infodir}/dir
mv $RPM_BUILD_ROOT%{_mandir}/man1/docbook2man.1 \
  $RPM_BUILD_ROOT%{_mandir}/man1/docbook-to-man.1
mv $RPM_BUILD_ROOT%{_mandir}/man1/docbook2texi.1 \
  $RPM_BUILD_ROOT%{_mandir}/man1/docbook-to-texi.1
mv $RPM_BUILD_ROOT%{_bindir}/docbook2man \
  $RPM_BUILD_ROOT%{_bindir}/docbook-to-man
mv $RPM_BUILD_ROOT%{_bindir}/docbook2texi \
  $RPM_BUILD_ROOT%{_bindir}/docbook-to-texi
%perl_process_packlist
cat_dir=%{buildroot}/etc/xml
%{INSTALL_DIR} $cat_dir
%{INSTALL_DATA} %{FOR_ROOT_CAT} $cat_dir
%define all_cat %{name}-%{version}
%define info_files docbook2texi-xslt docbook2man-xslt docbook2X

%post
edit-xml-catalog --group --catalog /etc/xml/suse-catalog.xml \
  --add /etc/xml/%{FOR_ROOT_CAT}

%postun
# remove entries only on removal of file
if [ ! -f %{xml_sysconf_dir}/%{FOR_ROOT_CAT} -a -x /usr/bin/edit-xml-catalog ] ; then
  edit-xml-catalog --group --catalog /etc/xml/suse-catalog.xml \
    --del %{name}-%{version}
fi
exit 0

%post doc
for f in %{info_files}; do
  %install_info --info-dir=%{_infodir} %{_infodir}/${f}.info.gz
done

%preun doc
for f in %{info_files}; do
  %install_info_delete --info-dir=%{_infodir} %{_infodir}/${f}.info.gz
done

%files
%defattr(-, root, root)
%config %{_sysconfdir}/xml/%{FOR_ROOT_CAT}
%{_bindir}/*
%{_datadir}/docbook2X

%files doc
%defattr(-, root, root)
%{_docdir}/%{name}
%{_infodir}/*
%{_mandir}/*/*

%changelog
openSUSE Build Service is sponsored by