- use wvHtml instead of catdoc by default: it retains formatting
[mnogosearch-rpm] / mnogosearch.spec
1 %global php_apiver  %((echo 0; php -i 2>/dev/null | sed -n 's/^PHP API => //p') | tail -1)
2 %global php_extdir  %(php-config --extension-dir 2>/dev/null || echo "undefined")
3 %global php_version %(php-config --version 2>/dev/null || echo 0)
4
5 # do not add php module to provides, it is no regular library
6 %{?filter_setup:
7 %filter_provides_in %{php_extdir}/.*\.so$
8 %filter_setup
9 }
10
11 Summary:        Web indexing and search system for a small domain or intranet
12 Name:           mnogosearch
13 Version:        3.3.11
14 Release:        2
15 License:        GPLv2+
16 Group:          Applications/Internet
17 URL:            http://www.mnogosearch.org/
18
19 # md5sum 906d5e1e21ba00024574f57548d32029
20 Source0:        http://www.mnogosearch.org/Download/mnogosearch-%{version}.tar.gz
21
22 Source1:        mnogosearch-reindex
23 Source2:        mnogosearch.crond
24 Source3:        httpd.conf
25
26 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
27
28 Requires:       %{name}-libs = %{version}-%{release}
29 Requires:       /usr/bin/wvHtml
30 Requires:       /usr/bin/xlhtml
31 Requires:       /usr/bin/ppthtml
32 Requires:       /usr/bin/pdftotext
33 Requires(pre):  shadow-utils
34
35 # user "apache" is added to mnogosearch group so we need the user to be present
36 Requires(post): httpd
37
38 BuildRequires:  autoconf
39 BuildRequires:  automake
40 BuildRequires:  libtool
41 BuildRequires:  openssl-devel
42 BuildRequires:  zlib-devel
43 BuildRequires:  expat-devel
44 BuildRequires:  openssl-devel
45 BuildRequires:  openjade
46 BuildRequires:  docbook-utils
47 BuildRequires:  mysql-devel
48 BuildRequires:  readline-devel
49 BuildRequires:  ncurses-devel
50 BuildRequires:  sqlite-devel
51 BuildRequires:  unixODBC-devel
52 BuildRequires:  postgresql-devel
53 BuildRequires:  freetds-devel
54 BuildRequires:  firebird-devel
55 BuildRequires:  catdoc
56 BuildRequires:  xlhtml
57
58 # build is done with unit testing by default, but it can be disabled
59 # by --without tests to save time
60 %define with_tests  %{?_without_tests:  0} %{?!_without_tests:  1}
61
62 %description
63 mnoGoSearch (formerly known as UdmSearch) is a full-featured Web search engine
64 that you can use to build search engines over HTTP, HTTPS, FTP, and NTTP
65 servers, local files, and database big text fields. It supports Oracle, MS SQL
66 Server, MySQL, PostgreSQL, InterBase/Firebird, Openlink Virtuoso, Intersystems
67 Cach, iODBC, EasySoft ODBC, and unixODBC database backends. It has XML, HTML,
68 and TEXT built-in support, and external converters support for other document
69 types. An automatic language/charset guesser for more 70 language/charset
70 combinations is included, along with basic authorization support, and you may
71 index password-protected intranet HTTP servers with proxy authorization
72 support.
73
74 mnoGoSearch is built with support for mysql (including fulltext extension),
75 sqlite, postgresql, firebird, unixODBC and freetds.
76
77 %package libs
78 Summary:        Libraries for %{name}
79 Group:          System Environment/Libraries
80
81 %description libs
82 This package contains the %{name} library files.
83
84 %package devel
85 Summary:        Development headers and libraries for %{name}
86 Group:          Development/Libraries
87 Requires:       %{name} = %{version}-%{release}
88
89 %description devel
90 This package contains the %{name} development files.
91
92 %package php
93 Summary:        PHP-extension for %{name}
94 Group:          Applications/Internet
95 Requires:       %{name}-libs = %{version}-%{release}
96 BuildRequires:  php-devel
97 BuildRequires:  php-cli
98
99 %if 0%{?php_zend_api}
100 Requires:       php(zend-abi) = %{php_zend_api}
101 Requires:       php(api) = %{php_core_api}
102 %else
103 Requires:       php-api = %{php_apiver}
104 %endif
105
106 %description php
107 This package contains the PHP extension for %{name}
108
109 %prep
110 %setup -q -n mnogosearch-%{version}
111
112 %build
113 autoreconf -fi
114
115 %configure \
116     --sysconfdir=%{_sysconfdir}/mnogosearch  \
117     --datadir=%{_datadir}/mnogosearch  \
118     --localstatedir=%{_localstatedir}/lib/mnogosearch \
119     --includedir=%{_includedir}/mnogosearch \
120     --enable-syslog \
121     --enable-syslog=LOG_LOCAL6 \
122     --enable-parser \
123     --enable-mp3 \
124     --enable-file \
125     --enable-http \
126     --enable-ftp \
127     --enable-news \
128     --with-openssl=%{_prefix} \
129     --with-zlib \
130     --with-readline \
131     --with-extra-charsets=all \
132     --with-mysql \
133     --enable-mysql-fulltext-plugin \
134     --with-pgsql \
135     --with-sqlite3 \
136     --with-unixODBC \
137     --with-freetds=%{_prefix} \
138     --with-ibase \
139     --with-docs \
140     --enable-fhs-layout
141
142 make %{?_smp_mflags}
143
144 %install
145 rm -rf %{buildroot}
146
147 %{__make} install \
148     DESTDIR=$RPM_BUILD_ROOT \
149     doc_FILES='$(HTML_ALL)'
150
151 # no need to call the config files *-dist
152 (cd %{buildroot}%{_sysconfdir}/%{name}
153 for f in *-dist ; do
154     mv -f $f `basename $f -dist`
155 done
156 )
157
158 # fix header of config file
159 sed -i 's|/usr/local/mnogosearch/sbin/indexer|%{_bindir}/indexer|g' \
160     %{buildroot}%{_sysconfdir}/mnogosearch/indexer.conf
161
162 # change default configuration
163 sed -i 's|DBAddr.mysql://root@localhost/test/?dbmode=blob|DBAddr sqlite3://localhost/%{_localstatedir}/lib/mnogosearch/default.db/?dbmode=blob|g' \
164     %{buildroot}%{_sysconfdir}/mnogosearch/indexer.conf \
165     %{buildroot}%{_sysconfdir}/mnogosearch/search.htm \
166
167 sed -i 's|#LocalCharset UTF-8|LocalCharset UTF-8|g' \
168     %{buildroot}%{_sysconfdir}/mnogosearch/indexer.conf
169
170 sed -i 's|#Server http://localhost/|Server http://localhost/|g' \
171     %{buildroot}%{_sysconfdir}/mnogosearch/indexer.conf
172
173 # enable common external document helpers by default
174 # we require them so they will be installed
175
176 sed -i 's|#Mime application/msword      "text/html; charset=utf-8"  "wvHtml --charset=utf-8 $1 -"|Mime application/msword      "text/html; charset=utf-8"  "wvHtml --charset=utf-8 $1 -"|g' \
177     %{buildroot}%{_sysconfdir}/mnogosearch/indexer.conf
178
179 sed -i 's|#Mime application/pdf          text/plain                 "pdftotext $1 -"|Mime application/pdf          text/plain                 "pdftotext $1 -"|g' \
180     %{buildroot}%{_sysconfdir}/mnogosearch/indexer.conf
181
182 sed -i 's|#Mime application/vnd.ms-excel text/html                  "xlhtml $1"|Mime application/vnd.ms-excel text/html                  "xlhtml $1"|g' \
183     %{buildroot}%{_sysconfdir}/mnogosearch/indexer.conf
184
185 sed -i 's|#Mime application/vnd.ms-powerpoint text/html             "ppthtml $1"|Mime application/vnd.ms-powerpoint text/html             "ppthtml $1"|g' \
186     %{buildroot}%{_sysconfdir}/mnogosearch/indexer.conf
187
188 sed -i 's|Disallow \*.tex  \*.texi \*.xls  \*.doc  \*.texinfo|Disallow *.tex *.texi *.texinfo|g' \
189     %{buildroot}%{_sysconfdir}/mnogosearch/indexer.conf
190
191 sed -i 's|Disallow \*.rtf  \*.pdf  \*.cdf  \*.ps|Disallow *.rtf  *.cdf  *.ps|g' \
192     %{buildroot}%{_sysconfdir}/mnogosearch/indexer.conf
193
194 sed -i 's|Disallow \*.ai   \*.eps  \*.ppt  \*.hqx|Disallow *.ai   *.eps  *.hqx|g' \
195     %{buildroot}%{_sysconfdir}/mnogosearch/indexer.conf
196
197 # the cgi is no regular binary, move it to libexec
198 install -d %{buildroot}%{_libexecdir}/mnogosearch
199 mv -f %{buildroot}%{_bindir}/*.cgi %{buildroot}%{_libexecdir}/mnogosearch/
200
201 # the .la's confuse libtool when building the php lib and they should not
202 # be packaged at all, so remove them
203 rm -f %{buildroot}%{_libdir}/*.la
204
205 install -m0755 %{SOURCE1} %{buildroot}%{_bindir}/
206
207 install -d %{buildroot}%{_sysconfdir}/cron.d/
208 install -m0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/cron.d/mnogosearch
209
210 install -d %{buildroot}%{_sysconfdir}/httpd/conf.d/
211 install -m0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/httpd/conf.d/mnogosearch.conf
212
213
214 # ---------------------
215 # make & install php stuff
216 # must be in install-section because it needs an already installed mnogosearch
217 cd php
218
219 /usr/bin/phpize
220 %configure --with-mnogosearch=%{buildroot}%{_prefix}
221
222 # get rid of rpath
223 sed -i 's|-Wl,-rpath,[^ ]*||g' Makefile
224
225 make %{?_smp_mflags} EXTRA_LDFLAGS="-L%{buildroot}%{_libdir}" EXTRA_CFLAGS="-I%{buildroot}%{_includedir}/mnogosearch"
226 make install \
227     INSTALL_ROOT=$RPM_BUILD_ROOT
228 cd ..
229
230 install -d %{buildroot}%{_sysconfdir}/php.d
231 cat >%{buildroot}%{_sysconfdir}/php.d/mnogosearch.ini <<EOF
232 ; Enable mnogosearch extension module
233 extension=mnogosearch.so
234 EOF
235
236 # end PHP stuff
237 # ---------------------
238
239 # create state-dir
240 install -d %{buildroot}%{_localstatedir}/lib/mnogosearch
241
242 # fix docs
243 rm -rf html; mkdir -p html
244 cp -p doc/*.html html/
245 rm -rf %{buildroot}/usr/doc
246
247 %check
248 %if %{with_tests}
249 # run unit tests with sqlite backend
250 touch ./msearch-test/sqlite.db
251 export UDM_TEST_DBADDR=sqlite3://`pwd`/msearch-test/sqlite.db/,sqlite3://`pwd`/msearch-test/sqlite2.db/
252 make check
253 %endif
254
255 %clean
256 rm -rf %{buildroot}
257
258 %pre
259 # create mnogosearch user and group
260 getent group mnogosearch >/dev/null || groupadd -r mnogosearch
261 getent passwd mnogosearch >/dev/null || \
262     useradd -r -g mnogosearch -d %{_localstatedir}/lib/mnogosearch \
263     -c "User the indexer of the mnoGoSearch search engine is executed with" \
264     -s /sbin/nologin mnogosearch
265 exit 0
266
267 %post
268 # the cgi (executed with the apache user) must be able to read the database:
269 # the apache user must be in the mnogosearch group
270 usermod -a -G mnogosearch apache || :
271
272 # we brought our own apache config snippet and new group rights
273 service httpd condrestart > /dev/null 2>&1 || :
274
275 # create default mnogosearch database (only during install)
276 if [ $1 -eq 1 ] ; then
277     /usr/bin/indexer --create >/dev/null
278     chown mnogosearch:mnogosearch %{_localstatedir}/lib/mnogosearch/default.db
279     # db must be group writeable to allow query tracking
280     chmod 0660 %{_localstatedir}/lib/mnogosearch/default.db
281 fi
282
283 %postun
284 service httpd condrestart > /dev/null 2>&1 || :
285
286 %post libs -p /sbin/ldconfig
287
288 %postun libs -p /sbin/ldconfig
289
290 %files
291 %defattr(-,root,root,-)
292 %{_bindir}/indexer
293 %{_bindir}/mconv
294 %{_bindir}/mguesser
295 %{_bindir}/mnogosearch-reindex
296 %dir %{_libexecdir}/mnogosearch
297 %{_libexecdir}/mnogosearch/search.cgi
298 %config(noreplace) %verify(not size mtime md5) %{_sysconfdir}/cron.d/mnogosearch
299 %config(noreplace) %verify(not size mtime md5) %{_sysconfdir}/httpd/conf.d/mnogosearch.conf
300
301 %defattr (0644,root,root,0755)
302 %doc ChangeLog README README.XML README.CVS TODO COPYING AUTHORS INSTALL NEWS FAQ html doc/samples
303 %{_mandir}/man?/*
304 %{_datadir}/mnogosearch
305
306 # the config files of mnogosearch often contain database passwords -> should not be world readable
307 %defattr (0640,root,mnogosearch,0750)
308 %dir %{_sysconfdir}/mnogosearch
309
310 # indexer.conf is executable: has a correct shebang to run the indexer with this configuration
311 %attr(0755,root,mnogosearch) %config(noreplace) %verify(not size mtime md5) %{_sysconfdir}/mnogosearch/indexer.conf
312 %config(noreplace) %verify(not size mtime md5) %{_sysconfdir}/mnogosearch/langmap.conf
313 %config(noreplace) %verify(not size mtime md5) %{_sysconfdir}/mnogosearch/stopwords.conf
314 %config(noreplace) %verify(not size mtime md5) %{_sysconfdir}/mnogosearch/search.htm
315 %config(noreplace) %verify(not size mtime md5) %{_sysconfdir}/mnogosearch/node.xml
316
317 # default dir for search databases should not be world-readable:
318 # the search engine could have indexed secret files
319 %attr (0750,mnogosearch,mnogosearch) %dir %{_localstatedir}/lib/mnogosearch
320
321 %files libs
322 %defattr(-,root,root,-)
323 %{_libdir}/lib*-*.so
324
325 %files devel
326 %defattr(-,root,root,-)
327 %{_bindir}/udm-config
328 %{_includedir}/mnogosearch
329 %{_libdir}/*.a
330 %{_libdir}/libmnogosearch.so
331 %{_libdir}/libmnogocharset.so
332
333 %files php
334 %defattr(-,root,root,-)
335 %{_sysconfdir}/php.d/mnogosearch.ini
336 %{php_extdir}
337
338 %changelog
339 * Thu Jan 27 2011 Gerd v. Egidy <gerd@egidy.de> 3.3.11-2
340 - last minute-changes in the 3.3.11 release
341 - enable some external document helpers by default:
342   we always have them because of requires
343 - require the binaries of the helpers used, not the package names
344 - use wvHtml instead of catdoc by default: it retains formatting
345 - don't disable the file types we now have helpers for
346
347 * Thu Jan 27 2011 Gerd v. Egidy <gerd@egidy.de> 3.3.11-1
348 - mnogosearch 3.3.11
349 - unit testing with two databases
350 - require catdoc and xlhtml for install and during build
351 - move make check into check-section
352 - fix timezone issue with test-blob unit test
353
354 * Thu Jan 27 2011 Gerd v. Egidy <gerd@egidy.de> 3.3.10-7.20110127cvs
355 - new cvs version with fix for directory names
356 - fix commandline options in mnogosearch-reindex
357
358 * Wed Jan 26 2011 Gerd v. Egidy <gerd@egidy.de> 3.3.10-6.20110126cvs
359 - import new upstream fixes for issues found during packaging
360 - group writeable default.db
361 - reindex option improvements by Alexander Barkov
362 - only create db on install
363 - create databases not with sqlite, but with the --create option of indexer
364
365 * Tue Jan 25 2011 Gerd v. Egidy <gerd@egidy.de> 3.3.10-5.20110124cvs
366 - update cvs version to get lib64 fix
367 - don't package *.la files as per Fedora review policy
368 - filter php module from provides
369 - create mnogosearch user and group during installation
370 - tighten file permissions to protect passwords and data
371 - create default configuration suitable for Fedora
372
373 * Fri Jan 21 2011 Gerd v. Egidy <gerd@egidy.de> 3.3.10-4.20110121cvs
374 - don't rename udm-config anymore
375 - better differentiation between release and cvs snapshots
376 - don't use $RPM_BUILD_DIR anymore
377
378 * Thu Jan 20 2011 Gerd v. Egidy <gerd@egidy.de> 3.3.10-3.20110120cvs
379 - make use of the new fhs configure option
380 - move language files to /usr/share
381 - move cgi to /usr/libexec
382 - clean up unneeded stuff left over from Mandriva
383 - link firebird database
384 - run supplied unit tests after build
385
386 * Mon Jan 17 2011 Gerd v. Egidy <gerd@egidy.de> 3.3.10-2.20110117cvs
387 - use current CVS as there are/will be some patches making packaging more easy
388
389 * Thu Jan 13 2011 Gerd v. Egidy <gerd@egidy.de> 3.3.10-1
390 - add building of the php module
391 - initial packaging for Fedora
392 - based on the Mandriva .spec by Oden Eriksson
393