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