5 %_enable_debug_packages 0
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 %{?debug:%debugcflags}%{!?debug:%optflags}%{?debuginfocflags}
30 # Build system path macros.
32 %__autoconf autoconf %{?debug:-Wall}
33 %__automake automake -a -c -f --foreign
34 %__autopoint autopoint --force
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; \
41 gettextize --copy --force --no-changelog --intl; \
43 if [ ! -f po/Makevars ]; then \
44 cp -f po/Makevars{.template,}; \
47 gettextize --copy --force; \
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
57 %dependencytracking %{nil}
58 #-----------------------------------------------------------------
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} \
71 --exec-prefix=%{_exec_prefix} \
73 --sbindir=%{_sbindir} \
74 --sysconfdir=%{_sysconfdir} \
75 --datadir=%{_datadir} \
76 --includedir=%{_includedir} \
78 --libexecdir=%{_libexecdir} \
79 --localstatedir=%{_localstatedir} \
80 --sharedstatedir=%{_sharedstatedir} \
82 --infodir=%{_infodir} \
83 --x-libraries=/usr/X11R6/%{_lib} \
84 %{dependencytracking} \
87 #----------------------------------------------------------------
88 %global configure_cache 0
89 %configure_cache_file %{buildroot}.configure.cache
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}} \
118 # ------------------------------------------------------------------------
119 # Overloading of some basic macros
135 %install %{?_enable_debug_packages:%{?buildsubdir:%{debug_package}}}\
143 # ------------------------------------------------------------------------
144 # Conditional build stuff.
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}}
151 # Shorthand for %{defined with_...}
152 %with() %{expand:%%{?with_%{1}:1}%%{!?with_%{1}:0}}
153 %without() %{expand:%%{?with_%{1}:0}%%{!?with_%{1}:1}}
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.
159 # %bcond_with foo defines symbol with_foo if --with foo was specified on
161 # %bcond_without foo defines symbol with_foo if --without foo was *not*
162 # specified on command line.
166 # %bcond_with extra_fonts
167 # %bcond_without static
168 # %if %{with extra_fonts}
171 # %ifdef %{with static}
174 # %{?with_static: ... }
175 # %{!?with_static: ... }
176 # %{?with_extra_fonts: ... }
177 # %{!?with_extra_fonts: ... }
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 # ------------------------------------------------------------------------
186 # Location of autoconf macros
187 %_aclocaldir %(aclocal --print-ac-dir)
189 # Location of omf files
190 %_omf_dest_dir %(scrollkeeper-config --omfdir)
192 # Location of pkgconfig files
193 %_pkgconfigdir /usr/%{_lib}/pkgconfig
195 # Location of desktop files
196 %_desktopdir /usr/share/applications
197 %_applnkdir ERROR:_applnkdir_is_obsolete_use_desktopdir_instead
199 # Location of pixmaps for applnk/desktop files
200 %_pixmapsdir /usr/share/pixmaps
202 # Location of themable icons for applnk/desktop files
203 %_iconsdir /usr/share/icons
205 # Location of fonts directories
206 %_fontsdir /usr/share/fonts
208 # Location of Gtk and associated libraries documentation
209 %_gtkdocdir %{_defaultdocdir}/gtk-doc/html
211 # Location of KDE documentation
212 %_kdedocdir %{_defaultdocdir}/kde/HTML
215 %__unsermake /usr/share/unsermake/unsermake
218 %date %(LC_ALL="C" date +"%a %b %d %Y")
221 %tmpdir %(echo "${TMPDIR:-/tmp}")
223 # Example files, programs, scripts...
224 %_examplesdir /usr/src/examples
226 # The directory holding Linux kernel sources
227 %_kernelsrcdir /usr/src/linux
229 # If non-empty "debug" macro defined, add "dbg" suffix to release number
230 %_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
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")
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)")
240 %requires_eq_to() %(LC_ALL="C" rpm -q --qf 'Requires: %1 = %%{epoch}:%%{version}\\n' %2 | sed -e 's/ (none):/ /' | grep -v "is not")
242 %apache_modules_api %(awk '/#define MODULE_MAGIC_NUMBER_MAJOR/ {print $3}' /usr/include/apache/ap_mmn.h 2>/dev/null || echo ERROR)
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')
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 \
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"' \
266 ; do echo $l; done >> %1 \
269 #-----------------------------------------------------------------
270 # find and gzip all files in %{_mandir} and %{infodir}
272 # Requires: xargs, find
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; \
288 #-----------------------------------------------------------------
289 # Strip executable binaries and shared object files
291 # Requires: find, awk, strip, cut, xargs
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; \
309 if [ -n "$elfsharedlist" ]; then \
310 %{__strip} --strip-unneeded --remove-section=.note --remove-section=.comment $elfsharedlist; \
312 if [ -n "$elfarchiveslist" ]; then \
313 %{__strip} --strip-debug --remove-section=.note --remove-section=.comment $elfarchiveslist; \
317 #-----------------------------------------------------------------
318 # remove all RPATH from executable binaries and shared object files
320 # Requires: find, awk, cut, xargs, chrpath, uname
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 \
333 for dir in `chrpath -l "$file" | \
334 awk '/RPATH=/ { gsub(/.*RPATH=/,""); gsub(/:/," "); print $0 }'` ; do \
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"; \
340 if [ "$rpath" = "" ] ; then rpath="$dir" ; \
341 else rpath="$rpath:$dir" ; fi ; \
345 if [ "$rpath" = "" ] ; then chrpath -d "$file" > /dev/null ; \
346 else chrpath -r "$rpath" "$file" > /dev/null ; fi ; \
350 #-----------------------------------------------------------------
351 # Find and gzip all kernel modules
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; \
370 %_source_payload w9.gzdio
371 %_binary_payload w9.bzdio
373 #-----------------------------------------------------------------
374 # Update GConf2 schemas
378 %gconf_schema_install() \
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 \
383 %gconf_schema_uninstall() \
384 if [ $1 = 0 ]; then \
386 GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" /usr/bin/gconftool-2 --makefile-uninstall-rule /etc/gconf/schemas/%{?1} > /dev/null \
390 #-----------------------------------------------------------------
391 # Update desktop MIME database
392 # requires: desktop-file-utils
394 %update_desktop_database_post() {{ \
396 /usr/bin/update-desktop-database; \
399 %update_desktop_database_postun() {{ \
400 if [ $1 = 0 ]; then \
402 /usr/bin/update-desktop-database; \
406 #-----------------------------------------------------------------
407 # Update scrollkeeper database
408 # requires: scrollkeeper
410 %scrollkeeper_update_post() \
411 /usr/bin/scrollkeeper-update -q; \
414 %scrollkeeper_update_postun() \
415 if [ $1 = 0 ]; then \
416 /usr/bin/scrollkeeper-update -q; \
420 #-----------------------------------------------------------------
421 # Run ldconfig after installing/deinstalling libraries
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
438 ###################################################################
439 # Requires/Provides automation
440 # exceptions system by Jacek Konieczny <jajcus@pld.org.pl>
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}
449 %_missing_doc_files_terminate_build 1%{nil}
450 %_unpackaged_files_terminate_build %{nil}
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)
456 %__php_provides %{nil}
457 %__php_requires %{nil}
458 %__perl_provides %{nil}
459 %__perl_requires %{nil}
460 %__mono_provides %{nil}
461 %__mono_requires %{nil}
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)
471 %php_pear_dir %{_datadir}/pear
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)
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)
485 %__php_api_requires() Requires: php(%{expand:%1}) = %{expand:%{%{!?2:%{1}}%{?2}}}
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}
494 # Python specific macro definitions.
495 # python main version
496 %py_ver %(echo `python -c "import sys; print sys.version[:3]"`)
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
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'):])"
510 %py_ocomp python -O -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
512 # Software written in Python language require Python with main version
513 %pyrequires_eq() Requires: %1
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 \
528 # remove python sources, so that check-files won't complain
529 # (idea by glen <at> pld-linux <dot> org)
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;\
539 if [ -e /boot/System.map-%1 ]; then \
540 /sbin/depmod -a -F /boot/System.map-%1 %1; \
542 if [ -e /boot/System.map ]; then \
543 /sbin/depmod -a -F /boot/System.map %1; \
545 /sbin/depmod -a %1; \
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)
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/')
564 %x8664 x86_64 amd64 ia32e
566 # user/group checking macros
571 %userremove /usr/lib/rpm/user_group.sh user del
572 %groupremove /usr/lib/rpm/user_group.sh group del
575 # if %usertestrm myuser; then
576 # /usr/sbin/userdel -r myuser
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
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
587 # %addusertogroup myuser agroup
589 %addusertogroup /usr/lib/rpm/user_group.sh user addtogroup
591 # banner support (useful in {pre,post}{,un} and triggers)
594 # %banner name [-a] [-e] [-n] [-tn] <<EOF
595 # the banner text, the banner text
596 # the banner text, and following line
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.
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
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" \
611 CMD="cat%{-e: >&2}" \
613 eval $CMD %2%{?3: %3} \
616 # useradd/groupadd macros written by glen@pld-linux.org.
617 # All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
620 # %useradd [-P package] [-u uid] [-d home_dir] [-s shell] [-c comment]
621 # [-g initial_group] [-G group[,...]] login
624 # -g gid/group. REQUIRED
625 # -s defaults to /bin/false
626 # -d defaults to /usr/share/empty
628 # -r is accepted but ignored (it's always set)
630 # -P package name. defaults to %{name}
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 \
642 echo "Adding user %{expand:%{%{#}}} UID=%{-u*}." \
643 /usr/sbin/useradd \\\
646 -d %{-d*}%{!-d:/usr/share/empty} \\\
647 -s %{-s*}%{!-s:/bin/false} \\\
648 %{-c:-c "%(set -- %{-c*} %{*}; echo $1)"}\\\
652 %{expand:%{%{#}}} 1>&2 \
656 # %groupadd [-P package] [-g gid] group
661 # %groupadd -P %{name}-base -g %{gid} %{name}
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 \
672 echo "Adding group %{1} GID=%{-g*}." \
673 /usr/sbin/groupadd -g %{-g*} -r %{1} 1>&2 \
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
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.
686 # should be called in trigger body:
687 # %triggerin -- apache1 >= 1.3.33-2
688 # %apache_config_install -v 1
690 # Add package's apache config to apache config.
693 # %apache_config_install -v {1|2} -c %{_sysconfdir}/apache-%{name}.conf -n 99
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
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)
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\
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\
720 # Remove package's apache config from apache config.
723 # %apache_config_uninstall -v {1|2} -n 99
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 \
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 \
748 for file in %{*}; do \
749 echo echo Installing $file to %{-d*}; \
750 echo "ln -sf %{_libdir}/browser-plugins/$file %{-d*};"; \
752 ) | ( %banner -t 5 -e %{name}-in ); fi; \
755 %nsplugin_uninstall(d:) { \
756 # remove link if either of the packages are gone \
757 if [ "$1" = "0" ] || [ "$2" = "0" ]; then \
760 for file in %{*}; do \
761 echo echo Removing $file from %{-d*}; \
762 echo "rm -f %{-d*}/$file;"; \
764 ) | ( %banner -t 5 -e %{name}-un ); fi; \
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.
773 # written by glen@pld-linux.org.
774 # All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
777 # %service [-q] SERVICE ACTION
779 # -q be silent when service isn't started (for postun scriplets)
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}; \
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; \
792 echo 'Run "/etc/rc.d/init.d/%1 %2" to %2 %1 service.'; \
795 %{!-q:echo 'Run "/etc/rc.d/init.d/%1 start" to start %1 service.';} \