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