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