%global xmlxsdver 2009/01

Summary:        Common SGML catalog and DTD files.
Summary(ja):    共用 SGML カタログ及び DTD ファイル集
Name:           sgml-common
Version:        0.6.3
Release:        42%{?_dist_release}
Group:          Applications/Text
Vendor:         Project Vine
Distribution:   Vine Linux
BuildArch:      noarch
BuildRoot:      %{_tmppath}/%{name}-%{version}-root

License:        GPL+
#Actually - there is no homepage of this project, on that URL
#page you could get complete ISO 8879 listing as was on the
#old page - only part of it is included in sgml-common package.
URL:            http://www.w3.org/2003/entities/
Source0:        ftp://sources.redhat.com/pub/docbook-tools/new-trials/SOURCES/%{name}-%{version}.tgz
# From openjade:
Source1:        xml.dcl
Source2:        xml.soc
Source3:        html.dcl
Source4:        html.soc
Source5:        http://www.w3.org/%{xmlxsdver}/xml.xsd
Source6:        http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd
Source7:        http://www.w3.org/2001/XMLSchema.dtd
Source8:        http://www.w3.org/2001/datatypes.dtd
Source9:        sgmlwhich.1
Source10:       sgml.conf.5
Patch0:         sgml-common-umask.patch
Patch1:         sgml-common-xmldir.patch
Patch2:         sgml-common-quotes.patch

BuildRequires:  libxml2 >= 2.4.8
BuildRequires:  automake
Requires:       /bin/basename

%description
The sgml-common package contains a collection of entities and DTDs
that are useful for processing SGML, but that don't need to be
included in multiple packages.  Sgml-common also includes an
up-to-date Open Catalog file.

%package -n xml-common
Summary: Common XML catalog and DTD files.
Summary(ja): 共用 XML カタログ及び DTD ファイル集
License: GPL+
Group: Applications/Text
Requires(pre): %{_bindir}/xmlcatalog

%description -n xml-common
The xml-common package contains a collection of entities and DTDs
that are useful for processing XML, but that don't need to be
included in multiple packages.

%prep
%setup -q
%patch0 -p1 -b .umask
%patch1 -p1 -b .xmldir
%patch2 -p1 -b .quotes

# replace bogus links with files
automakedir=`ls -1d /usr/share/automake* | head -n +1`
for file in COPYING INSTALL install-sh missing mkinstalldirs; do
   rm $file
   cp -p $automakedir/$file .
done

%build
%configure

%install
[ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT htmldir='%{_datadir}/doc' INSTALL='install -p'

mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/xml
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sgml/docbook
mkdir -p $RPM_BUILD_ROOT%{_datadir}/sgml/docbook
# Touch SGML catalog
touch $RPM_BUILD_ROOT%{_sysconfdir}/sgml/catalog
# Create an empty XML catalog.
XMLCATALOG=$RPM_BUILD_ROOT%{_sysconfdir}/xml/catalog
%{_bindir}/xmlcatalog --noout --create $XMLCATALOG
# ...and add xml.xsd in it
for type in system uri ; do
	for path in 2001 %{xmlxsdver} ; do
		%{_bindir}/xmlcatalog --noout --add $type \
			"http://www.w3.org/$path/xml.xsd" \
			"file://%{_datadir}/xml/xml.xsd" $XMLCATALOG
	done
	# Add xmldsig-core-schema.xsd to catalog
	%{_bindir}/xmlcatalog --noout --add $type \
		"http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd" \
		"file://%{_datadir}/xml/xmldsig-core-schema.xsd" $XMLCATALOG
done

# Now put the common DocBook entries in it
%{_bindir}/xmlcatalog --noout --add "delegatePublic" \
	"-//OASIS//ENTITIES DocBook XML" \
	"file://%{_sysconfdir}/sgml/docbook/xmlcatalog" $XMLCATALOG
%{_bindir}/xmlcatalog --noout --add "delegatePublic" \
	"-//OASIS//DTD DocBook XML" \
	"file://%{_sysconfdir}/sgml/docbook/xmlcatalog" $XMLCATALOG
%{_bindir}/xmlcatalog --noout --add "delegatePublic" \
	"ISO 8879:1986" \
	"file://%{_sysconfdir}/sgml/docbook/xmlcatalog" $XMLCATALOG
%{_bindir}/xmlcatalog --noout --add "delegateSystem" \
	"http://www.oasis-open.org/docbook/" \
	"file://%{_sysconfdir}/sgml/docbook/xmlcatalog" $XMLCATALOG
%{_bindir}/xmlcatalog --noout --add "delegateURI" \
	"http://www.oasis-open.org/docbook/" \
	"file://%{_sysconfdir}/sgml/docbook/xmlcatalog" $XMLCATALOG
for public in "-//W3C//DTD XMLSchema 200102//EN" "-//W3C//DTD XMLSCHEMA 200102//EN" ; do
	%{_bindir}/xmlcatalog --noout --add "public" \
		"$public" \
		"file://%{_datadir}/xml/XMLSchema.dtd" $XMLCATALOG
done
%{_bindir}/xmlcatalog --noout --add "system" \
	"http://www.w3.org/2001/XMLSchema.dtd" \
	"file://%{_datadir}/xml/XMLSchema.dtd" $XMLCATALOG

# Also create the common DocBook catalog
%{_bindir}/xmlcatalog --noout --create \
	$RPM_BUILD_ROOT%{_sysconfdir}/sgml/docbook/xmlcatalog
ln -sf %{_sysconfdir}/sgml/docbook/xmlcatalog\
	$RPM_BUILD_ROOT%{_datadir}/sgml/docbook/xmlcatalog

rm -f $RPM_BUILD_ROOT%{_datadir}/sgml/xml.dcl
install -p -m0644 %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} \
	$RPM_BUILD_ROOT%{_datadir}/sgml
