%define catalog_name	%{name}-%{version}-%{release}.cat

Name: xhtml-dtd10
Version: 1.0
Release: 2%{?_dist_release}
Group: Applications/Text

Summary: XML document type definition for XHTML 1.0

License: Distributable

#Provides: html-dtd
Requires: sgml-common >= 0.5
BuildRequires: unzip
BuildRoot: %{_tmppath}/%{name}-%{version}

BuildArch: noarch
Source0: http://www.w3.org/TR/xhtml1/xhtml1.zip
Source1: http://www.w3.org/Consortium/Legal/copyright-documents-19990405.html
Url: http://www.w3.org/TR/xhtml1/

%description
XML document type definition for XHTML 1.0

%prep
[ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}
rm -rf ${RPM_BUILD_DIR}/%{name}-%{version}

%setup -c -T
unzip %{SOURCE0}
cp -a %{SOURCE1} .

%build

%install
[ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}
[ "${RPM_BUILD_ROOT}" != "/" ] && \
            mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/sgml/xhtml/xhtml-dtd-1.0

pushd xhtml1/DTD
install -m0644 *.ent ${RPM_BUILD_ROOT}%{_datadir}/sgml/xhtml/xhtml-dtd-1.0
install -m0644 *.dtd ${RPM_BUILD_ROOT}%{_datadir}/sgml/xhtml/xhtml-dtd-1.0
install -m0644 *.dcl ${RPM_BUILD_ROOT}%{_datadir}/sgml/xhtml/xhtml-dtd-1.0
install -m0644 *.soc ${RPM_BUILD_ROOT}%{_datadir}/sgml/xhtml/xhtml-dtd-1.0
ln -s  xhtml.soc ${RPM_BUILD_ROOT}%{_datadir}/sgml/xhtml/xhtml-dtd-1.0/catalog
popd

%clean
[ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}
rm -rf ${RPM_BUILD_DIR}/%{name}-%{version}

%files
%defattr (-,root,root)
%doc copyright-documents-19990405.html xhtml1/*.*
%{_datadir}/sgml/xhtml/xhtml-dtd-1.0


%post
# Update the centralized catalog corresponding to this version of the DTD
/usr/bin/install-catalog --add /etc/sgml/%{catalog_name} %{_datadir}/sgml/xhtml/xhtml-dtd-1.0/catalog > /dev/null

# Update the link to the current version of the DTD
ln -s -f /etc/sgml/%{catalog_name} /etc/sgml/xhtml.cat

%postun
# Update the centralized catalog corresponding to this version of the DTD
/usr/bin/install-catalog --remove /etc/sgml/%{catalog_name} %{_datadir}/sgml/xhtml/xhtml-dtd-1.0/catalog > /dev/null

# Update the link to the current version of the DTD
if [ ! -e /etc/sgml/%{catalog_name} ]; then
    rm -f /etc/sgml/xhtml.cat
    OTHERCAT=`ls /etc/sgml/xhtml-?.*.cat 2> /dev/null | head --lines 1`
    if [ -n "$OTHERCAT" ]; then ln -s $OTHERCAT /etc/sgml/xhtml.cat; fi
fi

%changelog
* Wed Oct 15 2008 Shu KONNO <owa@bg.wakwak.com> 1.0-2vl5
- applied new versioning policy

* Mon Mar 24 2003 IWAI Masaharu <iwai@alib.jp> 1.0-1vl2
- rename catalog file

* Sun Jan  6 2002 IWAI Masaharu <iwaim@cc.mbn.or.jp>
- first release

