5 %_enable_debug_packages 1
9 %__chown_Rhf @__CHOWN_RHF@
10 %__chgrp_Rhf @__CHGRP_RHF@
12 %_fixowner [ `%{__id_u}` = '0' ] && %{__chown_Rhf} root:@ROOT_GROUP@
14 %_fixperms %{__chmod} -Rf @FIXPERMS@
15 %_topdir %(echo $HOME)/rpm
16 #-----------------------------------------------------------------
17 # CFLAGS and LDFLAGS used to build
19 %debuginfocflags %{expand:%%define __dic_%{?_enable_debug_packages} 1}%{?__dic_1: -ggdb}%{expand:%%undefine __dic_%{?_enable_debug_packages}}
21 %debugcflags -O0 -g -Wall
22 %rpmcflags %{?debug:%debugcflags}%{!?debug:%optflags}%{?debuginfocflags}
23 %rpmcxxflags %{rpmcflags}
25 # %rpmldflags -Wl,--as-needed
31 # Build system path macros.
33 %__autoconf autoconf %{?debug:-Wall}
34 %__automake automake -a -c -f --foreign
35 %__autopoint autopoint --force
38 if ! gettextize --version | grep -q '0\.10\.' ; then \
39 if grep -qs 'AM_GNU_GETTEXT.*external' configure.{ac,in} ; then \
40 gettextize --copy --force --no-changelog; \
42 gettextize --copy --force --no-changelog --intl; \
44 if [ ! -f po/Makevars ]; then \
45 cp -f po/Makevars{.template,}; \
48 gettextize --copy --force; \
52 %__glib_gettextize glib-gettextize --copy --force
53 %__gnome_doc_common gnome-doc-common --copy
54 %__gtkdocize gtkdocize --copy
55 %__intltoolize intltoolize --copy --force
56 %__libtoolize libtoolize --copy --force
58 %dependencytracking %{nil}
59 #-----------------------------------------------------------------
61 if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \
62 LDFLAGS="${LDFLAGS:-%rpmldflags}" ; export LDFLAGS ; \
63 CFLAGS="${CFLAGS:-%rpmcflags}" ; export CFLAGS ; \
64 CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" ; export CXXFLAGS ; \
65 FFLAGS="${FFLAGS:-%rpmcflags}" ; export FFLAGS ; \
66 CPPFLAGS="${CPPFLAGS:-}" ; export CPPFLAGS ; \
67 %{?__cc:CC="%{__cc}" ; export CC ; } \
68 %{?__cxx:CXX="%{__cxx}" ; export CXX ; } \
69 %{?configuredir:%{configuredir}}%{!?configuredir:.}/configure \
70 --host=%{_target_platform} \
72 --exec-prefix=%{_exec_prefix} \
74 --sbindir=%{_sbindir} \
75 --sysconfdir=%{_sysconfdir} \
76 --datadir=%{_datadir} \
77 --includedir=%{_includedir} \
79 --libexecdir=%{_libexecdir} \
80 --localstatedir=%{_localstatedir} \
81 --sharedstatedir=%{_sharedstatedir} \
83 --infodir=%{_infodir} \
84 --x-libraries=/usr/X11R6/%{_lib} \
85 %{dependencytracking} \
88 #----------------------------------------------------------------
89 %global configure_cache 0
90 %configure_cache_file %{buildroot}.configure.cache
92 %configure {./configure \
93 LDFLAGS="${LDFLAGS:-%rpmldflags}" \
94 CFLAGS="${CFLAGS:-%rpmcflags}" \
95 CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" \
96 FFLAGS="${FFLAGS:-%rpmcflags}" \
97 CPPFLAGS="${CPPFLAGS:-}" \
98 %{?__cc:CC="%{__cc}"} \
99 %{?__cxx:CXX="%{__cxx}"} \
100 --host=%{_target_platform} \
101 --build=%{_target_platform} \
102 --prefix=%{_prefix} \
103 --exec-prefix=%{_exec_prefix} \
104 --bindir=%{_bindir} \
105 --sbindir=%{_sbindir} \
106 --sysconfdir=%{_sysconfdir} \
107 --datadir=%{_datadir} \
108 --includedir=%{_includedir} \
109 --libdir=%{_libdir} \
110 --libexecdir=%{_libexecdir} \
111 --localstatedir=%{_localstatedir} \
112 --sharedstatedir=%{_sharedstatedir} \
113 --mandir=%{_mandir} \
114 --infodir=%{_infodir} \
115 --x-libraries=/usr/X11R6/%{_lib} \
116 %{dependencytracking} \
117 %{?configure_cache:--cache-file=%{configure_cache_file:-%{buildroot}.configure.cache}} \
120 # ------------------------------------------------------------------------
121 # Overloading of some basic macros
137 %install %{?_enable_debug_packages:%{?buildsubdir:%{debug_package}}}\
145 # ------------------------------------------------------------------------
146 # Conditional build stuff.
148 # Check if symbol is defined.
149 # Example usage: %if %{defined with_foo} && %{undefined with_bar} ...
150 %defined() %{expand:%%{?%{1}:1}%%{!?%{1}:0}}
151 %undefined() %{expand:%%{?%{1}:0}%%{!?%{1}:1}}
153 # Shorthand for %{defined with_...}
154 %with() %{expand:%%{?with_%{1}:1}%%{!?with_%{1}:0}}
155 %without() %{expand:%%{?with_%{1}:0}%%{!?with_%{1}:1}}
157 # Handle conditional builds. %bcond_with is for case when feature is
158 # default off and needs to be activated with --with ... command line
159 # switch. %bcond_without is for the dual case.
161 # %bcond_with foo defines symbol with_foo if --with foo was specified on
163 # %bcond_without foo defines symbol with_foo if --without foo was *not*
164 # specified on command line.
168 # %bcond_with extra_fonts
169 # %bcond_without static
170 # %if %{with extra_fonts}
173 # %ifdef %{with static}
176 # %{?with_static: ... }
177 # %{!?with_static: ... }
178 # %{?with_extra_fonts: ... }
179 # %{!?with_extra_fonts: ... }
181 # The bottom line: never use without_foo, _with_foo nor _without_foo, only
182 # with_foo. This way changing default set of bconds for given spec is just
183 # a matter of changing single line in it and syntax is more readable.
184 %bcond_with() %{expand:%%{?_with_%{1}:%%global with_%{1} 1}}
185 %bcond_without() %{expand:%%{!?_without_%{1}:%%global with_%{1} 1}}
186 # ------------------------------------------------------------------------
188 # Location of autoconf macros
189 %_aclocaldir %(aclocal --print-ac-dir)
191 # Location of omf files
192 %_omf_dest_dir %(scrollkeeper-config --omfdir)
194 # Location of pkgconfig files
195 %_pkgconfigdir /usr/%{_lib}/pkgconfig
197 # Location of desktop files
198 %_desktopdir /usr/share/applications
199 %_applnkdir ERROR:_applnkdir_is_obsolete_use_desktopdir_instead
201 # Location of pixmaps for applnk/desktop files
202 %_pixmapsdir /usr/share/pixmaps
204 # Location of themable icons for applnk/desktop files
205 %_iconsdir /usr/share/icons
207 # Location of fonts directories
208 %_fontsdir /usr/share/fonts
210 # Location of Gtk and associated libraries documentation
211 %_gtkdocdir %{_defaultdocdir}/gtk-doc/html
213 # Location of KDE documentation
214 %_kdedocdir %{_defaultdocdir}/kde/HTML
217 %__unsermake /usr/share/unsermake/unsermake
220 %date %(LC_ALL="C" date +"%a %b %d %Y")
223 %tmpdir %(echo "${TMPDIR:-/tmp}")
225 # Example files, programs, scripts...
226 %_examplesdir /usr/src/examples
228 # The directory holding Linux kernel sources
229 %_kernelsrcdir /usr/src/linux
231 # If non-empty "debug" macro defined, add "dbg" suffix to release number
232 %_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
234 # Requires name = version-release
235 %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")
237 %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)")
238 %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)")
239 %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)")
240 %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)")
242 %requires_eq_to() %(LC_ALL="C" rpm -q --qf 'Requires: %1 = %%{epoch}:%%{version}\\n' %2 | sed -e 's/ (none):/ /' | grep -v "is not")
244 %apache_modules_api %(awk '/#define MODULE_MAGIC_NUMBER_MAJOR/ {print $3}' /usr/include/apache/ap_mmn.h 2>/dev/null || echo ERROR)
246 # kernel version-release handling
247 %__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))
248 %__kernel_rel %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{RELEASE}" | grep -v "is not")
249 %__kernel_rpmvr %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{VERSION}-%{RELEASE}" | grep -v "is not")
250 %_kernel_ver %{__kernel_ver}%{?with_dist_kernel:%(echo %{__kernel_ver} | grep -q -e - || echo -%{__kernel_rel})}
251 %_kernel_ver_str %(echo %{!?_without_dist_kernel:%{__kernel_rpmvr}}%{?_without_dist_kernel:%{__kernel_ver}} | sed -e 's/-/_/g')
254 %xmlcat_add() /usr/bin/xmlcatalog --noout --add nextCatalog \"\" %1 /etc/xml/catalog ;
255 %xmlcat_del() /usr/bin/xmlcatalog --noout --del %1 /etc/xml/catalog ;
256 %xmlcat_add_rewrite /usr/bin/xmlcatalog --noout --add rewriteSystem
257 %xmlcat_create() /usr/bin/xmlcatalog --noout --create %1 ;
258 %sgmlcat_add() /usr/bin/install-catalog --add %1 %2 > /dev/null ;
259 %sgmlcat_del() /usr/bin/install-catalog --remove %1 %2 > /dev/null ;
260 %docbook_sgmlcat_fix() { for l in \
262 ' -- default decl --' \
263 'DTDDECL "-//OASIS//DTD DocBook XML V%2//EN" "../../xml.dcl"' \
264 ' -- hacks for opensp --' \
265 'SYSTEM "file://%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
266 'SYSTEM "http://www.oasis-open.org/docbook/xml/%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
268 ; do echo $l; done >> %1 \
271 #-----------------------------------------------------------------
272 # find and gzip all files in %{_mandir} and %{infodir}
274 # Requires: xargs, find
276 #%no_install_post_compress_docs 1
277 %__spec_install_post_compress_docs { \
278 %{!?no_install_post_compress_docs: \
279 echo "Compress man and info pages."; \
280 %{?verbose:set -x;} \
281 for i in /usr/share/man /usr/X11R6/man /usr/share/info; do \
282 if [ -d "$RPM_BUILD_ROOT$i" ]; then \
283 find "$RPM_BUILD_ROOT$i" -name \*.bz2 -print | xargs -r %{__bzip2} -df; \
284 find "$RPM_BUILD_ROOT$i" -name \*.gz -print | xargs -r %{__gzip} -dnf; \
285 find "$RPM_BUILD_ROOT$i" -type f -print | xargs -r %{__gzip} -9nf; \
290 #-----------------------------------------------------------------
291 # Strip executable binaries and shared object files
293 # Requires: find, awk, strip, cut, xargs
295 #%no_install_post_strip 1
296 %__spec_install_post_strip {%{!?debug: \
297 %{!?no_install_post_strip: \
298 %{?verbose:set -x;} \
299 if [ -d "$RPM_BUILD_ROOT" ]; then \
300 echo "Strip executable binaries, archives and shared object files."; \
301 filelist=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" %{?_noautostrip:! -regex "%{_noautostrip}"}`; \
302 elfexelist=`echo $filelist | xargs -r file | \
303 awk '/ELF.*executable/ {print $1}' | cut -d: -f1`; \
304 elfsharedlist=`echo $filelist | xargs -r file | \
305 awk '/LF.*shared object/ {print $1}' | cut -d: -f1`; \
306 elfarchiveslist=`echo $filelist | xargs -r file | \
307 awk '/current ar archive/ {print $1}' | cut -d: -f1`; \
308 if [ -n "$elfexelist" ]; then \
309 %{__strip} --remove-section=.note --remove-section=.comment $elfexelist; \
311 if [ -n "$elfsharedlist" ]; then \
312 %{__strip} --strip-unneeded --remove-section=.note --remove-section=.comment $elfsharedlist; \
314 if [ -n "$elfarchiveslist" ]; then \
315 %{__strip} --strip-debug --remove-section=.note --remove-section=.comment $elfarchiveslist; \
319 #-----------------------------------------------------------------
320 # remove all RPATH from executable binaries and shared object files
322 # Requires: find, awk, cut, xargs, chrpath, uname
324 #%no_install_post_chrpath 1
325 %__spec_install_post_chrpath {%{!?debug: \
326 %{!?no_install_post_chrpath: \
327 %{?verbose:set -x;} \
328 if [ -d "$RPM_BUILD_ROOT" ]; then \
329 echo "Remove RPATH from executable binaries and shared object files."; \
330 find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" ! -regex ".*/usr/lib[0-9]*/debug/.*" %{?_noautochrpath:! -regex "%{_noautochrpath}"} | xargs -r file | \
331 awk '/ELF.*(executable.*dynamically linked|shared object)/ {print $1}' | cut -d: -f1 | \
332 while read file ; do \
335 for dir in `chrpath -l "$file" | \
336 awk '/RPATH=/ { gsub(/.*RPATH=/,""); gsub(/:/," "); print $0 }'` ; do \
338 /home/* | /tmp/* | /usr/lib | /usr/lib64 | /lib | /lib64 | /usr/local/lib | /usr/local/lib64 | /usr/X11R6/lib | /usr/X11R6/lib64 ) \
339 echo "remove-rpath: $dir in $file"; \
342 if [ "$rpath" = "" ] ; then rpath="$dir" ; \
343 else rpath="$rpath:$dir" ; fi ; \
347 if [ "$rpath" = "" ] ; then chrpath -d "$file" > /dev/null ; \
348 else chrpath -r "$rpath" "$file" > /dev/null ; fi ; \
352 #-----------------------------------------------------------------
353 # Find and gzip all kernel modules
357 #%no_install_post_compress_modules 1
358 %__spec_install_post_compress_modules { \
359 %{!?no_install_post_compress_modules: \
360 %{?verbose:set -x;} \
361 if [ -d "$RPM_BUILD_ROOT" ]; then \
362 echo "Compress kernel modules if any."; \
363 if test -d $RPM_BUILD_ROOT/lib/modules ; then \
364 find $RPM_BUILD_ROOT/lib/modules -name \*o -type f -print | \
365 xargs -r %{__gzip} -9nf; \
366 find $RPM_BUILD_ROOT/lib/modules -name \*o -type l -printf "%p %l\n" | \
367 while read a b; do ln -sf $b.gz $a.gz; rm -f $a; done; \
372 %_source_payload w9.gzdio
373 %_binary_payload w9.bzdio
375 #-----------------------------------------------------------------
376 # Update GConf2 schemas
380 %gconf_schema_install() \
382 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 \
385 %gconf_schema_uninstall() \
386 if [ $1 = 0 ]; then \
388 GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" /usr/bin/gconftool-2 --makefile-uninstall-rule /etc/gconf/schemas/%{?1} > /dev/null \
392 #-----------------------------------------------------------------
393 # Update desktop MIME database
394 # requires: desktop-file-utils
396 %update_desktop_database_post() {{ \
398 /usr/bin/update-desktop-database; \
401 %update_desktop_database_postun() {{ \
402 if [ $1 = 0 ]; then \
404 /usr/bin/update-desktop-database; \
408 #-----------------------------------------------------------------
409 # Update scrollkeeper database
410 # requires: scrollkeeper
412 %scrollkeeper_update_post() \
413 /usr/bin/scrollkeeper-update -q; \
416 %scrollkeeper_update_postun() \
417 if [ $1 = 0 ]; then \
418 /usr/bin/scrollkeeper-update -q; \
422 #-----------------------------------------------------------------
423 # Run ldconfig after installing/deinstalling libraries
433 #-----------------------------------------------------------------
434 # post %install sequence:
435 # - autodeps exceptions
436 # - compress all man and info pages,
437 # - strip all ELF executables and ELF shared objects if not %debug.
438 # - compress kernel modules if any
440 ###################################################################
441 # Requires/Provides automation
442 # exceptions system by Jacek Konieczny <jajcus@pld.org.pl>
444 %__noautoreqfiles %(sed -e s'/#.*//' /etc/rpm/noautoreqfiles)%{?_noautoreqfiles: %{_noautoreqfiles}}
445 %__noautoprovfiles %(sed -e s'/#.*//' /etc/rpm/noautoprovfiles)%{?_noautoprovfiles: %{_noautoprovfiles}}
446 %__noautoreq %(sed -e s'/#.*//' /etc/rpm/noautoreq)%{?_noautoreq: %{_noautoreq}}
447 %__noautoreqdep %(sed -e s'/#.*//' /etc/rpm/noautoreqdep)%{?_noautoreqdep: %{_noautoreqdep}}
448 %__noautoprov %(sed -e s'/#.*//' /etc/rpm/noautoprov)%{?_noautoprov: %{_noautoprov}}
449 #%_noautocompressdoc %{nil}
451 %_missing_doc_files_terminate_build 1%{nil}
452 %_unpackaged_files_terminate_build %{nil}
454 %___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;}'
455 %_emacs_lispdir %(emacs %___emacs_lispdir_helper)
456 %_xemacs_lispdir %(xemacs %___emacs_lispdir_helper)
458 %__php_provides %{nil}
459 %__php_requires %{nil}
460 %__perl_provides %{nil}
461 %__perl_requires %{nil}
462 %__mono_provides %{nil}
463 %__mono_requires %{nil}
465 # Perl specific macro definitions.
466 %perl_privlib %(eval "`%{__perl} -V:installprivlib`"; echo $installprivlib)
467 %perl_archlib %(eval "`%{__perl} -V:installarchlib`"; echo $installarchlib)
468 %perl_vendorlib %(eval "`%{__perl} -V:installvendorlib`"; echo $installvendorlib)
469 %perl_vendorarch %(eval "`%{__perl} -V:installvendorarch`"; echo $installvendorarch)
470 %perl_sitelib %(eval "`%{__perl} -V:installsitelib`"; echo $installsitelib)
471 %perl_sitearch %(eval "`%{__perl} -V:installsitearch`"; echo $installsitearch)
473 %php_pear_dir %{_datadir}/pear
475 # extract php/zend api versions
476 %php_api_version %(awk '/#define PHP_API_VERSION/{print $3}' /usr/include/php/main/php.h)
477 %zend_module_api %(awk '/#define ZEND_MODULE_API_NO/{print $3}' /usr/include/php/Zend/zend_modules.h)
478 %zend_extension_api %(awk '/#define ZEND_EXTENSION_API_NO/{print $3}' /usr/include/php/Zend/zend_extensions.h)
480 # directory where php includes are installed on system.
481 %__php_includedir /usr/include/php
482 %php_api_version %(awk '/#define PHP_API_VERSION/{print $3}' %{__php_includedir}/main/php.h 2>/dev/null || echo ERROR)
483 %zend_module_api %(awk '/#define ZEND_MODULE_API_NO/{print $3}' %{__php_includedir}/Zend/zend_modules.h 2>/dev/null || echo ERROR)
484 %zend_extension_api %(awk '/#define ZEND_EXTENSION_API_NO/{print $3}' %{__php_includedir}/Zend/zend_extensions.h 2>/dev/null || echo ERROR)
487 %__php_api_requires() Requires: php(%{expand:%1}) = %{expand:%{%{!?2:%{1}}%{?2}}}
489 # macros for public use
490 # for php extensions (php-pecl)
491 %requires_php_extension %{__php_api_requires modules_api php_api_version}
492 # for zend extensions
493 %requires_zend_extension %{__php_api_requires zend_module_api} \
494 %{__php_api_requires zend_extension_api}
496 # Python specific macro definitions.
497 # python main version
498 %py_ver %(echo `python -c "import sys; print sys.version[:3]"`)
501 %py_prefix %(echo `python -c "import sys; print sys.prefix"`)
502 %py_libdir %{py_prefix}/%{_lib}/python%{py_ver}
503 %py_scriptdir %{py_prefix}/share/python%{py_ver}
504 %py_incdir /usr/include/python%{py_ver}
505 %py_sitedir %{py_libdir}/site-packages
506 %py_sitescriptdir %{py_scriptdir}/site-packages
507 %py_dyndir %{py_libdir}/lib-dynload
509 # pure python modules compilation
510 %py_comp python -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
512 %py_ocomp python -O -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
514 # Software written in Python language require Python with main version
515 %pyrequires_eq() Requires: %1
518 # Hardlink binary identical .pyc and .pyo files
519 # (idea by glen <at> pld-linux <dot> org)
520 %__spec_install_post_py_hardlink {\
521 %{!?no_install_post_py_hardlink: \
522 [ ! -d "$RPM_BUILD_ROOT" ] || find "$RPM_BUILD_ROOT" -name '*.pyc' | while read a; do \
523 b="$(echo $a|sed -e 's/.pyc$/.pyo/')"; \
524 if cmp -s "$a" "$b"; then \
530 # remove python sources, so that check-files won't complain
531 # (idea by glen <at> pld-linux <dot> org)
533 for d in %{py_sitescriptdir} %{py_sitedir} %*; do \
534 [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -print0 | xargs -0r -l512 rm;\
541 if [ -e /boot/System.map-%1 ]; then \
542 /sbin/depmod -a -F /boot/System.map-%1 %1; \
544 if [ -e /boot/System.map ]; then \
545 /sbin/depmod -a -F /boot/System.map %1; \
547 /sbin/depmod -a %1; \
552 # XMMS specific macros
553 %xmms_prefix %(xmms-config --prefix 2>/dev/null)
554 %xmms_exec_prefix %(xmms-config --exec-prefix 2>/dev/null)
555 %xmms_version %(xmms-config --version 2>/dev/null)
556 %xmms_datadir %(xmms-config --data-dir 2>/dev/null)
557 %xmms_plugindir %(xmms-config --plugin-dir 2>/dev/null)
558 %xmms_visualization_plugindir %(xmms-config --visualization-plugin-dir 2>/dev/null)
559 %xmms_input_plugindir %(xmms-config --input-plugin-dir 2>/dev/null)
560 %xmms_output_plugindir %(xmms-config --output-plugin-dir 2>/dev/null)
561 %xmms_effect_plugindir %(xmms-config --effect-plugin-dir 2>/dev/null)
562 %xmms_general_plugindir %(xmms-config --general-plugin-dir 2>/dev/null)
564 %_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/')
566 %x8664 x86_64 amd64 ia32e
568 # user/group checking macros
573 %userremove /usr/lib/rpm/user_group.sh user del
574 %groupremove /usr/lib/rpm/user_group.sh group del
577 # if %usertestrm myuser; then
578 # /usr/sbin/userdel -r myuser
580 # use these macros only if you need to call userdel/groupdel with
581 # a non-standard option or take an extra action; otherwise use the
582 # %userremove/%groupremove macros
584 %usertestrm /usr/lib/rpm/user_group.sh user testrm
585 %grouptestrm /usr/lib/rpm/user_group.sh group testrm
586 # user group membership management macros
589 # %addusertogroup myuser agroup
591 %addusertogroup /usr/lib/rpm/user_group.sh user addtogroup
593 # banner support (useful in {pre,post}{,un} and triggers)
596 # %banner name [-a] [-e] [-n] [-tn] <<EOF
597 # the banner text, the banner text
598 # the banner text, and following line
600 # You can use any form of here-document, <<'EOF' <<-EOT will do.
601 # NOTE: if your use "<<-EOF", then You can actually indent inside here-document.
603 # -a - append to the banner
604 # -e - send to stderr instead of stdout
605 # -n - no show banner (overrides -t)
606 # -t - show only, if RPM_SCRIPTVERBOSITY >= n; default n=5
608 RPM_SCRIPTVERBOSITY=5 \
609 [ -r /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm \
610 if [ -x /usr/bin/banner.sh ]; then \
611 CMD="/usr/bin/banner.sh %{-e:--stderr} %{!-n:$([ $RPM_SCRIPTVERBOSITY -ge %{-t:%{-t*}}%{!-t:5} ] && echo -s)} %{!-a:-m}%{-a:-M} %1" \
613 CMD="cat%{-e: >&2}" \
615 eval $CMD %2%{?3: %3} \
618 # useradd/groupadd macros written by glen@pld-linux.org.
619 # All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
622 # %useradd [-P package] [-u uid] [-d home_dir] [-s shell] [-c comment]
623 # [-g initial_group] [-G group[,...]] login
626 # -g gid/group. REQUIRED
627 # -s defaults to /bin/false
628 # -d defaults to /usr/share/empty
630 # -r is accepted but ignored (it's always set)
631 # -k skeleton dir. defaults to /usr/share/empty
633 # -P package name. defaults to %{name}
635 %useradd(c:d:e:f:g:G:Mmk:op:s:u:rP:) \
636 %{!-u:%{error:useradd: Required argument -u missing}} \
637 %{!-g:%{error:useradd: Required argument -g missing}} \
638 %{!?1:%{error:useradd: Required parameter login missing}} \
639 if [ -n "`/bin/id -u %{expand:%{%{#}}} 2>/dev/null`" ]; then \
640 if [ "`/bin/id -u %{expand:%{%{#}}}`" != "%{-u*}" ]; then \
641 echo "Error: user %{expand:%{%{#}}} doesn't have uid=%{-u*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
645 echo "Adding user %{expand:%{%{#}}} UID=%{-u*}." \
646 /usr/sbin/useradd \\\
647 %{-m:-m -k %{-k*}%{!-k:/usr/share/empty}} \\\
650 -d %{-d*}%{!-d:/usr/share/empty} \\\
651 -s %{-s*}%{!-s:/bin/false} \\\
652 %{-c:-c "%(set -- %{-c*} %{*}; echo $1)"}\\\
656 %{expand:%{%{#}}} 1>&2 \
660 # %groupadd [-P package] [-g gid] group
665 # %groupadd -P %{name}-base -g %{gid} %{name}
668 %{!-g:%{error:groupadd: Required argument -g missing}} \
669 %{!?1:%{error:groupadd: Required parameter group missing}} \
670 if [ -n "`/usr/bin/getgid %{1}`" ]; then \
671 if [ "`/usr/bin/getgid %{1}`" != "%{-g*}" ]; then \
672 echo "Error: group %{1} doesn't have gid=%{-g*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
676 echo "Adding group %{1} GID=%{-g*}." \
677 /usr/sbin/groupadd -g %{-g*} -r %{1} 1>&2 \
680 # apache_config_{install/uninstall} macros written by glen@pld-linux.org.
681 # All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
683 # The config is installed/removed inside trigger, this means that you can any
684 # time install apache1 or apache package and the configuration file is updated.
685 # if you don't need the config for various reason for specific apache, just
686 # remove the symlink from apache config directory. the trigger will not put the
687 # config again to that version of apache. In other words the config is linked
688 # to apache config directory on first install of PACKAGE or apache.
690 # should be called in trigger body:
691 # %triggerin -- apache1 >= 1.3.33-2
692 # %apache_config_install -v 1
694 # Add package's apache config to apache config.
697 # %apache_config_install -v {1|2} -c %{_sysconfdir}/apache-%{name}.conf -n 99
699 # -v REQUIRED: specify apache version. can be 1 or 2.
700 # -c OPTIONAL: specify full path to PACKAGE's config. Defaults to %{_sysconfdir}/apache-%{name}.conf.
701 # -n OPTIONAL: specify config "slot". defaults to 99
703 # Internal macros. don't use ;).
704 # expands apache config dir by apache version at build time.
705 %__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)
706 # expands apache service name by apache version at build time.
707 %__apache_svcname() %(if [ %{1} = 1 ]; then echo apache; elif [ %{1} = 2 ]; then echo httpd; else echo >&2 Unknown apache version specified; fi)
709 %apache_config_install(v:c:n:) \
710 %{!-v:%{error:apache_config_install: Required argument -v missing}} \
711 %{?debug:set -x; echo "apache_config_install:%{-v*} %{name}-%{version}-%{release} 1:[$1]; 2:[$2]"} \
712 if [ "$1" = "1" ] && [ "$2" = "1" ] && [ -d %{__apache_confdir %{-v*}} ]; then\
713 ln -sf %{-c*}%{!-c:%{_sysconfdir}/apache-%{name}.conf} %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf\
715 # reload apache if the config symlink is there\
716 if [ -L %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf ]; then\
717 # additionally don't reload if target package (the webserver) is upgraded, as webserver is restarted anyway in %post \
718 if [ "$2" != "2" ] && [ -f /var/lock/subsys/%{__apache_svcname %{-v*}} ]; then\
719 /etc/rc.d/init.d/%{__apache_svcname %{-v*}} reload 1>&2\
724 # Remove package's apache config from apache config.
727 # %apache_config_uninstall -v {1|2} -n 99
729 # -v REQUIRED: specify apache version. can be 1 or 2.
730 # -n OPTIONAL: specify config "slot". defaults to 99
731 %apache_config_uninstall(v:n:) \
732 %{!-v:%{error:apache_config_uninstall: Required argument -v missing}} \
733 %{?debug:set -x; echo "apache_config_uninstall:%{-v*} %{name}-%{version}-%{release}: 1:[$1]; 2:[$2]"} \
734 # remove link if either of the packages are gone \
735 if [ "$1" = "0" ] || [ "$2" = "0" ]; then \
736 if [ -L %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf ]; then \
737 rm -f %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf \
738 if [ -f /var/lock/subsys/%{__apache_svcname %{-v*}} ]; then \
739 /etc/rc.d/init.d/%{__apache_svcname %{-v*}} reload 1>&2 \
745 # see browser-plugins.spec / template-browser-plugin.spec
746 # written by glen@pld-linux.org.
747 %nsplugin_install(d:f) { \
748 # create link if it's first install of either of the packages \
749 if [ -n "%{-f:1}" ] || ([ "$1" = "1" ] && [ "$2" = "1" ] && [ -d %{-d*} ]); then \
752 for file in %{*}; do \
753 echo echo Installing $file to %{-d*}; \
754 echo "ln -sf %{_libdir}/browser-plugins/$file %{-d*};"; \
756 ) | ( %banner -t 5 -e %{name}-in ); fi; \
759 %nsplugin_uninstall(d:) { \
760 # remove link if either of the packages are gone \
761 if [ "$1" = "0" ] || [ "$2" = "0" ]; then \
764 for file in %{*}; do \
765 echo echo Removing $file from %{-d*}; \
766 echo "rm -f %{-d*}/$file;"; \
768 ) | ( %banner -t 5 -e %{name}-un ); fi; \
773 # calls usual service restart on package %post, but skips the restart if
774 # administrator has disabled automatic service restarts in either global
775 # /etc/sysconfig/rpm or per service /etc/sysconfig/SERVICE file.
777 # written by glen@pld-linux.org.
778 # All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
781 # %service [-q] SERVICE ACTION
783 # -q be silent when service isn't started (for postun scriplets)
786 # we use function, not to globber namespace with useless variables \
787 skip_auto_restart() { \
788 . /etc/sysconfig/rpm; # global setting \
789 [ -f /etc/sysconfig/%1 ] && . /etc/sysconfig/%1; # per service setting \
790 echo ${RPM_SKIP_AUTO_RESTART:-no}; \
792 if [ -f /var/lock/subsys/%1 ]; then \
793 if [ $(skip_auto_restart) = no ]; then \
794 /etc/rc.d/init.d/%1 %2 1>&2; \
796 echo 'Run "/etc/rc.d/init.d/%1 %2" to %2 %1 service.'; \
799 %{!-q:echo 'Run "/etc/rc.d/init.d/%1 start" to start %1 service.';} \