]> git.pld-linux.org Git - packages/rpm.git/blob - rpm.macros
- PHP PDO API version macros
[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 %_source_payload        w9.gzdio
12 %_binary_payload        w9.bzdio
13
14 # Build system path macros.
15 #
16 %__autoconf             autoconf %{?debug:-Wall}
17 %__automake             automake -a -c -f --foreign
18 %__autopoint            autopoint --force
19
20 %__gettextize { \
21 if ! gettextize --version | grep -q '0\.10\.' ; then \
22         if grep -qs 'AM_GNU_GETTEXT.*external' configure.{ac,in} ; then \
23                 gettextize --copy --force --no-changelog; \
24         else \
25                 gettextize --copy --force --no-changelog --intl; \
26         fi; \
27         if [ ! -f po/Makevars ]; then \
28                 cp -f po/Makevars{.template,}; \
29         fi; \
30 else \
31         gettextize --copy --force; \
32 fi; \
33 }
34
35 %__glib_gettextize      glib-gettextize --copy --force
36 %__gnome_doc_common     gnome-doc-common --copy
37 %__gtkdocize            gtkdocize --copy
38 %__intltoolize          intltoolize --copy --force
39 %__libtoolize           libtoolize --copy --force
40
41 #       The number of cvs changelog entries kept when building package.
42 %_buildchangelogtruncate 20
43
44 %dependencytracking     %{nil}
45
46 #       Relations between package names that cause dependency loops
47 #       with legacy packages that cannot be fixed. Relations are
48 #       specified as
49 #               p>q
50 #       where package p has a Requires: on something that package q Provides:
51 #
52 # XXX   Note: that there cannot be any whitespace within the string "p>q",
53 #       and that both p and q are package names (i.e. no version/release).
54 %_dependency_whiteout   %{nil}
55
56 #-----------------------------------------------------------------
57 %configure2_13 { \
58  if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \
59  LDFLAGS="${LDFLAGS:-%rpmldflags}" ; export LDFLAGS ; \
60  CFLAGS="${CFLAGS:-%rpmcflags}" ; export CFLAGS ; \
61  CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" ; export CXXFLAGS ; \
62  FFLAGS="${FFLAGS:-%rpmcflags}" ; export FFLAGS ; \
63  CPPFLAGS="${CPPFLAGS:-}" ; export CPPFLAGS ; \
64  %{?__cc:CC="%{__cc}" ; export CC ; } \
65  %{?__cxx:CXX="%{__cxx}" ; export CXX ; } \
66  %{?configuredir:%{configuredir}}%{!?configuredir:.}/configure \
67         --host=%{_target_platform} \
68         --prefix=%{_prefix} \
69         --exec-prefix=%{_exec_prefix} \
70         --bindir=%{_bindir} \
71         --sbindir=%{_sbindir} \
72         --sysconfdir=%{_sysconfdir} \
73         --datadir=%{_datadir} \
74         --includedir=%{_includedir} \
75         --libdir=%{_libdir} \
76         --libexecdir=%{_libexecdir} \
77         --localstatedir=%{_localstatedir} \
78         --sharedstatedir=%{_sharedstatedir} \
79         --mandir=%{_mandir} \
80         --infodir=%{_infodir} \
81         --x-libraries=%{?_x_libraries}%{!?_x_libraries:%{_libdir}} \
82         %{dependencytracking} \
83 }
84
85 #----------------------------------------------------------------
86 %global configure_cache 0
87 %configure_cache_file   %{buildroot}.configure.cache
88
89 %configure {./configure \
90         LDFLAGS="${LDFLAGS:-%rpmldflags}" \
91         CFLAGS="${CFLAGS:-%rpmcflags}" \
92         CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" \
93         FFLAGS="${FFLAGS:-%rpmcflags}" \
94         CPPFLAGS="${CPPFLAGS:-}" \
95         %{?__cc:CC="%{__cc}"} \
96         %{?__cxx:CXX="%{__cxx}"} \
97         --host=%{_target_platform} \
98         --build=%{_target_platform} \
99         --prefix=%{_prefix} \
100         --exec-prefix=%{_exec_prefix} \
101         --bindir=%{_bindir} \
102         --sbindir=%{_sbindir} \
103         --sysconfdir=%{_sysconfdir} \
104         --datadir=%{_datadir} \
105         --includedir=%{_includedir} \
106         --libdir=%{_libdir} \
107         --libexecdir=%{_libexecdir} \
108         --localstatedir=%{_localstatedir} \
109         --sharedstatedir=%{_sharedstatedir} \
110         --mandir=%{_mandir} \
111         --infodir=%{_infodir} \
112         --x-libraries=%{?_x_libraries}%{!?_x_libraries:%{_libdir}} \
113         %{dependencytracking} \
114         %{?configure_cache:--cache-file=%{configure_cache_file:-%{buildroot}.configure.cache}} \
115 }
116
117 # ------------------------------------------------------------------------
118 # Overloading of some basic macros
119 %prep \
120 %%prep\
121 LANG=C\
122 export LANG\
123 unset DISPLAY ||:\
124 unset LINGUAS ||:\
125 %{nil}
126
127 %build %%build\
128 LANG=C\
129 export LANG\
130 unset DISPLAY ||:\
131 unset LINGUAS ||:\
132 %{nil}
133
134 %install \
135 %if 0%{?_enable_debug_packages}\
136 %{?buildsubdir:%{debug_package}}\
137 %endif\
138 %%install\
139 LANG=C\
140 export LANG\
141 unset DISPLAY ||:\
142 unset LINGUAS ||:\
143 %{nil}
144
145 # Location of autoconf macros
146 %_aclocaldir    %(aclocal --print-ac-dir)
147
148 # Location of omf files
149 %_omf_dest_dir  %(scrollkeeper-config --omfdir)
150
151 # Location of pkgconfig files
152 %_pkgconfigdir  /usr/%{_lib}/pkgconfig
153
154 # Location of desktop files
155 %_desktopdir    /usr/share/applications
156 %_applnkdir     ERROR:_applnkdir_is_obsolete_use_desktopdir_instead
157
158 # Location of pixmaps for applnk/desktop files
159 %_pixmapsdir    /usr/share/pixmaps
160
161 # Location of themable icons for applnk/desktop files
162 %_iconsdir      /usr/share/icons
163
164 # Location of fonts directories
165 %_fontsdir      /usr/share/fonts
166
167 # Location of Gtk and associated libraries documentation
168 %_gtkdocdir  %{_defaultdocdir}/gtk-doc/html
169
170 # Location of KDE documentation
171 %_kdedocdir  %{_defaultdocdir}/kde/HTML
172
173 # unsermake script
174 %__unsermake /usr/share/unsermake/unsermake
175
176 # Current date
177 %date           %(LC_ALL="C" date +"%a %b %d %Y")
178
179 # tmp directory
180 %tmpdir         %(echo "${TMPDIR:-/tmp}")
181
182 # Example files, programs, scripts...
183 %_examplesdir   /usr/src/examples
184
185 # Alternative kernel type/version
186 %alt_kernel     %{nil}%{?_alt_kernel:-%{?_alt_kernel}}
187
188 # The directory holding Linux kernel sources
189 %_kernelsrcdir  /usr/src/linux%{alt_kernel}
190
191 # If non-empty "debug" macro defined, add "dbg" suffix to release number
192 %_rpmfilename           %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
193
194 # Requires name = version-release
195 %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")
196
197 %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)")
198 %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)")
199 %requires_releq_kernel_up(s:)   Requires%{-s:(%{-s*})}: %releq_kernel_up
200 %requires_releq_kernel_smp(s:)  Requires%{-s:(%{-s*})}: %releq_kernel_smp
201
202 %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")
203 %requires_eq_to() %(LC_ALL="C" rpm -q --qf 'Requires: %1 = %%{epoch}:%%{version}\\n' %2 | sed -e 's/ (none):/ /' | grep -v "is not")
204
205 %apache_modules_api %(awk '/#define MODULE_MAGIC_NUMBER_MAJOR/ {print $3}' /usr/include/apache/ap_mmn.h 2>/dev/null || echo ERROR)
206
207 # kernel version-release handling
208 %__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))
209 %__kernel_rel   %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{RELEASE}" | grep -v "is not")
210 %__kernel_rpmvr  %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{VERSION}-%{RELEASE}" | grep -v "is not")
211 %_kernel_ver    %{__kernel_ver}%{?with_dist_kernel:%(echo %{__kernel_ver} | grep -q -e - || echo -%{__kernel_rel})}
212 %_kernel_ver_str %(echo %{!?_without_dist_kernel:%{__kernel_rpmvr}}%{?_without_dist_kernel:%{__kernel_ver}} | sed -e 's/-/_/g')
213
214 # sgml macros
215 %xmlcat_add()           /usr/bin/xmlcatalog --noout --add nextCatalog \"\" %1 /etc/xml/catalog ;
216 %xmlcat_del()           /usr/bin/xmlcatalog --noout --del %1 /etc/xml/catalog ;
217 %xmlcat_add_rewrite     /usr/bin/xmlcatalog --noout --add rewriteSystem
218 %xmlcat_create()        /usr/bin/xmlcatalog --noout --create %1 ;
219 %sgmlcat_add()          /usr/bin/install-catalog --add %1 %2 > /dev/null ;
220 %sgmlcat_del()          /usr/bin/install-catalog --remove %1 %2 > /dev/null ;
221 %docbook_sgmlcat_fix() { for l in \
222 '' \
223 '  -- default decl --' \
224 'DTDDECL "-//OASIS//DTD DocBook XML V%2//EN" "../../xml.dcl"' \
225 '  -- hacks for opensp --' \
226 'SYSTEM "file://%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
227 'SYSTEM "http://www.oasis-open.org/docbook/xml/%2/docbookx.dtd"                  "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
228 '' \
229 ; do echo $l; done >> %1 \
230 }
231
232 #-----------------------------------------------------------------
233 # find and gzip all files in %{_mandir} and %{infodir}
234 #
235 # Requires: xargs, find
236 #
237 #%no_install_post_compress_docs 1
238 %__spec_install_post_compress_docs { \
239 %{!?no_install_post_compress_docs:__spec_install_post_compress_docs() { \
240         echo "Compress man and info pages."; \
241         for i in /usr/share/man /usr/X11R6/man /usr/share/info; do \
242                 if [ -d "$RPM_BUILD_ROOT$i" ]; then \
243                         find "$RPM_BUILD_ROOT$i" -name \*.bz2 -print | xargs -r %{__bzip2} -df; \
244                         find "$RPM_BUILD_ROOT$i" -name \*.gz -print | xargs -r %{__gzip} -dnf; \
245                         find "$RPM_BUILD_ROOT$i" -type f -print | xargs -r %{__gzip} -9nf; \
246                 fi; \
247         done; \
248 }; __spec_install_post_compress_docs } }
249
250 #-----------------------------------------------------------------
251 # Strip executable binaries and shared object files
252 #
253 # Requires: find, awk, strip, cut, xargs
254 #
255 #%no_install_post_strip 1
256 %__spec_install_post_strip {%{!?debug: \
257 %{!?no_install_post_strip:__spec_install_post_strip() { \
258         if [ -d "$RPM_BUILD_ROOT" ]; then \
259         echo "Strip executable binaries, archives and shared object files."; \
260         filelist=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" ! -regex ".*/usr/lib[0-9]*/debug/.*\.debug" %{?_noautostrip:! -regex "%{_noautostrip}"}`; \
261         elfexelist=`echo $filelist | xargs -r file | \
262                 awk '/ELF.*executable/ {print $1}' | cut -d: -f1`; \
263         elfsharedlist=`echo $filelist | xargs -r file | \
264                 awk '/LF.*shared object/ {print $1}' | cut -d: -f1`; \
265         elfarchiveslist=`echo $filelist | xargs -r file | \
266                 awk '/current ar archive/ {print $1}' | cut -d: -f1`; \
267         if [ -n "$elfexelist" ]; then \
268                 %{__strip} --remove-section=.note  --remove-section=.comment $elfexelist; \
269         fi; \
270         if [ -n "$elfsharedlist" ]; then \
271                 %{__strip} --strip-unneeded --remove-section=.note  --remove-section=.comment $elfsharedlist; \
272         fi; \
273         if [ -n "$elfarchiveslist" ]; then \
274                 %{__strip} --strip-debug --remove-section=.note  --remove-section=.comment $elfarchiveslist; \
275         fi; \
276 fi; }; __spec_install_post_strip } } }
277
278 #-----------------------------------------------------------------
279 # remove all RPATH from executable binaries and shared object files
280 #
281 # Requires: find, awk, cut, xargs, chrpath, uname
282 #
283 #%no_install_post_chrpath       1
284 %__spec_install_post_chrpath {%{!?debug: \
285 %{!?no_install_post_chrpath: __spec_install_post_chrpath() { \
286 if [ -d "$RPM_BUILD_ROOT" ]; then \
287 echo "Remove RPATH from executable binaries and shared object files."; \
288 find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" ! -regex ".*/usr/lib[0-9]*/debug/.*" %{?_noautochrpath:! -regex "%{_noautochrpath}"} | xargs -r file | \
289         awk '/ELF.*(executable.*dynamically linked|shared object)/ {print $1}' | cut -d: -f1 | \
290 while read file ; do \
291         rpath= ; \
292         chmod u+w "$file"; \
293         for dir in `chrpath -l "$file" | \
294                         awk '/RPATH=/ { gsub(/.*RPATH=/,""); gsub(/:/," "); print $0 }'` ; do \
295                         case $dir in \
296                         /home/* | /tmp/* | /usr/lib | /usr/lib64 | /lib | /lib64 | /usr/local/lib | /usr/local/lib64 | /usr/X11R6/lib | /usr/X11R6/lib64 ) \
297                                 echo "remove-rpath: $dir in $file"; \
298                                 ;; \
299                         * ) \
300                                 if [ "$rpath" = "" ] ; then rpath="$dir" ; \
301                                 else rpath="$rpath:$dir" ; fi ; \
302                                 ;; \
303                         esac ; \
304         done ; \
305         if [ "$rpath" = "" ] ; then chrpath -d "$file" > /dev/null ; \
306         else chrpath -r "$rpath" "$file" > /dev/null ; fi ; \
307 done; \
308 fi; }; __spec_install_post_chrpath } } }
309
310 #-----------------------------------------------------------------
311 # Find and gzip all kernel modules
312 #
313 # Requires: find
314 #
315 #%no_install_post_compress_modules  1
316 %__spec_install_post_compress_modules { \
317 %{!?no_install_post_compress_modules: __spec_install_post_compress_modules() { \
318         if [ -d "$RPM_BUILD_ROOT" ]; then \
319                 echo "Compress kernel modules if any."; \
320                 if test -d $RPM_BUILD_ROOT/lib/modules ; then \
321                         find $RPM_BUILD_ROOT/lib/modules -name \*o -type f -print | \
322                         xargs -r %{__gzip} -9nf; \
323                            find $RPM_BUILD_ROOT/lib/modules -name \*o -type l -printf "%p %l\n" | \
324                            while read a b; do ln -sf $b.gz $a.gz; rm -f $a; done; \
325                 fi; \
326         fi; \
327 }; __spec_install_post_compress_modules } }
328
329 # Remove common Perl files we don't package
330 %__spec_install_post_perl_clean {\
331 %{!?no_install_post_perl_clean: \
332 %{?pdir:rm -f $RPM_BUILD_ROOT{%{perl_archlib}/perllocal.pod,%{perl_vendorarch}/auto/%{pdir}%{?pnam:/%(echo %{pnam} | tr - /)}/.packlist}} \
333 } }
334
335 #-----------------------------------------------------------------
336 # Update GConf2 schemas
337 #
338 # Requires: GConf2
339 #
340 %gconf_schema_install() \
341         umask 022; \
342         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 \
343         %{nil}
344
345 %gconf_schema_uninstall() \
346 if [ $1 = 0 ]; then \
347         umask 022; \
348         GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" /usr/bin/gconftool-2 --makefile-uninstall-rule /etc/gconf/schemas/%{?1} > /dev/null \
349 fi \
350 %{nil}
351
352 #-----------------------------------------------------------------
353 # Update desktop MIME database
354 # requires: desktop-file-utils
355 #
356 %update_desktop_database_post() {{ \
357         umask 022; \
358         /usr/bin/update-desktop-database; \
359 }}
360
361 %update_desktop_database_postun() {{ \
362 if [ $1 = 0 ]; then \
363         umask 022; \
364         /usr/bin/update-desktop-database; \
365 fi \
366 }}
367
368 #-----------------------------------------------------------------
369 # Update scrollkeeper database
370 # requires: scrollkeeper
371 #
372 %scrollkeeper_update_post() \
373         /usr/bin/scrollkeeper-update -q; \
374         %{nil}
375
376 %scrollkeeper_update_postun() \
377 if [ $1 = 0 ]; then \
378         /usr/bin/scrollkeeper-update -q; \
379 fi \
380 %{nil}
381
382 #-----------------------------------------------------------------
383 # Run ldconfig after installing/deinstalling libraries
384 #
385 %ldconfig_post() \
386         /sbin/ldconfig; \
387         %{nil}
388
389 %ldconfig_postun() \
390         /sbin/ldconfig; \
391         %{nil}
392
393 #-----------------------------------------------------------------
394 # post %install sequence:
395 # - autodeps exceptions
396 # - compress all man and info pages,
397 # - strip all ELF executables and ELF shared objects if not %debug.
398 # - compress kernel modules if any
399
400 ###################################################################
401 # Requires/Provides automation
402 # exceptions system by Jacek Konieczny <jajcus@pld.org.pl>
403 #
404 %__noautoreqfiles       %(sed -e s'/#.*//' /etc/rpm/noautoreqfiles)%{?_noautoreqfiles: %{_noautoreqfiles}}
405 %__noautoprovfiles      %(sed -e s'/#.*//' /etc/rpm/noautoprovfiles)%{?_noautoprovfiles: %{_noautoprovfiles}}
406 %__noautoreq            %(sed -e s'/#.*//' /etc/rpm/noautoreq)%{?_noautoreq: %{_noautoreq}}
407 %__noautoreqdep         %(sed -e s'/#.*//' /etc/rpm/noautoreqdep)%{?_noautoreqdep: %{_noautoreqdep}}
408 %__noautoprov           %(sed -e s'/#.*//' /etc/rpm/noautoprov)%{?_noautoprov: %{_noautoprov}}
409 #%_noautocompressdoc    %{nil}
410 #
411 %_missing_doc_files_terminate_build     1%{nil}
412 %_unpackaged_files_terminate_build      %{nil}
413 # (X)emacs support
414 %___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;}'
415 %_emacs_lispdir %(emacs %___emacs_lispdir_helper)
416 %_xemacs_lispdir %(xemacs %___emacs_lispdir_helper)
417
418 %__php_provides %{nil}
419 %__php_requires %{nil}
420 %__perl_provides %{nil}
421 %__perl_requires %{nil}
422 %__mono_provides %{nil}
423 %__mono_requires %{nil}
424
425 # Perl specific macro definitions.
426 %perl_privlib           %(eval "`%{__perl} -V:installprivlib`"; echo $installprivlib)
427 %perl_archlib           %(eval "`%{__perl} -V:installarchlib`"; echo $installarchlib)
428 %perl_vendorlib         %(eval "`%{__perl} -V:installvendorlib`"; echo $installvendorlib)
429 %perl_vendorarch        %(eval "`%{__perl} -V:installvendorarch`"; echo $installvendorarch)
430 %perl_sitelib           %(eval "`%{__perl} -V:installsitelib`"; echo $installsitelib)
431 %perl_sitearch          %(eval "`%{__perl} -V:installsitearch`"; echo $installsitearch)
432
433 # Ruby
434 %ruby_archdir           %(ruby -r rbconfig -e 'print Config::CONFIG["archdir"]' 2>/dev/null || echo ERROR)
435 %ruby_ridir             %(ruby -r rbconfig -e 'include Config; print File.join(CONFIG["datadir"], "ri", CONFIG["ruby_version"], "system")' 2>/dev/null || echo ERROR)
436 %ruby_rubylibdir        %(ruby -r rbconfig -e 'print Config::CONFIG["rubylibdir"]' 2>/dev/null || echo ERROR)
437 %ruby_sitearchdir       %(ruby -r rbconfig -e 'print Config::CONFIG["sitearchdir"]' 2>/dev/null || echo ERROR)
438 %ruby_sitelibdir        %(ruby -r rbconfig -e 'print Config::CONFIG["sitelibdir"]' 2>/dev/null || echo ERROR)
439 %ruby_version           %(ruby -r rbconfig -e 'print Config::CONFIG["ruby_version"]' 2>/dev/null || echo ERROR)
440 %ruby_ver_requires_eq   Requires:       ruby(ver) = %ruby_version
441 %ruby_mod_ver_requires_eq       Requires:       ruby-modules(ver) = %ruby_version
442
443 %php_pear_dir   %{_datadir}/pear
444
445 # directory where php includes are installed on system.
446 %__php_includedir               /usr/include/php
447 # extract php/zend api versions
448 %php_major_version              %(awk '/#define PHP_MAJOR_VERSION/{print $3}' %{__php_includedir}/main/php_version.h 2>/dev/null || echo ERROR)
449 %php_api_version                %(awk '/#define PHP_API_VERSION/{print $3}' %{__php_includedir}/main/php.h 2>/dev/null || echo ERROR)
450 %php_pdo_api_version    %(awk '/#define PDO_DRIVER_API/{print $3}' %{__php_includedir}/ext/pdo/php_pdo_driver.h 2>/dev/null || echo ERROR)
451 %php_debug                              %(awk '/#define ZEND_DEBUG/{print $3}' %{__php_includedir}/main/php_config.h 2>/dev/null || echo ERROR)
452 %zend_module_api                %(awk '/#define ZEND_MODULE_API_NO/{print $3}' %{__php_includedir}/Zend/zend_modules.h 2>/dev/null || echo ERROR)
453 %zend_extension_api             %(awk '/#define ZEND_EXTENSION_API_NO/{print $3}' %{__php_includedir}/Zend/zend_extensions.h 2>/dev/null || echo ERROR)
454 %zend_zts                               %(Z=$(grep -sc '^#define ZTS 1' %{__php_includedir}/main/php_config.h); echo ${Z:-ERROR})
455
456 # helper macro
457 %__php_api_requires(v:) Requires: php%{-v*}(%{expand:%1}) = %{expand:%{%{!?2:%{1}}%{?2}}}
458
459 # macros for public use
460 # for php extensions (php-pecl)
461 %requires_php_extension %{__php_api_requires modules_api php_api_version} \
462 %{__php_api_requires -v %php_major_version debug php_debug} \
463 %{__php_api_requires -v %php_major_version thread-safety zend_zts}
464
465 # for zend extensions
466 %requires_zend_extension %{__php_api_requires zend_module_api} \
467 %{__php_api_requires zend_extension_api} \
468 %{__php_api_requires -v %php_major_version debug php_debug} \
469 %{__php_api_requires -v %php_major_version thread-safety zend_zts}
470
471 # for php pdo modules (php-pecl-PDO_*)
472 %requires_php_pdo_module %{__php_api_requires PDO_API php_pdo_api_version}
473
474 # Python specific macro definitions.
475 # python main version
476 %py_ver         %(python -c "import sys; print sys.version[:3]")
477
478 # directories
479 %py_prefix              %(python -c "import sys; print sys.prefix")
480 %py_libdir              %{py_prefix}/%{_lib}/python%{py_ver}
481 %py_scriptdir   %{py_prefix}/share/python%{py_ver}
482 %py_incdir              /usr/include/python%{py_ver}
483 %py_sitedir     %{py_libdir}/site-packages
484 %py_sitescriptdir %{py_scriptdir}/site-packages
485 %py_dyndir              %{py_libdir}/lib-dynload
486
487 # pure python modules compilation
488 %py_comp                python -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
489
490 %py_ocomp               python -O -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
491
492 # Software written in Python language require Python with main version
493 %pyrequires_eq() Requires:      %1
494
495 # Hardlink binary identical .pyc and .pyo files
496 # (idea by glen <at> pld-linux <dot> org)
497 %__spec_install_post_py_hardlink {\
498 %{!?no_install_post_py_hardlink: __spec_install_post_py_hardlink() { \
499 [ ! -d "$RPM_BUILD_ROOT" ] || find "$RPM_BUILD_ROOT" -name '*.pyc' | while read a; do \
500         b="$(echo $a|sed -e 's/.pyc$/.pyo/')"; \
501         if cmp -s "$a" "$b"; then \
502                 ln -f "$a" "$b"; \
503         fi; \
504 done \
505 }; __spec_install_post_py_hardlink } }
506
507 # remove python sources, so that check-files won't complain
508 # (idea by glen <at> pld-linux <dot> org)
509 %py_postclean() \
510 for d in %{py_sitescriptdir} %{py_sitedir} %*; do \
511  [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -print0 | xargs -0r -l512 rm;\
512 done \
513 %{nil}
514
515 # depmod macro
516 %depmod() { \
517 umask 022; \
518 if [ -e /boot/System.map-%1 ]; then \
519         /sbin/depmod -a -F /boot/System.map-%1 %1; \
520 else \
521         if [ -e /boot/System.map ]; then \
522                 /sbin/depmod -a -F /boot/System.map %1; \
523         else \
524                 /sbin/depmod -a %1; \
525         fi \
526 fi; \
527 }
528
529 # XMMS specific macros
530 %xmms_prefix                    %(xmms-config --prefix 2>/dev/null)
531 %xmms_exec_prefix               %(xmms-config --exec-prefix 2>/dev/null)
532 %xmms_version                   %(xmms-config --version 2>/dev/null)
533 %xmms_datadir                   %(xmms-config --data-dir 2>/dev/null)
534 %xmms_plugindir                 %(xmms-config --plugin-dir 2>/dev/null)
535 %xmms_visualization_plugindir   %(xmms-config --visualization-plugin-dir 2>/dev/null)
536 %xmms_input_plugindir           %(xmms-config --input-plugin-dir 2>/dev/null)
537 %xmms_output_plugindir          %(xmms-config --output-plugin-dir 2>/dev/null)
538 %xmms_effect_plugindir          %(xmms-config --effect-plugin-dir 2>/dev/null)
539 %xmms_general_plugindir         %(xmms-config --general-plugin-dir 2>/dev/null)
540
541 %_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/')
542
543 # user/group checking macros
544 #
545 # Usage:
546 #       %userremove myuser
547 #
548 %userremove     /usr/lib/rpm/user_group.sh user del
549 %groupremove    /usr/lib/rpm/user_group.sh group del
550 #
551 # Usage:
552 #       if %usertestrm myuser; then
553 #               /usr/sbin/userdel -r myuser
554 # Note:
555 #       use these macros only if you need to call userdel/groupdel with
556 #       a non-standard option or take an extra action; otherwise use the
557 #       %userremove/%groupremove macros
558 #
559 %usertestrm     /usr/lib/rpm/user_group.sh user testrm
560 %grouptestrm    /usr/lib/rpm/user_group.sh group testrm
561 # user group membership management macros
562 #
563 # Usage:
564 #       %addusertogroup myuser agroup
565 #
566 %addusertogroup /usr/lib/rpm/user_group.sh user addtogroup
567
568 # banner support (useful in {pre,post}{,un} and triggers)
569 #
570 # Usage:
571 #       %banner name [-a] [-e] [-n] [-tn] <<EOF
572 # the banner text, the banner text
573 # the banner text, and following line
574 #EOF
575 # You can use any form of here-document, <<'EOF' <<-EOT will do.
576 # NOTE: if your use "<<-EOF", then You can actually indent inside here-document.
577 #
578 # -a   - append to the banner
579 # -e   - send to stderr instead of stdout
580 # -n   - no show banner (overrides -t)
581 # -t   - show only, if RPM_SCRIPTVERBOSITY >= n; default n=5
582 %banner(aent:)  \
583 RPM_SCRIPTVERBOSITY=5 \
584 [ -r /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm \
585 if [ -x /usr/bin/banner.sh ]; then \
586         CMD="/usr/bin/banner.sh %{-e:--stderr} %{!-n:$([ $RPM_SCRIPTVERBOSITY -ge %{-t:%{-t*}}%{!-t:5} ] && echo -s)} %{!-a:-m}%{-a:-M} %1" \
587 else \
588         CMD="cat%{-e: >&2}" \
589 fi \
590 eval $CMD %2%{?3: %3} \
591 %nil
592
593 # useradd/groupadd macros written by glen@pld-linux.org.
594 # All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
595 #
596 # Usage:
597 #   %useradd [-P package] [-u uid] [-d home_dir] [-s shell] [-c comment]
598 #   [-g initial_group] [-G group[,...]] login
599 #
600 #  -u uid. REQUIRED
601 #  -g gid/group. REQUIRED
602 #  -s defaults to /bin/false
603 #  -d defaults to /usr/share/empty
604 #  -c No default
605 #  -r is accepted but ignored (it's always set)
606 #  -k skeleton dir. defaults to /usr/share/empty
607 # rpm specific flags
608 #  -P package name. defaults to %{name}
609 #
610 %useradd(c:d:e:f:g:G:Mmk:op:s:u:rP:) \
611 %{!-u:%{error:useradd: Required argument -u missing}} \
612 %{!-g:%{error:useradd: Required argument -g missing}} \
613 %{!?1:%{error:useradd: Required parameter login missing}} \
614 if [ -n "`/bin/id -u %{expand:%{%{#}}} 2>/dev/null`" ]; then \
615         if [ "`/bin/id -u %{expand:%{%{#}}}`" != "%{-u*}" ]; then \
616                 echo "Error: user %{expand:%{%{#}}} doesn't have uid=%{-u*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
617                 exit 1 \
618         fi \
619 else \
620         echo "Adding user %{expand:%{%{#}}} UID=%{-u*}." \
621         /usr/sbin/useradd \\\
622                 %{-m:-m -k %{-k*}%{!-k:/usr/share/empty}} \\\
623                 -u %{-u*} \\\
624                 -r \\\
625                 -d %{-d*}%{!-d:/usr/share/empty} \\\
626                 -s %{-s*}%{!-s:/bin/false} \\\
627                 %{-c:-c "%(set -- %{-c*} %{*}; echo $1)"}\\\
628                 -g %{-g*} \\\
629                 %{-M} \\\
630                 %{-G:-G %{-G*}} \\\
631                 %{expand:%{%{#}}} 1>&2 || exit $? \
632         [ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i passwd \
633 fi;
634
635 # Usage:
636 #   %groupadd [-P package] [-g gid] group
637 #
638 # -g gid. REQUIRED
639 #
640 # Sample:
641 #   %groupadd -P %{name}-base -g %{gid} %{name}
642
643 %groupadd(g:P:rfo)      \
644 %{!-g:%{error:groupadd: Required argument -g missing}} \
645 %{!?1:%{error:groupadd: Required parameter group missing}} \
646 if [ -n "`/usr/bin/getgid %{1}`" ]; then \
647         if [ "`/usr/bin/getgid %{1}`" != "%{-g*}" ]; then \
648                 echo "Error: group %{1} doesn't have gid=%{-g*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
649                 exit 1 \
650         fi \
651 else \
652         echo "Adding group %{1} GID=%{-g*}." \
653         /usr/sbin/groupadd -g %{-g*} -r %{1} 1>&2 || exit $? \
654         [ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i group \
655 fi;
656
657 # apache_config_{install/uninstall} macros written by glen@pld-linux.org.
658 # All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
659 #
660 # You should use webapp macros instead. these are here until single piece of them is gone from specs ;)
661 #
662 # The config is installed/removed inside trigger, this means that you can any
663 # time install apache1 or apache package and the configuration file is updated.
664 # if you don't need the config for various reason for specific apache, just
665 # remove the symlink from apache config directory. the trigger will not put the
666 # config again to that version of apache. In other words the config is linked
667 # to apache config directory on first install of PACKAGE or apache.
668 #
669 # should be called in trigger body:
670 #  %triggerin -- apache1 >= 1.3.33-2
671 #  %apache_config_install -v 1
672 #
673 # Add package's apache config to apache config.
674 #
675 # Usage:
676 #   %apache_config_install -v {1|2} -c %{_sysconfdir}/apache-%{name}.conf -n 99
677 #
678 #  -v REQUIRED: specify apache version. can be 1 or 2.
679 #  -c OPTIONAL: specify full path to PACKAGE's config. Defaults to %{_sysconfdir}/apache-%{name}.conf.
680 #  -n OPTIONAL: specify config "slot". defaults to 99
681 #  -f OPTIONAL: force symlink creation regardless if package was upraded. useful in triggers
682 #
683 # Internal macros. don't use ;).
684 # expands apache config dir by apache version at build time.
685 %__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)
686 # expands apache service name by apache version at build time.
687 %__apache_svcname() %(if [ %{1} = 1 ]; then echo apache; elif [ %{1} = 2 ]; then echo httpd; else echo >&2 Unknown apache version specified; fi)
688
689 %apache_config_install(fv:c:n:) \
690 %{!-v:%{error:apache_config_install: Required argument -v missing}} \
691 %{?debug:set -x; echo "apache_config_install:%{-v*} %{name}-%{version}-%{release} 1:[$1]; 2:[$2]"} \
692 if [ -n "%{-f:1}" ] || ([ "$1" = "1" ] && [ "$2" = "1" ]) && [ -d %{__apache_confdir %{-v*}} ]; then\
693         ln -sf %{-c*}%{!-c:%{_sysconfdir}/apache-%{name}.conf} %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf\
694 fi\
695 # reload apache if the config symlink is there\
696 if [ -L %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf ]; then\
697         # additionally don't reload if target package (the webserver) is upgraded, as webserver is restarted anyway in %post \
698         if [ "$2" != "2" ] && [ -f /var/lock/subsys/%{__apache_svcname %{-v*}} ]; then\
699                 /etc/rc.d/init.d/%{__apache_svcname %{-v*}} reload 1>&2\
700         fi\
701 fi\
702 %{nil}
703
704 # Remove package's apache config from apache config.
705 #
706 # Usage:
707 #   %apache_config_uninstall -v {1|2} -n 99
708 #
709 #  -v REQUIRED: specify apache version. can be 1 or 2.
710 #  -n OPTIONAL: specify config "slot". defaults to 99
711 %apache_config_uninstall(v:n:) \
712 %{!-v:%{error:apache_config_uninstall: Required argument -v missing}} \
713 %{?debug:set -x; echo "apache_config_uninstall:%{-v*} %{name}-%{version}-%{release}: 1:[$1]; 2:[$2]"} \
714 # remove link if either of the packages are gone \
715 if [ "$1" = "0" ] || [ "$2" = "0" ]; then \
716         if [ -L %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf ]; then \
717                 rm -f %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf \
718                 if [ -f /var/lock/subsys/%{__apache_svcname %{-v*}} ]; then \
719                         /etc/rc.d/init.d/%{__apache_svcname %{-v*}} reload 1>&2 \
720                 fi \
721         fi \
722 fi \
723 %{nil}
724
725 # webapp macros
726 #
727 # The config is installed/removed inside trigger, this means that you can any
728 # time install apache1/apache/lighttpd package and the configuration file is
729 # updated.  if you don't need the config for various reason for specific
730 # webserver, just remove the symlink from config directory using webapp
731 # program. the trigger will not recreate the symlink on upgrades. In other
732 # words the config is linked to webserver config directory on first install of
733 # PACKAGE or WEBSERVER.
734 #
735 # Add package's webserver config to webserver webapps dir.
736 # Usage:
737 #   %webapp_register WEBSERVER WEBAPP
738 #
739 %webapp_register() \
740 %{?debug:set -x; echo "webapp_register: %{name}-%{version}-%{release} 1:[$1]; 2:[$2]"} \
741 if [ "$1" = "1" ] && [ "$2" = "1" ]; then\
742         /usr/sbin/webapp register %1 %2\
743 fi\
744 # reload webserver if the config symlink is there and skip reload if webserver is upgraded\
745 if [ -L /etc/%1/webapps.d/%2.conf ] && [ "$2" -lt "2" ]; then\
746         %{expand:%service -q %%1 reload}\
747 fi\
748 %{nil}
749
750 # Remove package's config from webserver webapps dir.
751 # Usage:
752 #   %webapp_register [-f] WEBSERVER WEBAPP
753 %webapp_unregister(f) \
754 %{?debug:set -x; echo "webapp_unregister: %{name}-%{version}-%{release}: 1:[$1]; 2:[$2]"} \
755 # remove link if either of the packages are gone \
756 if [ -n "%{-f:1}" ] || [ "$1" = "0" ] || [ "$2" = "0" ] && [ -L /etc/%1/webapps.d/%2.conf ]; then \
757         /usr/sbin/webapp unregister %1 %2\
758         %{expand:%service -q %%1 reload}\
759 fi \
760 %{nil}
761
762 # see browser-plugins.spec / template-browser-plugin.spec
763 # written by glen@pld-linux.org.
764 %nsplugin_install(d:f) { \
765 # create link if it's first install of either of the packages \
766 if [ -n "%{-f:1}" ] || ([ "$1" = "1" ] && [ "$2" = "1" ] && [ -d %{-d*} ]); then \
767 ( \
768 %( \
769         for file in %{*}; do \
770                 echo echo Installing $file to %{-d*}; \
771                 echo "ln -sf %{_libdir}/browser-plugins/$file %{-d*};"; \
772         done ) \
773 ) | ( %banner -t 5 -e %{name}-in ); fi; \
774 }
775
776 %nsplugin_uninstall(d:) { \
777 # remove link if either of the packages are gone \
778 if [ "$1" = "0" ] || [ "$2" = "0" ]; then \
779 ( \
780 %( \
781         for file in %{*}; do \
782                 echo echo Removing $file from %{-d*}; \
783                 echo "rm -f %{-d*}/$file;"; \
784         done ) \
785 ) | ( %banner -t 5 -e %{name}-un ); fi; \
786 }
787
788 # service macro.
789 #
790 # calls usual service restart on package %post, but skips the restart if
791 # administrator has disabled automatic service restarts in either global
792 # /etc/sysconfig/rpm or per service /etc/sysconfig/SERVICE file.
793 #
794 # written by glen@pld-linux.org.
795 # All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
796 #
797 # Usage:
798 #   %service [-q] SERVICE ACTION ["SERVICE NICE DESCRIPTION"]
799 #
800 #  -q be silent when service isn't started (for scriplets restaring other package's services)
801 #
802 %service(q) {{%(export quiet=%{-q:1}; /usr/lib/rpm/service_generator.sh %{*}) };}
This page took 0.078565 seconds and 4 git commands to generate.