4c7113e9b66f48c1e061a84f877abe452cc5c9b5
[platform/upstream/docbook-xsl-stylesheets.git] / packaging / docbook-xsl-stylesheets.spec
1 %define pack_vers 1.77.1
2 %define regcat /usr/bin/sgml-register-catalog
3
4 Name:           docbook-xsl-stylesheets
5 Version:        1.77.1
6 Release:        0
7 License:        MPL-1.1 and MIT
8 Summary:        XSL Stylesheets for DocBook 4
9 Url:            http://sourceforge.net/projects/docbook/
10 Group:          Productivity/Publishing/DocBook
11 Source0:        http://switch.dl.sourceforge.net/sourceforge/docbook/docbook-xsl-%{pack_vers}.tar.bz2
12 Source1:        http://switch.dl.sourceforge.net/sourceforge/docbook/docbook-xsl-doc-%{version}.tar.bz2
13 BuildRequires:  fdupes
14 BuildRequires:  sgml-skel
15 BuildRequires:  unzip
16 Requires(pre):  %{regcat}
17 Requires(pre):  /usr/bin/xmlcatalog
18 Requires(pre):  sgml-skel
19 Requires:       docbook_4
20 Requires:       xmlcharent
21 BuildArch:      noarch
22
23 %description
24 These are the XSL stylesheets for DocBook XML and "Simplified" DocBook
25 DTDs. Use these stylesheets for documents based on DocBook 4 and
26 earlier; they are not aware of the namespace feature.
27
28 The stylesheets transform DocBook documents into HTML, XHTML, Manpages,
29 XSL-FO (for PDF), and a few other formats.
30
31 XSL is a standard W3C stylesheet language for both print and online
32 rendering. For more information about XSL, see the XSL page at the W3C:
33 http://www.w3.org/Style/XSL/
34
35 %define INSTALL install -m755 -s
36 %define INSTALL_DIR install -d -m755
37 %define INSTALL_DATA install -m644
38 %define INSTALL_SCRIPT install -m755
39 %define sgml_dir %{_datadir}/sgml
40 %define sgml_var_dir /var/lib/sgml
41 %define sgml_mod_dir %{sgml_dir}/docbook
42 %define sgml_mod_dtd_dir %{sgml_mod_dir}/dtd
43 %define sgml_mod_custom_dir %{sgml_mod_dir}/custom
44 %define sgml_mod_style_dir %{sgml_mod_dir}/stylesheet
45 %define xml_dir %{_datadir}/xml
46 %define xml_mod_dir %{xml_dir}/docbook
47 %define xml_mod_dtd_dir %{xml_mod_dir}/dtd
48 %define xml_mod_custom_dir %{xml_mod_dir}/custom
49 %define xml_mod_style_dir %{xml_mod_dir}/stylesheet
50 %define xml_mod_style_prod_dir %{xml_mod_style_dir}/nwalsh
51 %define sgml_config_dir /var/lib/sgml
52 %define sgml_sysconf_dir %{_sysconfdir}/sgml
53 %define xml_config_dir /var/lib/xml
54 %define xml_sysconf_dir %{_sysconfdir}/xml
55
56 %prep
57 # %%setup -q -n docbook-xsl-%%{pack_vers} -b 10
58 %setup -q -n docbook-xsl-%{pack_vers} -b 1
59
60 # mv epub/bin/dbtoepub epub/bin/dbtoepub.tmp
61 sed -i 's=@@EPUBDIR@@=%{xml_mod_style_prod_dir}/current//epub/bin='  epub/bin/dbtoepub
62
63 # We don't need these scripts:
64 rm -rf install.sh tools/bin/docbook-xsl-update
65
66 find -type f  -exec chmod -x {} \;
67 chmod -R a+rX,g-w,o-w .
68 chmod -x images/*.{svg,png,gif,tif} images/callouts/*.{svg,png,gif} extensions/docbook.py
69 # Start cleanup (to avoid warnings for rpmlint
70 [ -f ./extensions/saxon65/dist/saxon65.jar ] && rm -rf ./extensions/saxon65/dist/saxon65.jar
71 [ -f ./extensions/xalan27/dist/xalan27.jar ] && rm -rf ./extensions/xalan27/dist/xalan27.jar
72 find . -name '.gitignore' | xargs rm -fr
73 #x=$(find {lib,html,fo,lib,website,slides/fo,slides/html,roundtrip,manpages}/.[a-zA-Z0-9]* -maxdepth 1 -type f )
74 #if [ "$x" != '' ]; then
75 ## rm $x;
76 #  for i in $x; do
77 #     if [ -f $i ]; then
78 #        rm $i
79 #     fi
80 #  done
81 #fi
82
83 %build
84 xmlcatbin=/usr/bin/xmlcatalog
85 CATALOG=%{name}.xml
86 # file:///usr/share/sgml/docbook/ = %%{sgml_mod_dir} map it to
87 # %%{xml_mod_style_prod_dir}/%%{version}
88 $xmlcatbin --noout --create $CATALOG
89 /usr/bin/xmlcatalog --noout --add "rewriteSystem" \
90  "http://docbook.sourceforge.net/release/xsl/%{version}" \
91  "file://%{xml_mod_style_prod_dir}/%{version}" $CATALOG
92 /usr/bin/xmlcatalog --noout --add "rewriteURI" \
93  "http://docbook.sourceforge.net/release/xsl/%{version}" \
94  "file://%{xml_mod_style_prod_dir}/%{version}" $CATALOG
95 /usr/bin/xmlcatalog --noout --add "rewriteSystem" \
96  "http://docbook.sourceforge.net/release/xsl/current" \
97  "file://%{xml_mod_style_prod_dir}/%{version}" $CATALOG
98 /usr/bin/xmlcatalog --noout --add "rewriteURI" \
99  "http://docbook.sourceforge.net/release/xsl/current" \
100  "file://%{xml_mod_style_prod_dir}/%{version}" $CATALOG
101 %define FOR_ROOT_CAT for-catalog-%{name}-%{version}.xml
102 CATALOG=etc/xml/$CATALOG
103 rm -f %{FOR_ROOT_CAT}.tmp
104 $xmlcatbin --noout --create %{FOR_ROOT_CAT}.tmp
105 $xmlcatbin --noout --add "delegateSystem" \
106   "http://docbook.sourceforge.net/release/xsl/" \
107   "file:///$CATALOG" %{FOR_ROOT_CAT}.tmp
108 # $xmlcatbin --noout --add "delegatePublic" \
109 #   "-//OASIS//xxx" \
110 #   "file:///$CATALOG" %%{FOR_ROOT_CAT}.tmp
111 # Create tag
112 sed '/<catalog/a\
113   <group id="%{name}-%{version}">
114 /<\/catalog/i\
115   </group>' \
116   %{FOR_ROOT_CAT}.tmp > %{FOR_ROOT_CAT}
117
118 %install
119 # FIXME: Danger!?
120 # export NO_BRP_CHECK_BYTECODE_VERSION=true
121
122 # Install scripts
123 %{INSTALL_DIR} %{buildroot}%{_bindir}
124 %{INSTALL_SCRIPT} fo/pdf2index       %{buildroot}%{_bindir}
125 %{INSTALL_SCRIPT} epub/bin/dbtoepub  %{buildroot}%{_bindir}
126 rm fo/pdf2index
127
128 doc_dir=%{buildroot}%{_defaultdocdir}/%{name}
129 %{INSTALL_DIR} %{buildroot}%{xml_mod_style_prod_dir}/%{version}
130 cp -a [[:lower:]]* %{buildroot}%{xml_mod_style_prod_dir}/%{version}
131 cp -a VERSION.xsl %{buildroot}%{xml_mod_style_prod_dir}/%{version}
132 find %{buildroot}%{xml_mod_style_prod_dir} -type f -name '*.orig' -exec rm -f {} \;
133 rm -f %{buildroot}%{xml_mod_style_prod_dir}/%{version}/for-catalog*
134 : >%{name}_list
135 {
136   pushd %{buildroot}%{xml_mod_style_prod_dir} >/dev/null
137 # do not create the current link for snapshots
138 #  if ! echo %%{SOURCE0} | grep -q snapshot; then
139     ln -sf %{version} current
140     echo %{xml_mod_style_prod_dir}/current
141 #  fi
142   popd >/dev/null
143 } >%{name}_list
144 %{INSTALL_DIR} $doc_dir
145 # documentation
146 for f in README BUGS TODO WhatsNew RELEASE-NOTES.html; do
147   # On snapshots, WhatsNew is missing
148   [ -f $f ] && %{INSTALL_DATA} $f $doc_dir/$f
149 done
150 # cp -p README.SuSE $doc_dir/README.SuSE
151 #
152 {
153   LANG=C \
154     find %{buildroot}%{xml_mod_style_prod_dir}/%{version} \
155     -type d \
156     -not -path '%{buildroot}%{xml_mod_style_prod_dir}/%{version}/latex*' \
157     | sed 's|%{buildroot}|%dir |'
158   LANG=C \
159     find %{buildroot}%{xml_mod_style_prod_dir}/%{version} \
160     -type f \
161     -not -path '%{buildroot}%{xml_mod_style_prod_dir}/%{version}/latex*' \
162     | sed 's|%{buildroot}||'
163 } >> %{_builddir}/%{buildsubdir}/%{name}_list
164 # pushd %%{buildroot}%%{xml_mod_style_prod_dir}
165 #   rm -f docbook-xsl
166 #   ln -sf docbook-xsl-stylesheets-%%{version} docbook-xsl
167 #   rm -f xsl-stylesheets
168 #   ln -sf docbook-xsl-stylesheets-%%{version} xsl-stylesheets
169 #   rm -f %%{name}
170 #   ln -sf docbook-xsl-stylesheets-%%{version} %%{name}
171 # popd
172 cat_dir=%{buildroot}%{_sysconfdir}/xml
173 %{INSTALL_DIR} $cat_dir
174 %{INSTALL_DATA} %{FOR_ROOT_CAT} %{name}.xml $cat_dir
175 # cleanup
176 rm -f %{buildroot}%{xml_mod_style_prod_dir}/%{version}/%{name}.xml
177 cp $cat_dir/%{FOR_ROOT_CAT} \
178   %{buildroot}%{xml_mod_style_prod_dir}/%{version}/%{name}.xml
179 chmod +x \
180 %{buildroot}%{xml_mod_style_prod_dir}/%{version}/extensions/docbook.py \
181 %{buildroot}%{xml_mod_style_prod_dir}/%{version}/extensions/xslt.py
182 # %%{buildroot}%%{xml_mod_style_prod_dir}/%%{version}/epub/bin/lib/docbook.rb
183 # %%{buildroot}%%{xml_mod_style_prod_dir}/%%{version}/epub/bin/spec/spec_helper.rb
184
185 %fdupes -s %{buildroot}
186
187
188 %post
189 # remove empty dir if present (from ghost)
190 # also remove dangling symlink
191 D=usr/share/sgml
192 rmdir $D/docbkxsl >/dev/null 2>&1 || :
193 test -L $D/docbkxsl -a ! -e $D/docbkxsl && rm -f $D/docbkxsl
194 if [ -x /usr/bin/edit-xml-catalog ]; then
195   edit-xml-catalog --group --catalog /etc/xml/suse-catalog.xml \
196     --add /etc/xml/%{FOR_ROOT_CAT}
197 fi
198
199 %postun
200 # remove entries only on removal of file
201 if [ ! -f %{xml_sysconf_dir}/%{FOR_ROOT_CAT} -a -x /usr/bin/edit-xml-catalog ] ; then
202   edit-xml-catalog --group --catalog /etc/xml/suse-catalog.xml \
203     --del %{name}-%{version}
204 fi
205
206 %files -f %{name}_list
207 %defattr(-, root, root)
208 %config %{_sysconfdir}/xml/%{name}.xml
209 %config %{_sysconfdir}/xml/%{FOR_ROOT_CAT}
210 %{_defaultdocdir}/%{name}
211 %dir %{xml_mod_style_dir}
212 %dir %{xml_mod_style_prod_dir}
213 # it is now in the list:
214 # %%{xml_mod_style_prod_dir}/current
215 %{_bindir}/*
216
217 %changelog