]> git.pld-linux.org Git - packages/rpm.git/blob - rpm.macros
- %__gnome_doc_prepare, %update_mime_database, %update_icon_cache,
[packages/rpm.git] / rpm.macros
1 # $Revision$, $Date$
2 # PLD rpm macros
3
4 %epoch          0
5 %x8664          x86_64 amd64 ia32e
6
7 # kernel compiler
8 %kgcc           %{__cc}
9 %kgcc_package   gcc
10
11 # Build system path macros.
12 #
13 %__autoconf             autoconf %{?debug:-Wall}
14 %__automake             automake -a -c -f --foreign
15 %__autopoint            autopoint --force
16
17 %__gettextize { \
18 if ! gettextize --version | grep -q '0\.10\.' ; then \
19         if grep -qs 'AM_GNU_GETTEXT.*external' configure.{ac,in} ; then \
20                 gettextize --copy --force --no-changelog; \
21         else \
22                 gettextize --copy --force --no-changelog --intl; \
23         fi; \
24         if [ ! -f po/Makevars ]; then \
25                 cp -f po/Makevars{.template,}; \
26         fi; \
27 else \
28         gettextize --copy --force; \
29 fi; \
30 }
31
32 %__glib_gettextize      glib-gettextize --copy --force
33 %__gnome_doc_common     gnome-doc-common --copy
34 %__gnome_doc_prepare    gnome-doc-prepare --copy --force
35 %__gtkdocize            gtkdocize --copy
36 %__intltoolize          intltoolize --copy --force
37 %__libtoolize           libtoolize --copy --force
38
39 #       The number of cvs changelog entries kept when building package.
40 %_buildchangelogtruncate 20
41
42 %dependencytracking     %{nil}
43
44 #       Relations between package names that cause dependency loops
45 #       with legacy packages that cannot be fixed. Relations are
46 #       specified as
47 #               p>q
48 #       where package p has a Requires: on something that package q Provides:
49 #
50 # XXX   Note: that there cannot be any whitespace within the string "p>q",
51 #       and that both p and q are package names (i.e. no version/release).
52 %_dependency_whiteout   %{nil}
53
54 #-----------------------------------------------------------------
55 %configure2_13 { \
56  if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \
57  LDFLAGS="${LDFLAGS:-%rpmldflags}" ; export LDFLAGS ; \
58  CFLAGS="${CFLAGS:-%rpmcflags}" ; export CFLAGS ; \
59  CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" ; export CXXFLAGS ; \
60  FFLAGS="${FFLAGS:-%rpmcflags}" ; export FFLAGS ; \
61  CPPFLAGS="${CPPFLAGS:-}" ; export CPPFLAGS ; \
62  %{?__cc:CC="%{__cc}" ; export CC ; } \
63  %{?__cxx:CXX="%{__cxx}" ; export CXX ; } \
64  %{?configuredir:%{configuredir}}%{!?configuredir:.}/configure \
65         --host=%{_target_platform} \
66         --prefix=%{_prefix} \
67         --exec-prefix=%{_exec_prefix} \
68         --bindir=%{_bindir} \
69         --sbindir=%{_sbindir} \
70         --sysconfdir=%{_sysconfdir} \
71         --datadir=%{_datadir} \
72         --includedir=%{_includedir} \
73         --libdir=%{_libdir} \
74         --libexecdir=%{_libexecdir} \
75         --localstatedir=%{_localstatedir} \
76         --sharedstatedir=%{_sharedstatedir} \
77         --mandir=%{_mandir} \
78         --infodir=%{_infodir} \
79         --x-libraries=%{?_x_libraries}%{!?_x_libraries:%{_libdir}} \
80         %{dependencytracking} \
81 }
82
83 %cmake { \
84 CC="%{__cc}" \
85 CXX="%{__cxx}" \
86 CFLAGS="%{rpmcflags}" \
87 CXXFLAGS="%{rpmcxxflags}" \
88 cmake \
89 }
90
91 #----------------------------------------------------------------
92 %global configure_cache 0
93 %configure_cache_file   %{buildroot}.configure.cache
94
95 %configure {./configure \
96         LDFLAGS="${LDFLAGS:-%rpmldflags}" \
97         CFLAGS="${CFLAGS:-%rpmcflags}" \
98         CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" \
99         FFLAGS="${FFLAGS:-%rpmcflags}" \
100         CPPFLAGS="${CPPFLAGS:-}" \
101         %{?__cc:CC="%{__cc}"} \
102         %{?__cxx:CXX="%{__cxx}"} \
103         --host=%{_target_platform} \
104         --build=%{_target_platform} \
105         --prefix=%{_prefix} \
106         --exec-prefix=%{_exec_prefix} \
107         --bindir=%{_bindir} \
108         --sbindir=%{_sbindir} \
109         --sysconfdir=%{_sysconfdir} \
110         --datadir=%{_datadir} \
111         --includedir=%{_includedir} \
112         --libdir=%{_libdir} \
113         --libexecdir=%{_libexecdir} \
114         --localstatedir=%{_localstatedir} \
115         --sharedstatedir=%{_sharedstatedir} \
116         --mandir=%{_mandir} \
117         --infodir=%{_infodir} \
118         --x-libraries=%{?_x_libraries}%{!?_x_libraries:%{_libdir}} \
119         %{dependencytracking} \
120         %{?configure_cache:--cache-file=%{configure_cache_file:-%{buildroot}.configure.cache}} \
121 }
122
123 # ------------------------------------------------------------------------
124 # Overloading of some basic macros
125 %prep \
126 %%prep\
127 LANG=C\
128 export LANG\
129 unset DISPLAY ||:\
130 unset LINGUAS ||:\
131 %{nil}
132
133 %build %%build\
134 LANG=C\
135 export LANG\
136 unset DISPLAY ||:\
137 unset LINGUAS ||:\
138 %{nil}
139
140 %install \
141 %if 0%{?_enable_debug_packages}\
142 %{?buildsubdir:%{debug_package}}\
143 %endif\
144 %%install\
145 LANG=C\
146 export LANG\
147 unset DISPLAY ||:\
148 unset LINGUAS ||:\
149 %{nil}
150
151 # Location of autoconf macros
152 %_aclocaldir    %(aclocal --print-ac-dir)
153
154 # Location of omf files
155 %_omf_dest_dir  %(scrollkeeper-config --omfdir)
156
157 # Location of pkgconfig files
158 %_pkgconfigdir  /usr/%{_lib}/pkgconfig
159
160 # Location of desktop files
161 %_desktopdir    /usr/share/applications
162 %_applnkdir     ERROR:_applnkdir_is_obsolete_use_desktopdir_instead
163
164 # Location of pixmaps for applnk/desktop files
165 %_pixmapsdir    /usr/share/pixmaps
166
167 # Location of themable icons for applnk/desktop files
168 %_iconsdir      /usr/share/icons
169
170 # Location of fonts directories
171 %_fontsdir      /usr/share/fonts
172
173 # Location of Gtk and associated libraries documentation
174 %_gtkdocdir     %{_defaultdocdir}/gtk-doc/html
175
176 # Location of KDE documentation
177 %_kdedocdir     %{_defaultdocdir}/kde/HTML
178
179 # unsermake script
180 %__unsermake /usr/share/unsermake/unsermake
181
182 # Current date
183 %date           %(LC_ALL="C" date +"%a %b %d %Y")
184
185 # tmp directory
186 %tmpdir         %(echo "${TMPDIR:-/tmp}")
187
188 # Example files, programs, scripts...
189 %_examplesdir   /usr/src/examples
190
191 # Alternative kernel type/version
192 %_alt_kernel    %{nil}%{?alt_kernel:-%{?alt_kernel}}
193
194 # The directory holding Linux kernel sources
195 %_kernelsrcdir  /usr/src/linux%{_alt_kernel}
196
197 # If non-empty "debug" macro defined, add "dbg" suffix to release number
198 %_rpmfilename           %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
199
200 # Requires name = version-release
201 %requires_releq()               %(echo '%*' | LC_ALL="C" xargs -r rpm -q --qf 'Requires: %%{name} = %%{epoch}:%%{version}-%%{release}\\n' | sed -e 's/ (none):/ /' | grep -v "is not")
202
203 %releq_kernel_up()              %((LC_ALL="C" rpm -qf --qf '%%{name}-up = %%{epoch}:%%{version}-%%{release}\\n' %{_kernelsrcdir}/include/linux/version.h 2>/dev/null || echo ERROR) | sed -e 's/ (none):/ /' | sed -e 's:-headers::' | grep -vE "(is not|no such)")
204 %releq_kernel_smp()             %((LC_ALL="C" rpm -qf --qf '%%{name}-smp = %%{epoch}:%%{version}-%%{release}\\n' %{_kernelsrcdir}/include/linux/version.h 2>/dev/null || echo ERROR) | sed -e 's/ (none):/ /' | sed -e 's:-headers::' | grep -vE "(is not|no such)")
205 %requires_releq_kernel_up(s:)   Requires%{-s:(%{-s*})}: %releq_kernel_up
206 %requires_releq_kernel_smp(s:)  Requires%{-s:(%{-s*})}: %releq_kernel_smp
207
208 %requires_eq()          %(echo '%*' | LC_ALL="C" xargs -r rpm -q --qf 'Requires: %%{name} = %%{epoch}:%%{version}\\n' | sed -e 's/ (none):/ /' -e 's/ 0:/ /' | grep -v "is not")
209 %requires_eq_to() %(LC_ALL="C" rpm -q --qf 'Requires: %1 = %%{epoch}:%%{version}\\n' %2 | sed -e 's/ (none):/ /' | grep -v "is not")
210
211 %apache_modules_api %(awk '/#define MODULE_MAGIC_NUMBER_MAJOR/ {print $3}' /usr/include/apache/ap_mmn.h 2>/dev/null || echo ERROR)
212
213 # kernel version-release handling
214 %__kernel_ver   %([ -f %{_kernelsrcdir}/include/linux/version.h ] && (grep UTS_RELEASE %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | head -n 1 | cut -d'"' -f2) || (awk '/^VERSION/ { ver = $0; gsub(/VERSION.*=/, NIL, ver); } /^PATCHLEVEL/ { plev = $0; gsub(/PATCHLEVEL.*=/, NIL, plev); } /^SUBLEVEL/ { slev = $0; gsub(/SUBLEVEL.*=/, NIL, slev); } /^EXTRAVERSION/ { ever = $0; gsub(/EXTRAVERSION.*=/, NIL, ever); gsub(/ /, NIL, ever); } END { printf("%d.%d.%d%s", ver, plev, slev, ever); }' %{_kernelsrcdir}/Makefile 2> /dev/null))
215 %__kernel_rel   %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{RELEASE}" | grep -v "is not")
216 %__kernel_rpmvr %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{VERSION}-%{RELEASE}" | grep -v "is not")
217 %_kernel_ver    %{__kernel_ver}%{?with_dist_kernel:%(echo %{__kernel_ver} | grep -q -e - || echo -%{__kernel_rel})}
218 %_kernel_ver_str %(echo %{!?_without_dist_kernel:%{__kernel_rpmvr}}%{?_without_dist_kernel:%{__kernel_ver}} | sed -e 's/-/_/g')
219
220 # sgml macros
221 %xmlcat_add()           /usr/bin/xmlcatalog --noout --add nextCatalog \"\" %1 /etc/xml/catalog ;
222 %xmlcat_del()           /usr/bin/xmlcatalog --noout --del %1 /etc/xml/catalog ;
223 %xmlcat_add_rewrite     /usr/bin/xmlcatalog --noout --add rewriteSystem
224 %xmlcat_create()        /usr/bin/xmlcatalog --noout --create %1 ;
225 %sgmlcat_add()          /usr/bin/install-catalog --add %1 %2 > /dev/null ;
226 %sgmlcat_del()          /usr/bin/install-catalog --remove %1 %2 > /dev/null ;
227 %docbook_sgmlcat_fix() { for l in \
228 '' \
229 '  -- default decl --' \
230 'DTDDECL "-//OASIS//DTD DocBook XML V%2//EN" "../../xml.dcl"' \
231 '  -- hacks for opensp --' \
232 'SYSTEM "file://%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
233 'SYSTEM "http://www.oasis-open.org/docbook/xml/%2/docbookx.dtd"                  "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
234 '' \
235 ; do echo $l; done >> %1 \
236 }
237
238 # minimum file size needed for compressed documents.
239 # just smaller files than this get larger when compressed.
240 # some stats:
241 # - 0 byte file compressed was 25 bytes .gz
242 # - 39 byte file was compressed as 57
243 # - with test/test.spec@man 158 byte file was compressed also 158
244 %_min_compress_bytes    159
245
246 #-----------------------------------------------------------------
247 # find and gzip all files in %{_mandir} and %{infodir}
248 #
249 # Requires: xargs, find
250 #
251 #%no_install_post_compress_docs 1
252 %__spec_install_post_compress_docs { \
253 %{!?no_install_post_compress_docs:__spec_install_post_compress_docs() { \
254         echo "Compress man and info pages."; \
255         for i in /usr/share/man /usr/X11R6/man /usr/share/info; do \
256                 if [ -d "$RPM_BUILD_ROOT$i" ]; then \
257                         find "$RPM_BUILD_ROOT$i" -name '*.bz2' -print | xargs -r %{__bzip2} -df; \
258                         find "$RPM_BUILD_ROOT$i" -name '*.gz' -print | xargs -r %{__gzip} -dnf; \
259                         find "$RPM_BUILD_ROOT$i" -type f -size +%{_min_compress_bytes}c -print | xargs -r %{__gzip} -9nf; \
260                 fi; \
261         done; \
262 }; __spec_install_post_compress_docs } }
263
264 #-----------------------------------------------------------------
265 # Strip executable binaries and shared object files
266 #
267 # Requires: find, awk, strip, cut, xargs
268 #
269 #%no_install_post_strip 1
270 %__spec_install_post_strip {%{!?debug: \
271 %{!?no_install_post_strip:__spec_install_post_strip() { \
272         if [ -d "$RPM_BUILD_ROOT" ]; then \
273         echo "Strip executable binaries, archives and shared object files."; \
274         filelist=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" ! -regex ".*/usr/lib[0-9]*/debug/.*\.debug" %{?_noautostrip:! -regex "%{_noautostrip}"}`; \
275         elfexelist=`echo $filelist | xargs -r file | \
276                 awk '/ELF.*executable/ {print $1}' | cut -d: -f1`; \
277         elfsharedlist=`echo $filelist | xargs -r file | \
278                 awk '/LF.*shared object/ {print $1}' | cut -d: -f1`; \
279         elfarchiveslist=`echo $filelist | xargs -r file | \
280                 awk '/current ar archive/ {print $1}' | cut -d: -f1`; \
281         if [ -n "$elfexelist" ]; then \
282                 chmod u+w $elfexelist; \
283                 %{__strip} --remove-section=.note --remove-section=.comment $elfexelist; \
284         fi; \
285         if [ -n "$elfsharedlist" ]; then \
286                 chmod u+w $elfsharedlist; \
287                 %{__strip} --strip-unneeded --remove-section=.note --remove-section=.comment $elfsharedlist; \
288         fi; \
289         if [ -n "$elfarchiveslist" ]; then \
290                 chmod u+w $elfarchiveslist; \
291                 %{__strip} --strip-debug --remove-section=.note --remove-section=.comment $elfarchiveslist; \
292         fi; \
293 fi; }; __spec_install_post_strip } } }
294
295 #-----------------------------------------------------------------
296 # remove all RPATH from executable binaries and shared object files
297 #
298 # Requires: find, awk, cut, xargs, chrpath, uname
299 #
300 #%no_install_post_chrpath       1
301 %__spec_install_post_chrpath {%{!?debug: \
302 %{!?no_install_post_chrpath: __spec_install_post_chrpath() { \
303 if [ -d "$RPM_BUILD_ROOT" ]; then \
304 echo "Remove RPATH from executable binaries and shared object files."; \
305 find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" ! -regex ".*/usr/lib[0-9]*/debug/.*" %{?_noautochrpath:! -regex "%{_noautochrpath}"} | xargs -r file | \
306         awk '/ELF.*(executable.*dynamically linked|shared object)/ {print $1}' | cut -d: -f1 | \
307 while read file ; do \
308         rpath= ; \
309         chmod u+w "$file"; \
310         for dir in `chrpath -l "$file" | \
311                         awk '/RPATH=/ { gsub(/.*RPATH=/,""); gsub(/:/," "); print $0 }'` ; do \
312                         case $dir in \
313                         /home/* | /tmp/* | /usr/lib | /usr/lib64 | /lib | /lib64 | /usr/local/lib | /usr/local/lib64 | /usr/X11R6/lib | /usr/X11R6/lib64 ) \
314                                 echo "remove-rpath: $dir in $file"; \
315                                 ;; \
316                         * ) \
317                                 if [ "$rpath" = "" ] ; then rpath="$dir" ; \
318                                 else rpath="$rpath:$dir" ; fi ; \
319                                 ;; \
320                         esac ; \
321         done ; \
322         if [ "$rpath" = "" ] ; then chrpath -d "$file" > /dev/null ; \
323         else chrpath -r "$rpath" "$file" > /dev/null ; fi ; \
324 done; \
325 fi; }; __spec_install_post_chrpath } } }
326
327 #-----------------------------------------------------------------
328 # Find and gzip all kernel modules
329 #
330 # Requires: find
331 #
332 #%no_install_post_compress_modules      1
333 %__spec_install_post_compress_modules { \
334 %{!?no_install_post_compress_modules: __spec_install_post_compress_modules() { \
335         if [ -d "$RPM_BUILD_ROOT" ]; then \
336                 echo "Compress kernel modules if any."; \
337                 if test -d $RPM_BUILD_ROOT/lib/modules ; then \
338                         find $RPM_BUILD_ROOT/lib/modules -name \*o -type f -print | \
339                         xargs -r %{__gzip} -9nf; \
340                         find $RPM_BUILD_ROOT/lib/modules -name \*o -type l -printf "%p %l\n" | \
341                         while read a b; do ln -sf $b.gz $a.gz; rm -f $a; done; \
342                 fi; \
343         fi; \
344 }; __spec_install_post_compress_modules } }
345
346 # Remove common Perl files we don't package
347 %__spec_install_post_perl_clean {\
348 %{!?no_install_post_perl_clean: \
349 %{?pdir:rm -f $RPM_BUILD_ROOT{%{perl_archlib}/perllocal.pod,%{perl_vendorarch}/auto/%{pdir}%{?pnam:/%(echo %{pnam} | tr - /)}/.packlist}} \
350 } }
351
352 #-----------------------------------------------------------------
353 # Update GConf2 schemas
354 #
355 # Requires: GConf2
356 #
357 %gconf_schema_install() \
358         umask 022; \
359         GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" /usr/bin/gconftool-2 --makefile-install-rule /etc/gconf/schemas/%{?1}%{!?1:*.schemas} > /dev/null \
360         %{nil}
361
362 %gconf_schema_uninstall() \
363 if [ $1 = 0 ]; then \
364         umask 022; \
365         GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" /usr/bin/gconftool-2 --makefile-uninstall-rule /etc/gconf/schemas/%{?1} > /dev/null \
366 fi \
367 %{nil}
368
369 #-----------------------------------------------------------------
370 # Update desktop MIME database
371 # requires: desktop-file-utils
372 #
373 %update_desktop_database_post() {{ \
374         umask 022; \
375         /usr/bin/update-desktop-database -q; \
376 }}
377
378 %update_desktop_database_postun() {{ \
379 if [ $1 = 0 ]; then \
380         umask 022; \
381         /usr/bin/update-desktop-database -q; \
382 fi \
383 }}
384
385 #-----------------------------------------------------------------
386 # Update shared MIME info database
387 # requires: shared-mime-info
388 #
389 %update_mime_database() {{ \
390         umask 022; \
391         /usr/bin/update-mime-database %{_datadir}/mime; \
392 }}
393
394 #-----------------------------------------------------------------
395 # Update icon cache
396 # requires: gtk+
397 #
398 %update_icon_cache() {{ \
399         umask 022; \
400         gtk-update-icon-cache -qf %{_datadir}/icons/%1; \
401 }}
402
403 #-----------------------------------------------------------------
404 # Update scrollkeeper database
405 # requires: scrollkeeper
406 #
407 %scrollkeeper_update_post() \
408         /usr/bin/scrollkeeper-update -q; \
409         %{nil}
410
411 %scrollkeeper_update_postun() \
412 if [ $1 = 0 ]; then \
413         /usr/bin/scrollkeeper-update -q; \
414 fi \
415 %{nil}
416
417 #-----------------------------------------------------------------
418 # post %install sequence:
419 # - autodeps exceptions
420 # - compress all man and info pages,
421 # - strip all ELF executables and ELF shared objects if not %debug.
422 # - compress kernel modules if any
423
424 ###################################################################
425 # Requires/Provides automation
426 # exceptions system by Jacek Konieczny <jajcus@pld.org.pl>
427 #
428 %__noautoreqfiles       %(sed -e s'/#.*//' /etc/rpm/noautoreqfiles)%{?_noautoreqfiles: %{_noautoreqfiles}}
429 %__noautoprovfiles      %(sed -e s'/#.*//' /etc/rpm/noautoprovfiles)%{?_noautoprovfiles: %{_noautoprovfiles}}
430 %__noautoreq            %(sed -e s'/#.*//' /etc/rpm/noautoreq)%{?_noautoreq: %{_noautoreq}}
431 %__noautoreqdep         %(sed -e s'/#.*//' /etc/rpm/noautoreqdep)%{?_noautoreqdep: %{_noautoreqdep}}
432 %__noautoprov           %(sed -e s'/#.*//' /etc/rpm/noautoprov)%{?_noautoprov: %{_noautoprov}}
433 #%_noautocompressdoc    %{nil}
434 #
435 %_missing_doc_files_terminate_build     1%{nil}
436 %_unpackaged_files_terminate_build      %{nil}
437 # (X)emacs support
438 %___emacs_lispdir_helper  -batch -q -eval '(while load-path (princ (concat (car load-path) "\\n")) (setq load-path (cdr load-path)))' 2> /dev/null|sed -n '/\\(.*\\/x\\?emacs\\/site-lisp\\)\\/\\?$/{s,,\\1,p;q;}'
439 %_emacs_lispdir %(emacs %___emacs_lispdir_helper)
440 %_xemacs_lispdir %(xemacs %___emacs_lispdir_helper)
441
442 %__php_provides %{nil}
443 %__php_requires %{nil}
444 %__perl_provides %{nil}
445 %__perl_requires %{nil}
446 %__mono_provides %{nil}
447 %__mono_requires %{nil}
448
449 # Perl specific macro definitions.
450 %perl_privlib           %(eval "`%{__perl} -V:installprivlib`"; echo $installprivlib)
451 %perl_archlib           %(eval "`%{__perl} -V:installarchlib`"; echo $installarchlib)
452 %perl_vendorlib         %(eval "`%{__perl} -V:installvendorlib`"; echo $installvendorlib)
453 %perl_vendorarch        %(eval "`%{__perl} -V:installvendorarch`"; echo $installvendorarch)
454 %perl_sitelib           %(eval "`%{__perl} -V:installsitelib`"; echo $installsitelib)
455 %perl_sitearch          %(eval "`%{__perl} -V:installsitearch`"; echo $installsitearch)
456
457 # Ruby
458 %ruby_archdir           %(ruby -r rbconfig -e 'print Config::CONFIG["archdir"]' 2>/dev/null || echo ERROR)
459 %ruby_ridir             %(ruby -r rbconfig -e 'include Config; print File.join(CONFIG["datadir"], "ri", CONFIG["ruby_version"], "system")' 2>/dev/null || echo ERROR)
460 %ruby_rubylibdir        %(ruby -r rbconfig -e 'print Config::CONFIG["rubylibdir"]' 2>/dev/null || echo ERROR)
461 %ruby_sitearchdir       %(ruby -r rbconfig -e 'print Config::CONFIG["sitearchdir"]' 2>/dev/null || echo ERROR)
462 %ruby_sitelibdir        %(ruby -r rbconfig -e 'print Config::CONFIG["sitelibdir"]' 2>/dev/null || echo ERROR)
463 %ruby_version           %(ruby -r rbconfig -e 'print Config::CONFIG["ruby_version"]' 2>/dev/null || echo ERROR)
464 %ruby_ver_requires_eq   Requires:       ruby(ver) = %ruby_version
465 %ruby_mod_ver_requires_eq       Requires:       ruby-modules(ver) = %ruby_version
466
467 %php_pear_dir   %{_datadir}/pear
468
469 # directory where php includes are installed on system.
470 %__php_includedir               /usr/include/php
471 # extract php/zend api versions
472 %php_major_version              %(awk '/#define PHP_MAJOR_VERSION/{print $3}' %{__php_includedir}/main/php_version.h 2>/dev/null || echo ERROR)
473 %php_api_version                %(awk '/#define PHP_API_VERSION/{print $3}' %{__php_includedir}/main/php.h 2>/dev/null || echo ERROR)
474 %php_pdo_api_version    %(awk '/#define PDO_DRIVER_API/{print $3}' %{__php_includedir}/ext/pdo/php_pdo_driver.h 2>/dev/null || echo ERROR)
475 %php_debug                              %(awk '/#define ZEND_DEBUG/{print $3}' %{__php_includedir}/main/php_config.h 2>/dev/null || echo ERROR)
476 %zend_module_api                %(awk '/#define ZEND_MODULE_API_NO/{print $3}' %{__php_includedir}/Zend/zend_modules.h 2>/dev/null || echo ERROR)
477 %zend_extension_api             %(awk '/#define ZEND_EXTENSION_API_NO/{print $3}' %{__php_includedir}/Zend/zend_extensions.h 2>/dev/null || echo ERROR)
478 %zend_zts                               %(Z=$(grep -sc '^#define ZTS 1' %{__php_includedir}/main/php_config.h); echo ${Z:-ERROR})
479
480 # helper macro
481 %__php_api_requires(v:) Requires: php%{-v*}(%{expand:%1}) = %{expand:%{%{!?2:%{1}}%{?2}}}
482
483 # macros for public use
484 # for php extensions (php-pecl)
485 %requires_php_extension %{__php_api_requires modules_api php_api_version} \
486 %{__php_api_requires -v %php_major_version debug php_debug} \
487 %{__php_api_requires -v %php_major_version thread-safety zend_zts}
488
489 # for zend extensions
490 %requires_zend_extension %{__php_api_requires zend_module_api} \
491 %{__php_api_requires zend_extension_api} \
492 %{__php_api_requires -v %php_major_version debug php_debug} \
493 %{__php_api_requires -v %php_major_version thread-safety zend_zts}
494
495 # for php pdo modules (php-pecl-PDO_*)
496 %requires_php_pdo_module %{__php_api_requires PDO_API php_pdo_api_version}
497
498 # Python specific macro definitions.
499 # python main version
500 %py_ver         %(python -c "import sys; print sys.version[:3]")
501
502 # directories
503 %py_prefix              %(python -c "import sys; print sys.prefix")
504 %py_libdir              %{py_prefix}/%{_lib}/python%{py_ver}
505 %py_scriptdir   %{py_prefix}/share/python%{py_ver}
506 %py_incdir              /usr/include/python%{py_ver}
507 %py_sitedir     %{py_libdir}/site-packages
508 %py_sitescriptdir %{py_scriptdir}/site-packages
509 %py_dyndir              %{py_libdir}/lib-dynload
510
511 # pure python modules compilation
512 %py_comp                python -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
513
514 %py_ocomp               python -O -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
515
516 # Software written in Python language require Python with main version
517 %pyrequires_eq() Requires:      %1
518
519 # Hardlink binary identical .pyc and .pyo files
520 # (idea by glen <at> pld-linux <dot> org)
521 %__spec_install_post_py_hardlink {\
522 %{!?no_install_post_py_hardlink: __spec_install_post_py_hardlink() { \
523 [ ! -d "$RPM_BUILD_ROOT" ] || find "$RPM_BUILD_ROOT" -name '*.pyc' | while read a; do \
524         b="$(echo $a|sed -e 's/.pyc$/.pyo/')"; \
525         if cmp -s "$a" "$b"; then \
526                 ln -f "$a" "$b"; \
527         fi; \
528 done \
529 }; __spec_install_post_py_hardlink } }
530
531 # remove python sources, so that check-files won't complain
532 # (idea by glen <at> pld-linux <dot> org)
533 %py_postclean() \
534 for d in %{py_sitescriptdir} %{py_sitedir} %*; do \
535  [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -print0 | xargs -0r -l512 rm;\
536 done \
537 %{nil}
538
539 # depmod macro
540 %depmod() { \
541 umask 022; \
542 if [ -e /boot/System.map-%1 ]; then \
543         /sbin/depmod -a -F /boot/System.map-%1 %1; \
544 else \
545         if [ -e /boot/System.map ]; then \
546                 /sbin/depmod -a -F /boot/System.map %1; \
547         else \
548                 /sbin/depmod -a %1; \
549         fi \
550 fi; \
551 }
552
553 # XMMS specific macros
554 %xmms_prefix                    %(xmms-config --prefix 2>/dev/null)
555 %xmms_exec_prefix               %(xmms-config --exec-prefix 2>/dev/null)
556 %xmms_version                   %(xmms-config --version 2>/dev/null)
557 %xmms_datadir                   %(xmms-config --data-dir 2>/dev/null)
558 %xmms_plugindir                 %(xmms-config --plugin-dir 2>/dev/null)
559 %xmms_visualization_plugindir   %(xmms-config --visualization-plugin-dir 2>/dev/null)
560 %xmms_input_plugindir           %(xmms-config --input-plugin-dir 2>/dev/null)
561 %xmms_output_plugindir          %(xmms-config --output-plugin-dir 2>/dev/null)
562 %xmms_effect_plugindir          %(xmms-config --effect-plugin-dir 2>/dev/null)
563 %xmms_general_plugindir         %(xmms-config --general-plugin-dir 2>/dev/null)
564
565 %_target_base_arch      %(echo %{_target_cpu} | sed 's/i.86/i386/;s/athlon/i386/;s/pentium./i386/;s/amd64/x86_64/;s/ia32e/x86_64/')
566
567 # user/group checking macros
568 #
569 # Usage:
570 #       %userremove myuser
571 #
572 %userremove     /usr/lib/rpm/user_group.sh user del
573 %groupremove    /usr/lib/rpm/user_group.sh group del
574 #
575 # Usage:
576 #       if %usertestrm myuser; then
577 #               /usr/sbin/userdel -r myuser
578 # Note:
579 #       use these macros only if you need to call userdel/groupdel with
580 #       a non-standard option or take an extra action; otherwise use the
581 #       %userremove/%groupremove macros
582 #
583 %usertestrm     /usr/lib/rpm/user_group.sh user testrm
584 %grouptestrm    /usr/lib/rpm/user_group.sh group testrm
585 # user group membership management macros
586 #
587 # Usage:
588 #       %addusertogroup myuser agroup
589 #
590 %addusertogroup /usr/lib/rpm/user_group.sh user addtogroup
591
592 # banner support (useful in {pre,post}{,un} and triggers)
593 #
594 # Usage:
595 #       %banner name [-a] [-e] [-n] [-tn] <<EOF
596 # the banner text, the banner text
597 # the banner text, and following line
598 #EOF
599 # You can use any form of here-document, <<'EOF' <<-EOT will do.
600 # NOTE: if your use "<<-EOF", then You can actually indent inside here-document.
601 #
602 # -a   - append to the banner
603 # -e   - send to stderr instead of stdout
604 # -n   - no show banner (overrides -t)
605 # -t   - show only, if RPM_SCRIPTVERBOSITY >= n; default n=5
606 %banner(aent:)  \
607 RPM_SCRIPTVERBOSITY=5 \
608 [ -r /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm \
609 if [ -x /usr/bin/banner.sh ]; then \
610         CMD="/usr/bin/banner.sh %{-e:--stderr} %{!-n:$([ $RPM_SCRIPTVERBOSITY -ge %{-t:%{-t*}}%{!-t:5} ] && echo -s)} %{!-a:-m}%{-a:-M} %1" \
611 else \
612         CMD="cat%{-e: >&2}" \
613 fi \
614 eval $CMD %2%{?3: %3} \
615 %nil
616
617 # useradd/groupadd macros written by glen@pld-linux.org.
618 # All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
619 #
620 # Usage:
621 #   %useradd [-P package] [-u uid] [-d home_dir] [-s shell] [-c comment]
622 #   [-g initial_group] [-G group[,...]] login
623 #
624 #  -u uid. REQUIRED
625 #  -g gid/group. REQUIRED
626 #  -s defaults to /bin/false
627 #  -d defaults to /usr/share/empty
628 #  -c No default
629 #  -r is accepted but ignored (it's always set)
630 #  -k skeleton dir. defaults to /usr/share/empty
631 # rpm specific flags
632 #  -P package name. defaults to %{name}
633 #
634 %useradd(c:d:e:f:g:G:Mmk:op:s:u:rP:) \
635 %{!-u:%{error:useradd: Required argument -u missing}} \
636 %{!-g:%{error:useradd: Required argument -g missing}} \
637 %{!?1:%{error:useradd: Required parameter login missing}} \
638 if [ -n "`/bin/id -u %{expand:%{%{#}}} 2>/dev/null`" ]; then \
639         if [ "`/bin/id -u %{expand:%{%{#}}}`" != "%{-u*}" ]; then \
640                 echo "Error: user %{expand:%{%{#}}} doesn't have uid=%{-u*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
641                 exit 1 \
642         fi \
643 else \
644         echo "Adding user %{expand:%{%{#}}} UID=%{-u*}." \
645         /usr/sbin/useradd \\\
646                 %{-m:-m -k %{-k*}%{!-k:/usr/share/empty}} \\\
647                 -u %{-u*} \\\
648                 -r \\\
649                 -d %{-d*}%{!-d:/usr/share/empty} \\\
650                 -s %{-s*}%{!-s:/bin/false} \\\
651                 %{-c:-c "%(set -- %{-c*} %{*}; echo $1)"}\\\
652                 -g %{-g*} \\\
653                 %{-M} \\\
654                 %{-G:-G %{-G*}} \\\
655                 %{expand:%{%{#}}} 1>&2 || exit $? \
656         [ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i passwd \
657 fi;
658
659 # Usage:
660 #   %groupadd [-P package] [-g gid] group
661 #
662 # -g gid. REQUIRED
663 #
664 # Sample:
665 #   %groupadd -P %{name}-base -g %{gid} %{name}
666
667 %groupadd(g:P:rfo)      \
668 %{!-g:%{error:groupadd: Required argument -g missing}} \
669 %{!?1:%{error:groupadd: Required parameter group missing}} \
670 if [ -n "`/usr/bin/getgid %{1}`" ]; then \
671         if [ "`/usr/bin/getgid %{1}`" != "%{-g*}" ]; then \
672                 echo "Error: group %{1} doesn't have gid=%{-g*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
673                 exit 1 \
674         fi \
675 else \
676         echo "Adding group %{1} GID=%{-g*}." \
677         /usr/sbin/groupadd -g %{-g*} -r %{1} 1>&2 || exit $? \
678         [ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i group \
679 fi;
680
681 # apache_config_{install/uninstall} macros written by glen@pld-linux.org.
682 # All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
683 #
684 # You should use webapp macros instead. these are here until single piece of them is gone from specs ;)
685 #
686 # The config is installed/removed inside trigger, this means that you can any
687 # time install apache1 or apache package and the configuration file is updated.
688 # if you don't need the config for various reason for specific apache, just
689 # remove the symlink from apache config directory. the trigger will not put the
690 # config again to that version of apache. In other words the config is linked
691 # to apache config directory on first install of PACKAGE or apache.
692 #
693 # should be called in trigger body:
694 #  %triggerin -- apache1 >= 1.3.33-2
695 #  %apache_config_install -v 1
696 #
697 # Add package's apache config to apache config.
698 #
699 # Usage:
700 #   %apache_config_install -v {1|2} -c %{_sysconfdir}/apache-%{name}.conf -n 99
701 #
702 #  -v REQUIRED: specify apache version. can be 1 or 2.
703 #  -c OPTIONAL: specify full path to PACKAGE's config. Defaults to %{_sysconfdir}/apache-%{name}.conf.
704 #  -n OPTIONAL: specify config "slot". defaults to 99
705 #  -f OPTIONAL: force symlink creation regardless if package was upraded. useful in triggers
706 #
707 # Internal macros. don't use ;).
708 # expands apache config dir by apache version at build time.
709 %__apache_confdir() %(if [ %{1} = 1 ]; then echo /etc/apache/conf.d; elif [ %{1} = 2 ]; then echo /etc/httpd/httpd.conf; else echo >&2 Unknown apache version specified; fi)
710 # expands apache service name by apache version at build time.
711 %__apache_svcname() %(if [ %{1} = 1 ]; then echo apache; elif [ %{1} = 2 ]; then echo httpd; else echo >&2 Unknown apache version specified; fi)
712
713 %apache_config_install(fv:c:n:) \
714 %{!-v:%{error:apache_config_install: Required argument -v missing}} \
715 %{?debug:set -x; echo "apache_config_install:%{-v*} %{name}-%{version}-%{release} 1:[$1]; 2:[$2]"} \
716 if [ -n "%{-f:1}" ] || ([ "$1" = "1" ] && [ "$2" = "1" ]) && [ -d %{__apache_confdir %{-v*}} ]; then\
717         ln -sf %{-c*}%{!-c:%{_sysconfdir}/apache-%{name}.conf} %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf\
718 fi\
719 # reload apache if the config symlink is there\
720 if [ -L %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf ]; then\
721         # additionally don't reload if target package (the webserver) is upgraded, as webserver is restarted anyway in %post \
722         if [ "$2" != "2" ] && [ -f /var/lock/subsys/%{__apache_svcname %{-v*}} ]; then\
723                 /etc/rc.d/init.d/%{__apache_svcname %{-v*}} reload 1>&2\
724         fi\
725 fi\
726 %{nil}
727
728 # Remove package's apache config from apache config.
729 #
730 # Usage:
731 #   %apache_config_uninstall -v {1|2} -n 99
732 #
733 #  -v REQUIRED: specify apache version. can be 1 or 2.
734 #  -n OPTIONAL: specify config "slot". defaults to 99
735 %apache_config_uninstall(v:n:) \
736 %{!-v:%{error:apache_config_uninstall: Required argument -v missing}} \
737 %{?debug:set -x; echo "apache_config_uninstall:%{-v*} %{name}-%{version}-%{release}: 1:[$1]; 2:[$2]"} \
738 # remove link if either of the packages are gone \
739 if [ "$1" = "0" ] || [ "$2" = "0" ]; then \
740         if [ -L %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf ]; then \
741                 rm -f %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf \
742                 if [ -f /var/lock/subsys/%{__apache_svcname %{-v*}} ]; then \
743                         /etc/rc.d/init.d/%{__apache_svcname %{-v*}} reload 1>&2 \
744                 fi \
745         fi \
746 fi \
747 %{nil}
748
749 # webapp macros
750 #
751 # The config is installed/removed inside trigger, this means that you can any
752 # time install apache1/apache/lighttpd package and the configuration file is
753 # updated. if you don't need the config for various reason for specific
754 # webserver, just remove the symlink from config directory using webapp
755 # program. the trigger will not recreate the symlink on upgrades. In other
756 # words the config is linked to webserver config directory on first install of
757 # PACKAGE or WEBSERVER.
758 #
759 # Add package's webserver config to webserver webapps dir.
760 # Usage:
761 #   %webapp_register WEBSERVER WEBAPP
762 #
763 %webapp_register() \
764 %{?debug:set -x; echo "webapp_register: %{name}-%{version}-%{release} 1:[$1]; 2:[$2]"} \
765 if [ "$1" = "1" ] && [ "$2" = "1" ]; then\
766         /usr/sbin/webapp register %1 %2\
767 fi\
768 # reload webserver if the config symlink is there and skip reload if webserver is upgraded\
769 if [ -L /etc/%1/webapps.d/%(echo "%2" | tr '/' '-').conf ] && [ "$2" -lt "2" ]; then\
770         %{expand:%service -q %%1 reload}\
771 fi\
772 %{nil}
773
774 # Remove package's config from webserver webapps dir.
775 # Usage:
776 #   %webapp_register [-f] WEBSERVER WEBAPP
777 %webapp_unregister(f) \
778 %{?debug:set -x; echo "webapp_unregister: %{name}-%{version}-%{release}: 1:[$1]; 2:[$2]"} \
779 # remove link if either of the packages are gone \
780 if [ -n "%{-f:1}" ] || [ "$1" = "0" ] || [ "$2" = "0" ] && [ -L /etc/%1/webapps.d/%(echo "%2" | tr '/' '-').conf ]; then \
781         /usr/sbin/webapp unregister %1 %2\
782         %{expand:%service -q %%1 reload}\
783 fi \
784 %{nil}
785
786 # see browser-plugins.spec / template-browser-plugin.spec
787 # written by glen@pld-linux.org.
788 %nsplugin_install(d:f) { \
789 # create link if it's first install of either of the packages \
790 if [ -n "%{-f:1}" ] || ([ "$1" = "1" ] && [ "$2" = "1" ] && [ -d %{-d*} ]); then \
791 ( \
792 %( \
793         for file in %{*}; do \
794                 echo echo Installing $file to %{-d*}; \
795                 echo "ln -sf %{_libdir}/browser-plugins/$file %{-d*};"; \
796         done ) \
797 ) | ( %banner -t 5 -e %{name}-in ); fi; \
798 }
799
800 %nsplugin_uninstall(d:) { \
801 # remove link if either of the packages are gone \
802 if [ "$1" = "0" ] || [ "$2" = "0" ]; then \
803 ( \
804 %( \
805         for file in %{*}; do \
806                 echo echo Removing $file from %{-d*}; \
807                 echo "rm -f %{-d*}/$file;"; \
808         done ) \
809 ) | ( %banner -t 5 -e %{name}-un ); fi; \
810 }
811
812 # service macro.
813 #
814 # calls usual service restart on package %post, but skips the restart if
815 # administrator has disabled automatic service restarts in either global
816 # /etc/sysconfig/rpm or per service /etc/sysconfig/SERVICE file.
817 #
818 # written by glen@pld-linux.org.
819 # All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
820 #
821 # Usage:
822 #   %service [-q] SERVICE ACTION ["SERVICE NICE DESCRIPTION"]
823 #
824 #  -q be silent when service isn't started (for scriplets restaring other package's services)
825 #
826 %service(q) {{%(export quiet=%{-q:1}; /usr/lib/rpm/service_generator.sh %{*}) };}
827
828
829 # java macros. based on jpackage macros.java
830 %_jvmdir                %{_libdir}/jvm
831 %_jvmjardir             %{_libdir}/jvm-exports
832 %_jvmprivdir            %{_libdir}/jvm-private
833 %_jvmlibdir             %{_libdir}/jvm
834 %_jvmdatadir            %{_datadir}/jvm
835 %_jvmsysconfdir         %{_sysconfdir}/jvm
836 # FIXME: are these used?
837 %_jvmcommonlibdir       %{_libdir}/jvm-common
838 %_jvmcommondatadir      %{_datadir}/jvm-common
839 %_jvmcommonsysconfdir   %{_sysconfdir}/jvm-common
840 %_jnidir                %{_libdir}/java
841 %java_home              %(unset JAVA_HOME; . %{_javadir}-utils/java-functions; set_jvm; echo $JAVA_HOME)
842
843 %ant                    JAVA_HOME=%{java_home} ant
844 %jar                    %{java_home}/bin/jar
845 %java                   %(unset JAVACMD; . %{_javadir}-utils/java-functions; set_javacmd; echo $JAVACMD)
846 %javac                  %{java_home}/bin/javac
847 %javadoc                %{java_home}/bin/javadoc
848
849 %add_jvm_extension      JAVA_LIBDIR=%{buildroot}/%{_javadir}    %{_bindir}/jvmjar -l
850
851 %jpackage_script() \
852 install -d $RPM_BUILD_ROOT%{_bindir}\
853 cat > $RPM_BUILD_ROOT%{_bindir}/%5 << 'EOF' \
854 #!/bin/sh\
855 #\
856 # %{name} script\
857 # JPackage Project <http://www.jpackage.org/>\
858 \
859 # Source functions library\
860 . %{_javadir}-utils/java-functions\
861 \
862 # Source system prefs\
863 if [ -f %{_sysconfdir}/java/%{name}.conf ]; then\
864     . %{_sysconfdir}/java/%{name}.conf\
865 fi\
866 \
867 # Source user prefs\
868 if [ -f $HOME/.%{name}rc ]; then\
869     . $HOME/.%{name}rc\
870 fi\
871 \
872 # Configuration\
873 MAIN_CLASS=%1\
874 BASE_FLAGS=%2\
875 BASE_OPTIONS=%3\
876 BASE_JARS="%(echo %4 | tr ':' ' ')"\
877 \
878 # Set parameters\
879 set_jvm\
880 set_classpath $BASE_JARS\
881 set_flags $BASE_FLAGS\
882 set_options $BASE_OPTIONS\
883 \
884 # Let's start\
885 run "$@"\
886 EOF
887
888 # pear install macros written by glen@pld-linux.org.
889 # All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
890 #
891 # Usage:
892 #       %%pear_package_setup [-a #] [-n FMT]
893 #
894 # -a #   - unpack SOURCE# instead of SOURCE0
895 # -n FMT - create builddir with FMT, instead of default %%{_pearname}-%%{version}
896 # -z     - unpack pear package and let pear use package.xml (not tarball) for install. use this for buggy packages.
897 # -f     - force pear install. use with care.
898 #
899 # unpack PEAR package to %%{_builddir}/FMT. package is extracted with already
900 # destination hierarchy. you should copy the tree to buildroot after
901 # patching/reorganizing with %%pear_package_install.
902 #
903 # additionally BUILDROOT is stripped from files and files are converted to UNIX
904 # line endings.
905 #
906 # the pear install process output is recorded to install.log, you should put it
907 # to %%doc for latter debug or just information.
908 #
909 # additionally additional-packages.txt is produced if it was detected that the
910 # package has optional dependencies. the file format is suitable of displaying
911 # in %%post of a package. you should put this file to %%doc. noautocompressdoc is
912 # automatically added for this file.
913 #
914 %pear_package_setup(a:n:zf) \
915 %setup -q -c -T -n %{-n*}%{!-n:%{_pearname}-%{version}}\
916 D=%{_builddir}/%{-n*}%{!-n:%{_pearname}-%{version}} \
917 %{-z:tar zxf %{S:%{-a*}%{!-a:0}}; P=%{_pearname}-%{version}/package.xml; [ -f $P ] || P=package.xml} \
918 pear \\\
919         -d doc_dir=/docs \\\
920         -d php_dir=%{php_pear_dir} \\\
921         -d bin_dir=%{_bindir} \\\
922         -d data_dir=%{php_pear_dir}/data \\\
923         -d test_dir=%{php_pear_dir}/tests \\\
924         install \\\
925         --installroot=${D} \\\
926         --offline \\\
927         --nodeps \\\
928         %{-f:--force} \\\
929         %{!-z:%{S:%{-a*}%{!-a:0}}}%{-z:$P} | tee install.log \
930 # make post message of optional packages \
931 grep 'can optionally use' install.log | sed -e 's,package "pear/,package "php-pear-,g;s,^pear/,php-pear-,' > optional-packages.txt \
932 if [ -s optional-packages.txt ]; then \
933         awk -F'"' '/use package/{print $2}' optional-packages.txt | sed -e "s,_,/,g;s,php-pear-, 'pear(,;s,$,.*)'," | tr -d '\\\n' > _noautoreq \
934 else \
935         rm -f optional-packages.txt \
936 fi \
937 rm ./%{php_pear_dir}/.{lock,filemap} \
938 # undos sources \
939 find . -type f -print0 | xargs -0 sed -i -e 's,\\r$,,' \
940 # bug in PEAR --installroot. \
941 # http://pear.php.net/bugs/bug.php?id=5448 \
942 grep -rl "${D}" ./{%{_bindir},%{php_pear_dir}}/* | xargs -r sed -i -e "s,${D},," \
943 %{!?_noautocompressdoc:%global _noautocompressdoc %{nil}}%{expand:%%global _noautocompressdoc %{_noautocompressdoc} optional-packages.txt} \
944 %{!?_noautoprov:%global _noautoprov %{nil}}%{expand:%%global _noautoprov %{_noautoprov} 'pear(tests/.*)'} \
945 %{nil}
946
947 # copies exctracted PEAR package structure to buildroot.
948 # also copies PEAR registry file.
949 # please use this macro, for future extensions being possible.
950 %pear_package_install() \
951 cp -a ./%{php_pear_dir}/{.registry,*} $RPM_BUILD_ROOT%{php_pear_dir} \
952 find $RPM_BUILD_ROOT%{php_pear_dir} '(' -name '*~' -o -name '*.orig' ')' | xargs -r rm -v \
953 # help the developer out a little: \
954 if [ -f _noautoreq ]; then \
955         echo "AutoReqdep detected:" \
956         echo "_noautoreq $(cat _noautoreq)" \
957 fi \
958 %{nil}
959
960
961 # Register OpenLDAP schema.
962 # Author: Elan Ruusamäe <glen@pld-linux.org>
963 #
964 # Usage:
965 #   %%openldap_schema_register [-d core,nis] %{schemadir}/horde.schema
966 #
967 #  -d specify dependant schemas, separated by comma
968 #
969 %openldap_schema_register(d:) \
970 for schema in %*; do \
971         if ! grep -q "$schema" /etc/openldap/slapd.conf; then \
972                 %{__sed} -i -e " \
973                         /^include.*local.schema/{ \
974                                 iinclude\\t     $schema\
975                         } \
976                 " /etc/openldap/slapd.conf \
977         fi \
978 done \
979 # enable dependant schemas \
980 if [ "%{-d*}" ]; then \
981         %{__sed} -i -e ' \
982         /^#include.*\\(%(echo '%{-d*}' | %{__sed} -e 's/,/\\\\|/g')\\)\\.schema/{ \
983                 s/^#// \
984         }' /etc/openldap/slapd.conf \
985 fi \
986 %{nil}
987
988 # Unregister OpenLDAP schema.
989 # Author: Elan Ruusamäe <glen@pld-linux.org>
990 #
991 # Usage:
992 #   %%openldap_schema_unregister %{schemadir}/horde.schema
993 #
994 %openldap_schema_unregister() \
995 for schema in %*; do \
996         if grep -q "$schema" /etc/openldap/slapd.conf; then \
997                 %{__sed} -i -e " \
998                 /^include.*$(echo "$schema" | %{__sed} -e 's,/,\\\\/,g')/d \
999                 # for symmetry it would be nice if we disable enabled schemas in post, \
1000                 # but we really can not do that, it would break something else. \
1001                 " /etc/openldap/slapd.conf \
1002         fi \
1003 done \
1004 %{nil}
1005
1006 # vim:ts=4 sw=4 noet
This page took 0.15694 seconds and 4 git commands to generate.