summaryrefslogtreecommitdiff
path: root/packaging/xmlcharent.spec
blob: 690373eabc64ae72a6435b5cfe6d2731fe8bb443 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#
# spec file for package xmlcharent (Version 0.3)
#
# Copyright (c) 2010 SUSE LINUX Products 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:           xmlcharent
Version:        0.3
Release:        405
License:        BSD-3-Clause
Summary:        XML Character Entities
Url:            http://www.oasis-open.org/committees/docbook/xmlcharent/
Group:          Productivity/Publishing/XML
Source0:        http://www.oasis-open.org/committees/docbook/%{name}/%{version}/%{name}-%{version}.zip
Source1:        catalog.xml
Source2:        CATALOG.xmlcharent
BuildRequires:  sgml-skel
BuildRequires:  unzip
%define regcat /usr/bin/sgml-register-catalog
Requires(pre):  %{regcat}
Requires(pre):  /usr/bin/edit-xml-catalog
Requires(pre):  /usr/bin/xmlcatalog
Requires(pre):  gawk
Requires(pre):  grep
Requires(pre):  sed
Requires:       libxml2
Requires:       sgml-skel
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

%description
XML encodings for the 19 standard character entity sets defined in
non-normative Annex D of [ISO 8879:1986].

%define INSTALL install -m755 -s
%define INSTALL_DIR install -d -m755
%define INSTALL_DATA install -m644
%define INSTALL_SCRIPT install -m755 -o root -g root
%define sgml_dir %{_datadir}/sgml
%define sgml_var_dir /var/lib/sgml
%define sgml_mod_dir %{sgml_dir}/xmlcharent
%define xml_dir %{_datadir}/xml
%define xml_mod_dir %{xml_dir}/entities/%{name}/%{version}
%define sgml_config_dir /var/lib/sgml
%define sgml_sysconf_dir %{_sysconfdir}/sgml
%define xml_config_dir /var/lib/xml
%define xml_sysconf_dir %{_sysconfdir}/xml

%prep
%setup -n %{name} -c -T
unzip -aq %{SOURCE0}
sed 's|@VERSION@|%{version}|
s|@DIR@|%{xml_mod_dir}|' %{SOURCE1} >catalog.xml
sed 's|@VERSION@|%{version}|
s|@DIR@|%{xml_mod_dir}|' %{SOURCE2} >CATALOG.%{name}
#%setup -q -n %{name}

%build
# # lynx -width=300 -dump  entities-2002-03-19.html \
# #   | grep '\(Public\|System\) identifier' \
# #   | awk -F 'entifier: ' '
# # / System i/ {printf "\"%s\"\n", gensub(/.*\//,"%{sgml_dir_iso}/", g, $2)}
# # / Public i/ {printf "PUBLIC \"-//%s\" ", $2}' > CATALOG.xmlcharent
# {
#   for f in iso-*.ent; do
#     {
#       grep ' *ISO 8879:1986' $f | sed 's:^ \+::' \
#         | awk '{printf "PUBLIC \"-//%s\"", $0}';
#       echo " \"%{sgml_dir_iso}/$f\"";
#     }
#   done
# } > CATALOG.xmlcharent
# sed 's:%{xml_mod_dir}/::' CATALOG.xmlcharent > sgml.catalog
# Prep XML catalog fragment
%define FOR_ROOT_CAT for-catalog-%{name}-%{version}.xml
xmlcatbin=/usr/bin/xmlcatalog
# build root catalog fragment
rm -f %{FOR_ROOT_CAT}.tmp
$xmlcatbin --noout --create %{FOR_ROOT_CAT}.tmp
CATALOG=%{xml_mod_dir}/catalog.xml
$xmlcatbin --noout --add "delegatePublic" "ISO 8879:1986//ENTITIES" \
    "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
%{INSTALL_DIR} %{buildroot}{%{xml_mod_dir},%{sgml_dir},%{sgml_var_dir}}
%{INSTALL_DATA} catalog.xml *.ent %{buildroot}%{xml_mod_dir}
%{INSTALL_DATA} CATALOG.xmlcharent %{buildroot}%{sgml_var_dir}
pushd %{buildroot}%{sgml_dir}
ln -sf ../../../var/lib/sgml/CATALOG.* .
popd
pushd %{buildroot}%{xml_mod_dir}
for f in *.ent; do
  ln -sf "$f" "${f/-}"
done
popd
# parse-sgml-catalog.sh CATALOG.xmlcharent > CATALOG.norm
# sgml2xmlcat.sh -i CATALOG.norm \
#   -l -s '%{buildroot}/usr/share/sgml' -p xmlcharent
#
mkdir -p %{buildroot}%{_sysconfdir}/xml
install -m644 %{FOR_ROOT_CAT} %{buildroot}%{_sysconfdir}/xml
#
%define all_cat xmlcharent

%post
if [ -x %{regcat} ]; then
  for c in  %{all_cat}; do
    grep -q -e "%{sgml_dir}/CATALOG.$c\\>" /etc/sgml/catalog \
      || %{regcat} -a %{sgml_dir}/CATALOG.$c >/dev/null 2>&1 || :
  done
fi
xmlcatbin=usr/bin/xmlcatalog
if [ -x /usr/bin/edit-xml-catalog ]; then
/usr/bin/edit-xml-catalog --group --catalog /etc/xml/suse-catalog.xml \
  --add /etc/xml/%{FOR_ROOT_CAT}
fi

%postun
if [  "$1" = "0" -a -x %{regcat} ]; then
  for c in  %{all_cat}; do
    %{regcat} -r %{sgml_dir}/CATALOG.$c >/dev/null 2>&1 || :
  done
fi
xmlcatbin=/usr/bin/xmlcatalog
# remove entries only on removal of file
if [ ! -f %{xml_sysconf_dir}/%{FOR_ROOT_CAT} -a -x /usr/bin/edit-xml-catalog ] ; then
  /usr/bin/edit-xml-catalog --group --catalog /etc/xml/suse-catalog.xml \
    --del %{name}-%{version}
fi

%files
%defattr(-, root, root)
# %doc entities-*.html
%{xml_mod_dir}
%config %{_sysconfdir}/xml/%{FOR_ROOT_CAT}
%config %{sgml_var_dir}/CATALOG.*
# %{sgml_dir}/ISO*
%{sgml_dir}/CATALOG.*
%dir %{xml_dir}/entities
%dir %{xml_dir}/entities/xmlcharent

%changelog