summaryrefslogtreecommitdiff
path: root/packaging/docbook-xsl-stylesheets.spec
blob: db5f234a7f062d370d9b0a6854fa40b1dd8deeed (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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
%define regcat /usr/bin/sgml-register-catalog

Name:           docbook-xsl-stylesheets
Version:        1.78.1
Release:        0
License:        MPL-1.1 and MIT
Summary:        XSL Stylesheets for DocBook 4
Url:            http://sourceforge.net/projects/docbook/
Group:          Base/Utilities
Source0:        http://switch.dl.sourceforge.net/sourceforge/docbook/docbook-xsl-%{version}.tar.bz2
Source1001:     docbook-xsl-stylesheets.manifest
BuildRequires:  fdupes
BuildRequires:  sgml-skel
BuildRequires:  unzip
Requires(pre):  %{regcat}
Requires(pre):  /usr/bin/xmlcatalog
Requires(pre):  sgml-skel
Requires:       docbook_4
Requires:       xmlcharent
BuildArch:      noarch

%description
These are the XSL stylesheets for DocBook XML and "Simplified" DocBook
DTDs. Use these stylesheets for documents based on DocBook 4 and
earlier; they are not aware of the namespace feature.

The stylesheets transform DocBook documents into HTML, XHTML, Manpages,
XSL-FO (for PDF), and a few other formats.

XSL is a standard W3C stylesheet language for both print and online
rendering. For more information about XSL, see the XSL page at the W3C:
http://www.w3.org/Style/XSL/

%define INSTALL install -m755 -s
%define INSTALL_DIR install -d -m755
%define INSTALL_DATA install -m644
%define INSTALL_SCRIPT install -m755
%define sgml_dir %{_datadir}/sgml
%define sgml_var_dir /var/lib/sgml
%define sgml_mod_dir %{sgml_dir}/docbook
%define sgml_mod_dtd_dir %{sgml_mod_dir}/dtd
%define sgml_mod_custom_dir %{sgml_mod_dir}/custom
%define sgml_mod_style_dir %{sgml_mod_dir}/stylesheet
%define xml_dir %{_datadir}/xml
%define xml_mod_dir %{xml_dir}/docbook
%define xml_mod_dtd_dir %{xml_mod_dir}/dtd
%define xml_mod_custom_dir %{xml_mod_dir}/custom
%define xml_mod_style_dir %{xml_mod_dir}/stylesheet
%define xml_mod_style_prod_dir %{xml_mod_style_dir}/nwalsh
%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 -q -n docbook-xsl-%{version} 
cp %{SOURCE1001} .

# mv epub/bin/dbtoepub epub/bin/dbtoepub.tmp
sed -i 's=@@EPUBDIR@@=%{xml_mod_style_prod_dir}/current//epub/bin='  epub/bin/dbtoepub

# We don't need these scripts:
rm -rf install.sh tools/bin/docbook-xsl-update

find -type f -print0 |xargs -0 chmod -x
chmod -R a+rX,g-w,o-w .
chmod -x images/*.{svg,png,gif,tif} images/callouts/*.{svg,png,gif} extensions/docbook.py
# Start cleanup (to avoid warnings for rpmlint
[ -f ./extensions/saxon65/dist/saxon65.jar ] && rm -rf ./extensions/saxon65/dist/saxon65.jar
[ -f ./extensions/xalan27/dist/xalan27.jar ] && rm -rf ./extensions/xalan27/dist/xalan27.jar
find . -name '.gitignore' | xargs rm -fr
#x=$(find {lib,html,fo,lib,website,slides/fo,slides/html,roundtrip,manpages}/.[a-zA-Z0-9]* -maxdepth 1 -type f )
#if [ "$x" != '' ]; then
## rm $x;
#  for i in $x; do
#     if [ -f $i ]; then
#        rm $i
#     fi
#  done
#fi

%build
xmlcatbin=/usr/bin/xmlcatalog
CATALOG=%{name}.xml
# file:///usr/share/sgml/docbook/ = %%{sgml_mod_dir} map it to
# %%{xml_mod_style_prod_dir}/%%{version}
$xmlcatbin --noout --create $CATALOG
/usr/bin/xmlcatalog --noout --add "rewriteSystem" \
 "http://docbook.sourceforge.net/release/xsl/%{version}" \
 "file://%{xml_mod_style_prod_dir}/%{version}" $CATALOG
/usr/bin/xmlcatalog --noout --add "rewriteURI" \
 "http://docbook.sourceforge.net/release/xsl/%{version}" \
 "file://%{xml_mod_style_prod_dir}/%{version}" $CATALOG
/usr/bin/xmlcatalog --noout --add "rewriteSystem" \
 "http://docbook.sourceforge.net/release/xsl/current" \
 "file://%{xml_mod_style_prod_dir}/%{version}" $CATALOG
/usr/bin/xmlcatalog --noout --add "rewriteURI" \
 "http://docbook.sourceforge.net/release/xsl/current" \
 "file://%{xml_mod_style_prod_dir}/%{version}" $CATALOG
%define FOR_ROOT_CAT for-catalog-%{name}-%{version}.xml
CATALOG=etc/xml/$CATALOG
rm -f %{FOR_ROOT_CAT}.tmp
$xmlcatbin --noout --create %{FOR_ROOT_CAT}.tmp
$xmlcatbin --noout --add "delegateSystem" \
  "http://docbook.sourceforge.net/release/xsl/" \
  "file:///$CATALOG" %{FOR_ROOT_CAT}.tmp
# $xmlcatbin --noout --add "delegatePublic" \
#   "-//OASIS//xxx" \
#   "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
# FIXME: Danger!?
# export NO_BRP_CHECK_BYTECODE_VERSION=true

# Install scripts
%{INSTALL_DIR} %{buildroot}%{_bindir}
%{INSTALL_SCRIPT} fo/pdf2index       %{buildroot}%{_bindir}
%{INSTALL_SCRIPT} epub/bin/dbtoepub  %{buildroot}%{_bindir}
rm fo/pdf2index

doc_dir=%{buildroot}%{_defaultdocdir}/%{name}
%{INSTALL_DIR} %{buildroot}%{xml_mod_style_prod_dir}/%{version}
cp -a [[:lower:]]* %{buildroot}%{xml_mod_style_prod_dir}/%{version}
cp -a VERSION.xsl %{buildroot}%{xml_mod_style_prod_dir}/%{version}
find %{buildroot}%{xml_mod_style_prod_dir} -type f -name '*.orig' -print0 |xargs -0 rm -f
rm -f %{buildroot}%{xml_mod_style_prod_dir}/%{version}/for-catalog*
: >%{name}_list
{
  pushd %{buildroot}%{xml_mod_style_prod_dir} >/dev/null
# do not create the current link for snapshots
#  if ! echo %%{SOURCE0} | grep -q snapshot; then
    ln -sf %{version} current
    echo %{xml_mod_style_prod_dir}/current
#  fi
  popd >/dev/null
} >%{name}_list
%{INSTALL_DIR} $doc_dir
# documentation
for f in README BUGS TODO WhatsNew RELEASE-NOTES.html; do
  # On snapshots, WhatsNew is missing
  [ -f $f ] && %{INSTALL_DATA} $f $doc_dir/$f
done
# cp -p README.SuSE $doc_dir/README.SuSE
#
{
  LANG=C \
    find %{buildroot}%{xml_mod_style_prod_dir}/%{version} \
    -type d \
    -not -path '%{buildroot}%{xml_mod_style_prod_dir}/%{version}/latex*' \
    | sed 's|%{buildroot}|%dir |'
  LANG=C \
    find %{buildroot}%{xml_mod_style_prod_dir}/%{version} \
    -type f \
    -not -path '%{buildroot}%{xml_mod_style_prod_dir}/%{version}/latex*' \
    | sed 's|%{buildroot}||'
} >> %{_builddir}/%{buildsubdir}/%{name}_list
# pushd %%{buildroot}%%{xml_mod_style_prod_dir}
#   rm -f docbook-xsl
#   ln -sf docbook-xsl-stylesheets-%%{version} docbook-xsl
#   rm -f xsl-stylesheets
#   ln -sf docbook-xsl-stylesheets-%%{version} xsl-stylesheets
#   rm -f %%{name}
#   ln -sf docbook-xsl-stylesheets-%%{version} %%{name}
# popd
cat_dir=%{buildroot}%{_sysconfdir}/xml
%{INSTALL_DIR} $cat_dir
%{INSTALL_DATA} %{FOR_ROOT_CAT} %{name}.xml $cat_dir
# cleanup
rm -f %{buildroot}%{xml_mod_style_prod_dir}/%{version}/%{name}.xml
cp $cat_dir/%{FOR_ROOT_CAT} \
  %{buildroot}%{xml_mod_style_prod_dir}/%{version}/%{name}.xml
chmod +x \
%{buildroot}%{xml_mod_style_prod_dir}/%{version}/extensions/docbook.py \
%{buildroot}%{xml_mod_style_prod_dir}/%{version}/extensions/xslt.py
# %%{buildroot}%%{xml_mod_style_prod_dir}/%%{version}/epub/bin/lib/docbook.rb
# %%{buildroot}%%{xml_mod_style_prod_dir}/%%{version}/epub/bin/spec/spec_helper.rb

%fdupes -s %{buildroot}


%post
# remove empty dir if present (from ghost)
# also remove dangling symlink
D=usr/share/sgml
rmdir $D/docbkxsl >/dev/null 2>&1 || :
test -L $D/docbkxsl -a ! -e $D/docbkxsl && rm -f $D/docbkxsl
if [ -x /usr/bin/edit-xml-catalog ]; then
  edit-xml-catalog --group --catalog /etc/xml/suse-catalog.xml \
    --add /etc/xml/%{FOR_ROOT_CAT}
fi

%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

%files -f %{name}_list
%manifest %{name}.manifest
%defattr(-, root, root)
%config %{_sysconfdir}/xml/%{name}.xml
%config %{_sysconfdir}/xml/%{FOR_ROOT_CAT}
%{_defaultdocdir}/%{name}
%dir %{xml_mod_style_dir}
%dir %{xml_mod_style_prod_dir}
# it is now in the list:
# %%{xml_mod_style_prod_dir}/current
%{_bindir}/*