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