]> git.pld-linux.org Git - packages/rpm-build-macros.git/blob - rpm.macros
- 1.286 (kernel macro fixes)
[packages/rpm-build-macros.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 %dependencytracking     %{nil}
42
43 #       Relations between package names that cause dependency loops
44 #       with legacy packages that cannot be fixed. Relations are
45 #       specified as
46 #               p>q
47 #       where package p has a Requires: on something that package q Provides:
48 #
49 # XXX   Note: that there cannot be any whitespace within the string "p>q",
50 #       and that both p and q are package names (i.e. no version/release).
51 %_dependency_whiteout   %{nil}
52
53 #-----------------------------------------------------------------
54 %configure2_13 { \
55  if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \
56  LDFLAGS="${LDFLAGS:-%rpmldflags}" ; export LDFLAGS ; \
57  CFLAGS="${CFLAGS:-%rpmcflags}" ; export CFLAGS ; \
58  CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" ; export CXXFLAGS ; \
59  FFLAGS="${FFLAGS:-%rpmcflags}" ; export FFLAGS ; \
60  CPPFLAGS="${CPPFLAGS:-}" ; export CPPFLAGS ; \
61  %{?__cc:CC="%{__cc}" ; export CC ; } \
62  %{?__cxx:CXX="%{__cxx}" ; export CXX ; } \
63  %{?configuredir:%{configuredir}}%{!?configuredir:.}/configure \
64         --host=%{_target_platform} \
65         --prefix=%{_prefix} \
66         --exec-prefix=%{_exec_prefix} \
67         --bindir=%{_bindir} \
68         --sbindir=%{_sbindir} \
69         --sysconfdir=%{_sysconfdir} \
70         --datadir=%{_datadir} \
71         --includedir=%{_includedir} \
72         --libdir=%{_libdir} \
73         --libexecdir=%{_libexecdir} \
74         --localstatedir=%{_localstatedir} \
75         --sharedstatedir=%{_sharedstatedir} \
76         --mandir=%{_mandir} \
77         --infodir=%{_infodir} \
78         --x-libraries=%{?_x_libraries}%{!?_x_libraries:%{_libdir}} \
79         %{dependencytracking} \
80 }
81
82 #----------------------------------------------------------------
83 %global configure_cache 0
84 %configure_cache_file   %{buildroot}.configure.cache
85
86 %configure {./configure \
87         LDFLAGS="${LDFLAGS:-%rpmldflags}" \
88         CFLAGS="${CFLAGS:-%rpmcflags}" \
89         CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" \
90         FFLAGS="${FFLAGS:-%rpmcflags}" \
91         CPPFLAGS="${CPPFLAGS:-}" \
92         %{?__cc:CC="%{__cc}"} \
93         %{?__cxx:CXX="%{__cxx}"} \
94         --host=%{_target_platform} \
95         --build=%{_target_platform} \
96         --prefix=%{_prefix} \
97         --exec-prefix=%{_exec_prefix} \
98         --bindir=%{_bindir} \
99         --sbindir=%{_sbindir} \
100         --sysconfdir=%{_sysconfdir} \
101         --datadir=%{_datadir} \
102         --includedir=%{_includedir} \
103         --libdir=%{_libdir} \
104         --libexecdir=%{_libexecdir} \
105         --localstatedir=%{_localstatedir} \
106         --sharedstatedir=%{_sharedstatedir} \
107         --mandir=%{_mandir} \
108         --infodir=%{_infodir} \
109         --x-libraries=%{?_x_libraries}%{!?_x_libraries:%{_libdir}} \
110         %{dependencytracking} \
111         %{?configure_cache:--cache-file=%{configure_cache_file:-%{buildroot}.configure.cache}} \
112 }
113
114 # ------------------------------------------------------------------------
115 # Overloading of some basic macros
116 %prep \
117 %%prep\
118 LANG=C\
119 export LANG\
120 unset DISPLAY ||:\
121 unset LINGUAS ||:\
122 %{nil}
123
124 %build %%build\
125 LANG=C\
126 export LANG\
127 unset DISPLAY ||:\
128 unset LINGUAS ||:\
129 %{nil}
130
131 %install \
132 %if 0%{?_enable_debug_packages}\
133 %{?buildsubdir:%{debug_package}}\
134 %endif\
135 %%install\
136 LANG=C\
137 export LANG\
138 unset DISPLAY ||:\
139 unset LINGUAS ||:\
140 %{nil}
141
142 # Location of autoconf macros
143 %_aclocaldir    %(aclocal --print-ac-dir)
144
145 # Location of omf files
146 %_omf_dest_dir  %(scrollkeeper-config --omfdir)
147
148 # Location of pkgconfig files
149 %_pkgconfigdir  /usr/%{_lib}/pkgconfig
150
151 # Location of desktop files
152 %_desktopdir    /usr/share/applications
153 %_applnkdir     ERROR:_applnkdir_is_obsolete_use_desktopdir_instead
154
155 # Location of pixmaps for applnk/desktop files
156 %_pixmapsdir    /usr/share/pixmaps
157
158 # Location of themable icons for applnk/desktop files
159 %_iconsdir      /usr/share/icons
160
161 # Location of fonts directories
162 %_fontsdir      /usr/share/fonts
163
164 # Location of Gtk and associated libraries documentation
165 %_gtkdocdir  %{_defaultdocdir}/gtk-doc/html
166
167 # Location of KDE documentation
168 %_kdedocdir  %{_defaultdocdir}/kde/HTML
169
170 # unsermake script
171 %__unsermake /usr/share/unsermake/unsermake
172
173 # Current date
174 %date           %(LC_ALL="C" date +"%a %b %d %Y")
175
176 # tmp directory
177 %tmpdir         %(echo "${TMPDIR:-/tmp}")
178
179 # Example files, programs, scripts...
180 %_examplesdir   /usr/src/examples
181
182 # The directory holding Linux kernel sources
183 %_kernelsrcdir  /usr/src/linux
184
185 # If non-empty "debug" macro defined, add "dbg" suffix to release number
186 %_rpmfilename           %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
187
188 # Requires name = version-release
189 %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")
190
191 %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)")
192 %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)")
193 %requires_releq_kernel_up(s:)   Requires%{-s:(%{-s*})}: %releq_kernel_up
194 %requires_releq_kernel_smp(s:)  Requires%{-s:(%{-s*})}: %releq_kernel_smp
195
196 %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")
197 %requires_eq_to() %(LC_ALL="C" rpm -q --qf 'Requires: %1 = %%{epoch}:%%{version}\\n' %2 | sed -e 's/ (none):/ /' | grep -v "is not")
198
199 %apache_modules_api %(awk '/#define MODULE_MAGIC_NUMBER_MAJOR/ {print $3}' /usr/include/apache/ap_mmn.h 2>/dev/null || echo ERROR)
200
201 # kernel version-release handling
202 %__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))
203 %__kernel_rel   %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{RELEASE}" | grep -v "is not")
204 %__kernel_rpmvr  %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{VERSION}-%{RELEASE}" | grep -v "is not")
205 %_kernel_ver    %{__kernel_ver}%{?with_dist_kernel:%(echo %{__kernel_ver} | grep -q -e - || echo -%{__kernel_rel})}
206 %_kernel_ver_str %(echo %{!?_without_dist_kernel:%{__kernel_rpmvr}}%{?_without_dist_kernel:%{__kernel_ver}} | sed -e 's/-/_/g')
207
208 # sgml macros
209 %xmlcat_add()           /usr/bin/xmlcatalog --noout --add nextCatalog \"\" %1 /etc/xml/catalog ;
210 %xmlcat_del()           /usr/bin/xmlcatalog --noout --del %1 /etc/xml/catalog ;
211 %xmlcat_add_rewrite     /usr/bin/xmlcatalog --noout --add rewriteSystem
212 %xmlcat_create()        /usr/bin/xmlcatalog --noout --create %1 ;
213 %sgmlcat_add()          /usr/bin/install-catalog --add %1 %2 > /dev/null ;
214 %sgmlcat_del()          /usr/bin/install-catalog --remove %1 %2 > /dev/null ;
215 %docbook_sgmlcat_fix() { for l in \
216 '' \
217 '  -- default decl --' \
218 'DTDDECL "-//OASIS//DTD DocBook XML V%2//EN" "../../xml.dcl"' \
219 '  -- hacks for opensp --' \
220 'SYSTEM "file://%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
221 'SYSTEM "http://www.oasis-open.org/docbook/xml/%2/docbookx.dtd"                  "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
222 '' \
223 ; do echo $l; done >> %1 \
224 }
225
226 #-----------------------------------------------------------------
227 # find and gzip all files in %{_mandir} and %{infodir}
228 #
229 # Requires: xargs, find
230 #
231 #%no_install_post_compress_docs 1
232 %__spec_install_post_compress_docs { \
233 %{!?no_install_post_compress_docs: \
234         echo "Compress man and info pages."; \
235         %{?verbose:set -x;} \
236         for i in /usr/share/man /usr/X11R6/man /usr/share/info; do \
237                 if [ -d "$RPM_BUILD_ROOT$i" ]; then \
238                         find "$RPM_BUILD_ROOT$i" -name \*.bz2 -print | xargs -r %{__bzip2} -df; \
239                         find "$RPM_BUILD_ROOT$i" -name \*.gz -print | xargs -r %{__gzip} -dnf; \
240                         find "$RPM_BUILD_ROOT$i" -type f -print | xargs -r %{__gzip} -9nf; \
241                 fi; \
242         done; \
243 } }
244
245 #-----------------------------------------------------------------
246 # Strip executable binaries and shared object files
247 #
248 # Requires: find, awk, strip, cut, xargs
249 #
250 #%no_install_post_strip 1
251 %__spec_install_post_strip {%{!?debug: \
252 %{!?no_install_post_strip: \
253 %{?verbose:set -x;} \
254         if [ -d "$RPM_BUILD_ROOT" ]; then \
255         echo "Strip executable binaries, archives and shared object files."; \
256         filelist=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" ! -regex ".*/usr/lib[0-9]*/debug/.*\.debug" %{?_noautostrip:! -regex "%{_noautostrip}"}`; \
257         elfexelist=`echo $filelist | xargs -r file | \
258                 awk '/ELF.*executable/ {print $1}' | cut -d: -f1`; \
259         elfsharedlist=`echo $filelist | xargs -r file | \
260                 awk '/LF.*shared object/ {print $1}' | cut -d: -f1`; \
261         elfarchiveslist=`echo $filelist | xargs -r file | \
262                 awk '/current ar archive/ {print $1}' | cut -d: -f1`; \
263         if [ -n "$elfexelist" ]; then \
264                 %{__strip} --remove-section=.note  --remove-section=.comment $elfexelist; \
265         fi; \
266         if [ -n "$elfsharedlist" ]; then \
267                 %{__strip} --strip-unneeded --remove-section=.note  --remove-section=.comment $elfsharedlist; \
268         fi; \
269         if [ -n "$elfarchiveslist" ]; then \
270                 %{__strip} --strip-debug --remove-section=.note  --remove-section=.comment $elfarchiveslist; \
271         fi; \
272 fi; } \
273 } }
274
275 #-----------------------------------------------------------------
276 # remove all RPATH from executable binaries and shared object files
277 #
278 # Requires: find, awk, cut, xargs, chrpath, uname
279 #
280 #%no_install_post_chrpath       1
281 %__spec_install_post_chrpath {%{!?debug: \
282 %{!?no_install_post_chrpath: \
283         %{?verbose:set -x;} \
284 if [ -d "$RPM_BUILD_ROOT" ]; then \
285 echo "Remove RPATH from executable binaries and shared object files."; \
286 find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" ! -regex ".*/usr/lib[0-9]*/debug/.*" %{?_noautochrpath:! -regex "%{_noautochrpath}"} | xargs -r file | \
287         awk '/ELF.*(executable.*dynamically linked|shared object)/ {print $1}' | cut -d: -f1 | \
288 while read file ; do \
289         rpath= ; \
290         chmod u+w "$file"; \
291         for dir in `chrpath -l "$file" | \
292                         awk '/RPATH=/ { gsub(/.*RPATH=/,""); gsub(/:/," "); print $0 }'` ; do \
293                         case $dir in \
294                         /home/* | /tmp/* | /usr/lib | /usr/lib64 | /lib | /lib64 | /usr/local/lib | /usr/local/lib64 | /usr/X11R6/lib | /usr/X11R6/lib64 ) \
295                                 echo "remove-rpath: $dir in $file"; \
296                                 ;; \
297                         * ) \
298                                 if [ "$rpath" = "" ] ; then rpath="$dir" ; \
299                                 else rpath="$rpath:$dir" ; fi ; \
300                                 ;; \
301                         esac ; \
302         done ; \
303         if [ "$rpath" = "" ] ; then chrpath -d "$file" > /dev/null ; \
304         else chrpath -r "$rpath" "$file" > /dev/null ; fi ; \
305 done; \
306 fi; } \
307 } }
308
309 #-----------------------------------------------------------------
310 # Find and gzip all kernel modules
311 #
312 # Requires: find
313 #
314 #%no_install_post_compress_modules  1
315 %__spec_install_post_compress_modules { \
316 %{!?no_install_post_compress_modules: \
317         %{?verbose:set -x;} \
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 } }
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_debug                              %(awk '/#define ZEND_DEBUG/{print $3}' %{__php_includedir}/main/php_config.h 2>/dev/null || echo ERROR)
451 %zend_module_api                %(awk '/#define ZEND_MODULE_API_NO/{print $3}' %{__php_includedir}/Zend/zend_modules.h 2>/dev/null || echo ERROR)
452 %zend_extension_api             %(awk '/#define ZEND_EXTENSION_API_NO/{print $3}' %{__php_includedir}/Zend/zend_extensions.h 2>/dev/null || echo ERROR)
453 %zend_zts                               %(Z=$(grep -sc '^#define ZTS 1' %{__php_includedir}/main/php_config.h); echo ${Z:-ERROR})
454
455 # helper macro
456 %__php_api_requires(v:) Requires: php%{-v*}(%{expand:%1}) = %{expand:%{%{!?2:%{1}}%{?2}}}
457
458 # macros for public use
459 # for php extensions (php-pecl)
460 %requires_php_extension %{__php_api_requires modules_api php_api_version} \
461 %{__php_api_requires -v %php_major_version debug php_debug} \
462 %{__php_api_requires -v %php_major_version thread-safety zend_zts}
463
464 # for zend extensions
465 %requires_zend_extension %{__php_api_requires zend_module_api} \
466 %{__php_api_requires zend_extension_api} \
467 %{__php_api_requires -v %php_major_version debug php_debug} \
468 %{__php_api_requires -v %php_major_version thread-safety zend_zts}
469
470 # Python specific macro definitions.
471 # python main version
472 %py_ver         %(python -c "import sys; print sys.version[:3]")
473
474 # directories
475 %py_prefix              %(python -c "import sys; print sys.prefix")
476 %py_libdir              %{py_prefix}/%{_lib}/python%{py_ver}
477 %py_scriptdir   %{py_prefix}/share/python%{py_ver}
478 %py_incdir              /usr/include/python%{py_ver}
479 %py_sitedir     %{py_libdir}/site-packages
480 %py_sitescriptdir %{py_scriptdir}/site-packages
481 %py_dyndir              %{py_libdir}/lib-dynload
482
483 # pure python modules compilation
484 %py_comp                python -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
485
486 %py_ocomp               python -O -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
487
488 # Software written in Python language require Python with main version
489 %pyrequires_eq() Requires:      %1
490
491 # Hardlink binary identical .pyc and .pyo files
492 # (idea by glen <at> pld-linux <dot> org)
493 %__spec_install_post_py_hardlink {\
494 %{!?no_install_post_py_hardlink: \
495 [ ! -d "$RPM_BUILD_ROOT" ] || find "$RPM_BUILD_ROOT" -name '*.pyc' | while read a; do \
496         b="$(echo $a|sed -e 's/.pyc$/.pyo/')"; \
497         if cmp -s "$a" "$b"; then \
498                 ln -f "$a" "$b"; \
499         fi; \
500 done \
501 } }
502
503 # remove python sources, so that check-files won't complain
504 # (idea by glen <at> pld-linux <dot> org)
505 %py_postclean() \
506 for d in %{py_sitescriptdir} %{py_sitedir} %*; do \
507  [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -print0 | xargs -0r -l512 rm;\
508 done \
509 %{nil}
510
511 # depmod macro
512 %depmod() { \
513 umask 022; \
514 if [ -e /boot/System.map-%1 ]; then \
515         /sbin/depmod -a -F /boot/System.map-%1 %1; \
516 else \
517         if [ -e /boot/System.map ]; then \
518                 /sbin/depmod -a -F /boot/System.map %1; \
519         else \
520                 /sbin/depmod -a %1; \
521         fi \
522 fi; \
523 }
524
525 # XMMS specific macros
526 %xmms_prefix                    %(xmms-config --prefix 2>/dev/null)
527 %xmms_exec_prefix               %(xmms-config --exec-prefix 2>/dev/null)
528 %xmms_version                   %(xmms-config --version 2>/dev/null)
529 %xmms_datadir                   %(xmms-config --data-dir 2>/dev/null)
530 %xmms_plugindir                 %(xmms-config --plugin-dir 2>/dev/null)
531 %xmms_visualization_plugindir   %(xmms-config --visualization-plugin-dir 2>/dev/null)
532 %xmms_input_plugindir           %(xmms-config --input-plugin-dir 2>/dev/null)
533 %xmms_output_plugindir          %(xmms-config --output-plugin-dir 2>/dev/null)
534 %xmms_effect_plugindir          %(xmms-config --effect-plugin-dir 2>/dev/null)
535 %xmms_general_plugindir         %(xmms-config --general-plugin-dir 2>/dev/null)
536
537 %_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/')
538
539 # user/group checking macros
540 #
541 # Usage:
542 #       %userremove myuser
543 #
544 %userremove     /usr/lib/rpm/user_group.sh user del
545 %groupremove    /usr/lib/rpm/user_group.sh group del
546 #
547 # Usage:
548 #       if %usertestrm myuser; then
549 #               /usr/sbin/userdel -r myuser
550 # Note:
551 #       use these macros only if you need to call userdel/groupdel with
552 #       a non-standard option or take an extra action; otherwise use the
553 #       %userremove/%groupremove macros
554 #
555 %usertestrm     /usr/lib/rpm/user_group.sh user testrm
556 %grouptestrm    /usr/lib/rpm/user_group.sh group testrm
557 # user group membership management macros
558 #
559 # Usage:
560 #       %addusertogroup myuser agroup
561 #
562 %addusertogroup /usr/lib/rpm/user_group.sh user addtogroup
563
564 # banner support (useful in {pre,post}{,un} and triggers)
565 #
566 # Usage:
567 #       %banner name [-a] [-e] [-n] [-tn] <<EOF
568 # the banner text, the banner text
569 # the banner text, and following line
570 #EOF
571 # You can use any form of here-document, <<'EOF' <<-EOT will do.
572 # NOTE: if your use "<<-EOF", then You can actually indent inside here-document.
573 #
574 # -a   - append to the banner
575 # -e   - send to stderr instead of stdout
576 # -n   - no show banner (overrides -t)
577 # -t   - show only, if RPM_SCRIPTVERBOSITY >= n; default n=5
578 %banner(aent:)  \
579 RPM_SCRIPTVERBOSITY=5 \
580 [ -r /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm \
581 if [ -x /usr/bin/banner.sh ]; then \
582         CMD="/usr/bin/banner.sh %{-e:--stderr} %{!-n:$([ $RPM_SCRIPTVERBOSITY -ge %{-t:%{-t*}}%{!-t:5} ] && echo -s)} %{!-a:-m}%{-a:-M} %1" \
583 else \
584         CMD="cat%{-e: >&2}" \
585 fi \
586 eval $CMD %2%{?3: %3} \
587 %nil
588
589 # useradd/groupadd macros written by glen@pld-linux.org.
590 # All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
591 #
592 # Usage:
593 #   %useradd [-P package] [-u uid] [-d home_dir] [-s shell] [-c comment]
594 #   [-g initial_group] [-G group[,...]] login
595 #
596 #  -u uid. REQUIRED
597 #  -g gid/group. REQUIRED
598 #  -s defaults to /bin/false
599 #  -d defaults to /usr/share/empty
600 #  -c No default
601 #  -r is accepted but ignored (it's always set)
602 #  -k skeleton dir. defaults to /usr/share/empty
603 # rpm specific flags
604 #  -P package name. defaults to %{name}
605 #
606 %useradd(c:d:e:f:g:G:Mmk:op:s:u:rP:) \
607 %{!-u:%{error:useradd: Required argument -u missing}} \
608 %{!-g:%{error:useradd: Required argument -g missing}} \
609 %{!?1:%{error:useradd: Required parameter login missing}} \
610 if [ -n "`/bin/id -u %{expand:%{%{#}}} 2>/dev/null`" ]; then \
611         if [ "`/bin/id -u %{expand:%{%{#}}}`" != "%{-u*}" ]; then \
612                 echo "Error: user %{expand:%{%{#}}} doesn't have uid=%{-u*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
613                 exit 1 \
614         fi \
615 else \
616         echo "Adding user %{expand:%{%{#}}} UID=%{-u*}." \
617         /usr/sbin/useradd \\\
618                 %{-m:-m -k %{-k*}%{!-k:/usr/share/empty}} \\\
619                 -u %{-u*} \\\
620                 -r \\\
621                 -d %{-d*}%{!-d:/usr/share/empty} \\\
622                 -s %{-s*}%{!-s:/bin/false} \\\
623                 %{-c:-c "%(set -- %{-c*} %{*}; echo $1)"}\\\
624                 -g %{-g*} \\\
625                 %{-M} \\\
626                 %{-G:-G %{-G*}} \\\
627                 %{expand:%{%{#}}} 1>&2 \
628 fi;
629
630 # Usage:
631 #   %groupadd [-P package] [-g gid] group
632 #
633 # -g gid. REQUIRED
634 #
635 # Sample:
636 #   %groupadd -P %{name}-base -g %{gid} %{name}
637
638 %groupadd(g:P:rfo)      \
639 %{!-g:%{error:groupadd: Required argument -g missing}} \
640 %{!?1:%{error:groupadd: Required parameter group missing}} \
641 if [ -n "`/usr/bin/getgid %{1}`" ]; then \
642         if [ "`/usr/bin/getgid %{1}`" != "%{-g*}" ]; then \
643                 echo "Error: group %{1} doesn't have gid=%{-g*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
644                 exit 1 \
645         fi \
646 else \
647         echo "Adding group %{1} GID=%{-g*}." \
648         /usr/sbin/groupadd -g %{-g*} -r %{1} 1>&2 \
649 fi;
650
651 # apache_config_{install/uninstall} macros written by glen@pld-linux.org.
652 # All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
653 #
654 # You should use webapp macros instead. these are here until single piece of them is gone from specs ;)
655 #
656 # The config is installed/removed inside trigger, this means that you can any
657 # time install apache1 or apache package and the configuration file is updated.
658 # if you don't need the config for various reason for specific apache, just
659 # remove the symlink from apache config directory. the trigger will not put the
660 # config again to that version of apache. In other words the config is linked
661 # to apache config directory on first install of PACKAGE or apache.
662 #
663 # should be called in trigger body:
664 #  %triggerin -- apache1 >= 1.3.33-2
665 #  %apache_config_install -v 1
666 #
667 # Add package's apache config to apache config.
668 #
669 # Usage:
670 #   %apache_config_install -v {1|2} -c %{_sysconfdir}/apache-%{name}.conf -n 99
671 #
672 #  -v REQUIRED: specify apache version. can be 1 or 2.
673 #  -c OPTIONAL: specify full path to PACKAGE's config. Defaults to %{_sysconfdir}/apache-%{name}.conf.
674 #  -n OPTIONAL: specify config "slot". defaults to 99
675 #  -f OPTIONAL: force symlink creation regardless if package was upraded. useful in triggers
676 #
677 # Internal macros. don't use ;).
678 # expands apache config dir by apache version at build time.
679 %__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)
680 # expands apache service name by apache version at build time.
681 %__apache_svcname() %(if [ %{1} = 1 ]; then echo apache; elif [ %{1} = 2 ]; then echo httpd; else echo >&2 Unknown apache version specified; fi)
682
683 %apache_config_install(fv:c:n:) \
684 %{!-v:%{error:apache_config_install: Required argument -v missing}} \
685 %{?debug:set -x; echo "apache_config_install:%{-v*} %{name}-%{version}-%{release} 1:[$1]; 2:[$2]"} \
686 if [ -n "%{-f:1}" ] || ([ "$1" = "1" ] && [ "$2" = "1" ]) && [ -d %{__apache_confdir %{-v*}} ]; then\
687         ln -sf %{-c*}%{!-c:%{_sysconfdir}/apache-%{name}.conf} %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf\
688 fi\
689 # reload apache if the config symlink is there\
690 if [ -L %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf ]; then\
691         # additionally don't reload if target package (the webserver) is upgraded, as webserver is restarted anyway in %post \
692         if [ "$2" != "2" ] && [ -f /var/lock/subsys/%{__apache_svcname %{-v*}} ]; then\
693                 /etc/rc.d/init.d/%{__apache_svcname %{-v*}} reload 1>&2\
694         fi\
695 fi\
696 %{nil}
697
698 # Remove package's apache config from apache config.
699 #
700 # Usage:
701 #   %apache_config_uninstall -v {1|2} -n 99
702 #
703 #  -v REQUIRED: specify apache version. can be 1 or 2.
704 #  -n OPTIONAL: specify config "slot". defaults to 99
705 %apache_config_uninstall(v:n:) \
706 %{!-v:%{error:apache_config_uninstall: Required argument -v missing}} \
707 %{?debug:set -x; echo "apache_config_uninstall:%{-v*} %{name}-%{version}-%{release}: 1:[$1]; 2:[$2]"} \
708 # remove link if either of the packages are gone \
709 if [ "$1" = "0" ] || [ "$2" = "0" ]; then \
710         if [ -L %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf ]; then \
711                 rm -f %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf \
712                 if [ -f /var/lock/subsys/%{__apache_svcname %{-v*}} ]; then \
713                         /etc/rc.d/init.d/%{__apache_svcname %{-v*}} reload 1>&2 \
714                 fi \
715         fi \
716 fi \
717 %{nil}
718
719 # webapp macros
720 #
721 # The config is installed/removed inside trigger, this means that you can any
722 # time install apache1/apache/lighttpd package and the configuration file is
723 # updated.  if you don't need the config for various reason for specific
724 # webserver, just remove the symlink from config directory using webapp
725 # program. the trigger will not recreate the symlink on upgrades. In other
726 # words the config is linked to webserver config directory on first install of
727 # PACKAGE or WEBSERVER.
728 #
729 # Add package's webserver config to webserver webapps dir.
730 # Usage:
731 #   %webapp_register WEBSERVER WEBAPP
732 #
733 %webapp_register() \
734 %{?debug:set -x; echo "webapp_register: %{name}-%{version}-%{release} 1:[$1]; 2:[$2]"} \
735 if [ "$1" = "1" ] && [ "$2" = "1" ]; then\
736         /usr/sbin/webapp register %1 %2\
737 fi\
738 # reload webserver if the config symlink is there and skip reload if webserver is upgraded\
739 if [ -L /etc/%1/webapps.d/%2.conf ] && [ "$2" -lt "2" ]; then\
740         %{expand:%service -q %%1 reload}\
741 fi\
742 %{nil}
743
744 # Remove package's config from webserver webapps dir.
745 # Usage:
746 #   %webapp_register [-f] WEBSERVER WEBAPP
747 %webapp_unregister(f) \
748 %{?debug:set -x; echo "webapp_unregister: %{name}-%{version}-%{release}: 1:[$1]; 2:[$2]"} \
749 # remove link if either of the packages are gone \
750 if [ -n "%{-f:1}" ] || [ "$1" = "0" ] || [ "$2" = "0" ] && [ -L /etc/%1/webapps.d/%2.conf ]; then \
751         /usr/sbin/webapp unregister %1 %2\
752         %{expand:%service -q %%1 reload}\
753 fi \
754 %{nil}
755
756 # see browser-plugins.spec / template-browser-plugin.spec
757 # written by glen@pld-linux.org.
758 %nsplugin_install(d:f) { \
759 # create link if it's first install of either of the packages \
760 if [ -n "%{-f:1}" ] || ([ "$1" = "1" ] && [ "$2" = "1" ] && [ -d %{-d*} ]); then \
761 ( \
762 %( \
763         for file in %{*}; do \
764                 echo echo Installing $file to %{-d*}; \
765                 echo "ln -sf %{_libdir}/browser-plugins/$file %{-d*};"; \
766         done ) \
767 ) | ( %banner -t 5 -e %{name}-in ); fi; \
768 }
769
770 %nsplugin_uninstall(d:) { \
771 # remove link if either of the packages are gone \
772 if [ "$1" = "0" ] || [ "$2" = "0" ]; then \
773 ( \
774 %( \
775         for file in %{*}; do \
776                 echo echo Removing $file from %{-d*}; \
777                 echo "rm -f %{-d*}/$file;"; \
778         done ) \
779 ) | ( %banner -t 5 -e %{name}-un ); fi; \
780 }
781
782 # service macro.
783 #
784 # calls usual service restart on package %post, but skips the restart if
785 # administrator has disabled automatic service restarts in either global
786 # /etc/sysconfig/rpm or per service /etc/sysconfig/SERVICE file.
787 #
788 # written by glen@pld-linux.org.
789 # All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
790 #
791 # Usage:
792 #   %service [-q] SERVICE ACTION ["SERVICE NICE DESCRIPTION"]
793 #
794 #  -q be silent when service isn't started (for scriplets restaring other package's services)
795 #
796 %service(q) {{%(export quiet=%{-q:1}; /usr/lib/rpm/service_generator.sh %{*}) };}
This page took 0.125825 seconds and 4 git commands to generate.