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