rm -rf $RPM_BUILD_ROOT%{_datadir}/xml/*
install -p -m0644 %{SOURCE5} %{SOURCE6} %{SOURCE7} %{SOURCE8} \
        $RPM_BUILD_ROOT%{_datadir}/xml
mkdir -p $RPM_BUILD_ROOT%{_mandir}/man1
mkdir -p $RPM_BUILD_ROOT%{_mandir}/man5
install -p -m0644 %{SOURCE9} $RPM_BUILD_ROOT%{_mandir}/man1
install -p -m0644 %{SOURCE10} $RPM_BUILD_ROOT%{_mandir}/man5

# remove installed doc file and prepare installation with %%doc
rm -f $RPM_BUILD_ROOT%{_datadir}/doc/*.html
rm -rf __dist_doc/html/
mkdir -p __dist_doc/html/
cp -p doc/HTML/*.html __dist_doc/html/

%clean
[ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf $RPM_BUILD_ROOT

%pre -n xml-common
if [ $1 -gt 1 ] && [ -e %{_sysconfdir}/xml/catalog ]; then
	for type in system uri ; do
		for path in 2001 %{xmlxsdver} ; do
			%{_bindir}/xmlcatalog --noout --add $type \
				"http://www.w3.org/$path/xml.xsd" \
				"file://%{_datadir}/xml/xml.xsd" \
				%{_sysconfdir}/xml/catalog
		done
		%{_bindir}/xmlcatalog --noout --add $type \
			"http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd" \
			"file://%{_datadir}/xml/xmldsig-core-schema.xsd" %{_sysconfdir}/xml/catalog
	done
	for public in "-//W3C//DTD XMLSchema 200102//EN" "-//W3C//DTD XMLSCHEMA200102//EN" ; do
		%{_bindir}/xmlcatalog --noout --add "public" \
			"$public" \
			"file://%{_datadir}/xml/XMLSchema.dtd" %{_sysconfdir}/xml/catalog
	done
fi

%files
%defattr (-,root,root)
%license COPYING
%doc __dist_doc/html/ AUTHORS NEWS ChangeLog README
%dir %{_sysconfdir}/sgml
%config(noreplace) %{_sysconfdir}/sgml/sgml.conf
%ghost %verify(not md5 size mtime) %config(noreplace,missingok) %{_sysconfdir}/sgml/catalog
%dir %{_datadir}/sgml
%dir %{_datadir}/sgml/sgml-iso-entities-8879.1986
%{_datadir}/sgml/sgml-iso-entities-8879.1986/*
%{_datadir}/sgml/xml.dcl
%{_datadir}/sgml/xml.soc
%{_datadir}/sgml/html.dcl
%{_datadir}/sgml/html.soc
%{_bindir}/sgmlwhich
%{_bindir}/install-catalog
%{_mandir}/man8/install-catalog.8*
%{_mandir}/man1/sgmlwhich.1*
%{_mandir}/man5/sgml.conf.5*

%files -n xml-common
%defattr (-,root,root)
%license COPYING
%doc AUTHORS NEWS ChangeLog README
%dir %{_sysconfdir}/xml
%dir %{_sysconfdir}/sgml
%dir %{_sysconfdir}/sgml/docbook
%config(noreplace) %verify(not md5 size mtime) %{_sysconfdir}/xml/catalog
%config(noreplace) %verify(not md5 size mtime) %{_sysconfdir}/sgml/docbook/xmlcatalog
%dir %{_datadir}/sgml
%dir %{_datadir}/sgml/docbook
%{_datadir}/sgml/docbook/xmlcatalog
%dir %{_datadir}/xml
%{_datadir}/xml/xml.xsd
%{_datadir}/xml/xmldsig-core-schema.xsd
%{_datadir}/xml/XMLSchema.dtd
%{_datadir}/xml/datatypes.dtd

%changelog
* Sat Apr 11 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.6.3-42
- imported Source6-10 from rawhide.

* Sun Nov 16 2014 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 0.6.3-41
- updated based on Fedora 0.6.3-41
  * Thu Oct 11 2012 Ondrej Vasik <ovasik@redhat.com> 0.6.3-38
  - get rid of the explicit automake14 requirement
  * Sun Oct 30 2011 Ville Skyttä <ville.skytta@iki.fi> - 0.6.3-35
  - Include xml.xsd in xml-common (#750073).
  
* Mon Dec 30 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.6.3-35
- rebuild with VineSeed environment

* Fri Apr 22 2011 IWAI, Masaharu <iwai@alib.jp> 0.6.3-34
- sync Fedora 0.6.3-34
 * Wed Feb 09 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.3-34
 -  Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
 * Mon Jul 12 2010 Ondrej Vasik <ovasik@redhat.com> 0.6.3-33
 - ship COPYING file with both sgml-common and xml-common
 - ship documentation with xml-common

* Sat Mar  6 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 0.6.3-33
- updated based on FC 0.6.3-32 
  * Tue Jul 01 2008 Ondrej Vasik <ovasik@redhat.com> 0.6.3-25
  - mark xmlcatalog config(noreplace) to prevent overwriting
    of the content, move it to sysconfdir and make symlink for
    it to silence rpmlint
  * Mon Jun 30 2008 Ondrej Vasik <ovasik@redhat.com> 0.6.3-24
  - mark catalog files as (not md5 size mtime) for verify to
    prevent info about changed files
  * Thu Nov 15 2007 Ondrej Vasik <ovasik@redhat.com> 0.6.3-22
  - Merge Review(226415)
  - changed: License Tag, using RPM macros instead of hardcoded
    dirs, summary ended with dot, added URL, removed CHANGES
    file as obsolete, preserved timestamps and some other cosmetic
    changes
  - no longer shipping old automake tarball, fixed issue with man8_DATA,
    BuildRequire:Automake,Autoconf again(see MergeReview discussion)

* Sun Jun  8 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 0.6.3-22
- updated Requires: coreutils instead of sh-utils fileutils textutils
- applied new versioning policy

* Sun Jul  8 2007 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 0.6.3-21vl1
- s/Copyright/License/
- rebuilt based on Fedora development package 0.6.3-21
  * Mon May 28 2007 Ondrej Vasik <ovasik@redhat.com> 0.6.3-21
  - Fixed broken URL (changed to XML entity declarations) (bug #237726) 
  * Tue May 15 2007 Tim Waugh <twaugh@redhat.com> 0.6.3-20
  - Added dist tag.
  - Fixed summary.
  - Removed build dependency on autoconf/automake.
  * Tue Oct 24 2006 Tim Waugh <twaugh@redhat.com> 0.6.3-19
  - Removed stale URL (bug #210848).

* Tue Jun  3 2003 Jun Nishii <jun@vinelinux.org> 0.6.3-14vl2
- added install-catalog process in post/preun scripts

* Sat Apr 12 2003 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 0.6.3-14vl1
- sync Rawhide 0.6.3-14

* Thu Jan 31 2002 IWAI Masaharu <iwaim@cc.mbn.or.jp> 0.6.3-8vl1
- sync Rawhide 0.6.3-8
  - added BuildRequires: libxml2 >= 2.4.8
  - Use (and handle) catalog files with quotes in install-catalog.
    (sgml-common-quotes.patch)
  - added sgml-common-xmldir.patch
  - use rpmmacros
- obsoleted sgml-common-oldsyntax.patch ( upstream merged )


* Thu Oct 11 2001 Akira TAGOH <tagoh@gnome.gr.jp> 0.5-7vl1
- Rebuild for Vine.
- Added a script to remove old catalog file.

* Wed May 23 2001 Tim Waugh <twaugh@redhat.com> 0.5-7
- Remove execute bit from data files.

* Mon May 21 2001 Tim Waugh <twaugh@redhat.com> 0.5-6
- install-catalog needs to make sure that it creates world-readable files
  (bug #41552).

* Wed Mar 14 2001 Tim Powers <timp@redhat.com> 0.5-5
- fixed license

* Wed Jan 24 2001 Tim Waugh <twaugh@redhat.com>
- Make install-catalog quieter during normal operation.

* Tue Jan 23 2001 Tim Waugh <twaugh@redhat.com>
- Require textutils, fileutils, grep (bug #24719).

* Wed Jan 17 2001 Tim Waugh <twaugh@redhat.com>
- Require sh-utils.

* Mon Jan 15 2001 Tim Waugh <twaugh@redhat.com>
- Don't play so many macro games.
- Fix typo in install-catalog patch.

* Mon Jan 08 2001 Tim Waugh <twaugh@redhat.com>
- Change group.
- Install by hand (man/en/...).  Use %%{_mandir}.
- Use %%{_tmppath}.
- Make install-catalog fail silently if given the old syntax.
- Add CHANGES file.
- Change Copyright: to License:.
- Remove Packager: line.

* Mon Jan 08 2001 Tim Waugh <twaugh@redhat.com>
- Based on Eric Bischoff's new-trials packages.
