10 # Build system path macros.
12 %__autoconf autoconf %{?debug:-Wall}
13 %__automake automake -a -c -f --foreign
14 %__autopoint autopoint --force
17 if ! gettextize --version | grep -q '0\.10\.' ; then \
18 if grep -qs 'AM_GNU_GETTEXT.*external' configure.{ac,in} ; then \
19 gettextize --copy --force --no-changelog; \
21 gettextize --copy --force --no-changelog --intl; \
23 if [ ! -f po/Makevars ]; then \
24 cp -f po/Makevars{.template,}; \
27 gettextize --copy --force; \
31 %__glib_gettextize glib-gettextize --copy --force
32 %__gnome_doc_common gnome-doc-common --copy
33 %__gtkdocize gtkdocize --copy
34 %__intltoolize intltoolize --copy --force
35 %__libtoolize libtoolize --copy --force
37 %dependencytracking %{nil}
38 #-----------------------------------------------------------------
40 if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \
41 LDFLAGS="${LDFLAGS:-%rpmldflags}" ; export LDFLAGS ; \
42 CFLAGS="${CFLAGS:-%rpmcflags}" ; export CFLAGS ; \
43 CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" ; export CXXFLAGS ; \
44 FFLAGS="${FFLAGS:-%rpmcflags}" ; export FFLAGS ; \
45 CPPFLAGS="${CPPFLAGS:-}" ; export CPPFLAGS ; \
46 %{?__cc:CC="%{__cc}" ; export CC ; } \
47 %{?__cxx:CXX="%{__cxx}" ; export CXX ; } \
48 %{?configuredir:%{configuredir}}%{!?configuredir:.}/configure \
49 --host=%{_target_platform} \
51 --exec-prefix=%{_exec_prefix} \
53 --sbindir=%{_sbindir} \
54 --sysconfdir=%{_sysconfdir} \
55 --datadir=%{_datadir} \
56 --includedir=%{_includedir} \
58 --libexecdir=%{_libexecdir} \
59 --localstatedir=%{_localstatedir} \
60 --sharedstatedir=%{_sharedstatedir} \
62 --infodir=%{_infodir} \
63 --x-libraries=/usr/X11R6/%{_lib} \
64 %{dependencytracking} \
67 #----------------------------------------------------------------
68 %global configure_cache 0
69 %configure_cache_file %{buildroot}.configure.cache
71 %configure {./configure \
72 LDFLAGS="${LDFLAGS:-%rpmldflags}" \
73 CFLAGS="${CFLAGS:-%rpmcflags}" \
74 CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" \
75 FFLAGS="${FFLAGS:-%rpmcflags}" \
76 CPPFLAGS="${CPPFLAGS:-}" \
77 %{?__cc:CC="%{__cc}"} \
78 %{?__cxx:CXX="%{__cxx}"} \
79 --host=%{_target_platform} \
80 --build=%{_target_platform} \
82 --exec-prefix=%{_exec_prefix} \
84 --sbindir=%{_sbindir} \
85 --sysconfdir=%{_sysconfdir} \
86 --datadir=%{_datadir} \
87 --includedir=%{_includedir} \
89 --libexecdir=%{_libexecdir} \
90 --localstatedir=%{_localstatedir} \
91 --sharedstatedir=%{_sharedstatedir} \
93 --infodir=%{_infodir} \
94 --x-libraries=/usr/X11R6/%{_lib} \
95 %{dependencytracking} \
96 %{?configure_cache:--cache-file=%{configure_cache_file:-%{buildroot}.configure.cache}} \
99 # ------------------------------------------------------------------------
100 # Overloading of some basic macros
117 %if 0%{?_enable_debug_packages}\
118 %{?buildsubdir:%{debug_package}}\
127 # Location of autoconf macros
128 %_aclocaldir %(aclocal --print-ac-dir)
130 # Location of omf files
131 %_omf_dest_dir %(scrollkeeper-config --omfdir)
133 # Location of pkgconfig files
134 %_pkgconfigdir /usr/%{_lib}/pkgconfig
136 # Location of desktop files
137 %_desktopdir /usr/share/applications
138 %_applnkdir ERROR:_applnkdir_is_obsolete_use_desktopdir_instead
140 # Location of pixmaps for applnk/desktop files
141 %_pixmapsdir /usr/share/pixmaps
143 # Location of themable icons for applnk/desktop files
144 %_iconsdir /usr/share/icons
146 # Location of fonts directories
147 %_fontsdir /usr/share/fonts
149 # Location of Gtk and associated libraries documentation
150 %_gtkdocdir %{_defaultdocdir}/gtk-doc/html
152 # Location of KDE documentation
153 %_kdedocdir %{_defaultdocdir}/kde/HTML
156 %__unsermake /usr/share/unsermake/unsermake
159 %date %(LC_ALL="C" date +"%a %b %d %Y")
162 %tmpdir %(echo "${TMPDIR:-/tmp}")
164 # Example files, programs, scripts...
165 %_examplesdir /usr/src/examples
167 # The directory holding Linux kernel sources
168 %_kernelsrcdir /usr/src/linux
170 # If non-empty "debug" macro defined, add "dbg" suffix to release number
171 %_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
173 # Requires name = version-release
174 %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")
176 %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)")
177 %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)")
178 %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)")
179 %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)")
181 %requires_eq_to() %(LC_ALL="C" rpm -q --qf 'Requires: %1 = %%{epoch}:%%{version}\\n' %2 | sed -e 's/ (none):/ /' | grep -v "is not")
183 %apache_modules_api %(awk '/#define MODULE_MAGIC_NUMBER_MAJOR/ {print $3}' /usr/include/apache/ap_mmn.h 2>/dev/null || echo ERROR)
185 # kernel version-release handling
186 %__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))
187 %__kernel_rel %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{RELEASE}" | grep -v "is not")
188 %__kernel_rpmvr %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{VERSION}-%{RELEASE}" | grep -v "is not")
189 %_kernel_ver %{__kernel_ver}%{?with_dist_kernel:%(echo %{__kernel_ver} | grep -q -e - || echo -%{__kernel_rel})}
190 %_kernel_ver_str %(echo %{!?_without_dist_kernel:%{__kernel_rpmvr}}%{?_without_dist_kernel:%{__kernel_ver}} | sed -e 's/-/_/g')
193 %xmlcat_add() /usr/bin/xmlcatalog --noout --add nextCatalog \"\" %1 /etc/xml/catalog ;
194 %xmlcat_del() /usr/bin/xmlcatalog --noout --del %1 /etc/xml/catalog ;
195 %xmlcat_add_rewrite /usr/bin/xmlcatalog --noout --add rewriteSystem
196 %xmlcat_create() /usr/bin/xmlcatalog --noout --create %1 ;
197 %sgmlcat_add() /usr/bin/install-catalog --add %1 %2 > /dev/null ;
198 %sgmlcat_del() /usr/bin/install-catalog --remove %1 %2 > /dev/null ;
199 %docbook_sgmlcat_fix() { for l in \
201 ' -- default decl --' \
202 'DTDDECL "-//OASIS//DTD DocBook XML V%2//EN" "../../xml.dcl"' \
203 ' -- hacks for opensp --' \
204 'SYSTEM "file://%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
205 'SYSTEM "http://www.oasis-open.org/docbook/xml/%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
207 ; do echo $l; done >> %1 \
210 #-----------------------------------------------------------------
211 # find and gzip all files in %{_mandir} and %{infodir}
213 # Requires: xargs, find
215 #%no_install_post_compress_docs 1
216 %__spec_install_post_compress_docs { \
217 %{!?no_install_post_compress_docs: \
218 echo "Compress man and info pages."; \
219 %{?verbose:set -x;} \
220 for i in /usr/share/man /usr/X11R6/man /usr/share/info; do \
221 if [ -d "$RPM_BUILD_ROOT$i" ]; then \
222 find "$RPM_BUILD_ROOT$i" -name \*.bz2 -print | xargs -r %{__bzip2} -df; \
223 find "$RPM_BUILD_ROOT$i" -name \*.gz -print | xargs -r %{__gzip} -dnf; \
224 find "$RPM_BUILD_ROOT$i" -type f -print | xargs -r %{__gzip} -9nf; \
229 #-----------------------------------------------------------------
230 # Strip executable binaries and shared object files
232 # Requires: find, awk, strip, cut, xargs
234 #%no_install_post_strip 1
235 %__spec_install_post_strip {%{!?debug: \
236 %{!?no_install_post_strip: \
237 %{?verbose:set -x;} \
238 if [ -d "$RPM_BUILD_ROOT" ]; then \
239 echo "Strip executable binaries, archives and shared object files."; \
240 filelist=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" ! -regex ".*/usr/lib[0-9]*/debug/.*\.debug" %{?_noautostrip:! -regex "%{_noautostrip}"}`; \
241 elfexelist=`echo $filelist | xargs -r file | \
242 awk '/ELF.*executable/ {print $1}' | cut -d: -f1`; \
243 elfsharedlist=`echo $filelist | xargs -r file | \
244 awk '/LF.*shared object/ {print $1}' | cut -d: -f1`; \
245 elfarchiveslist=`echo $filelist | xargs -r file | \
246 awk '/current ar archive/ {print $1}' | cut -d: -f1`; \
247 if [ -n "$elfexelist" ]; then \
248 %{__strip} --remove-section=.note --remove-section=.comment $elfexelist; \
250 if [ -n "$elfsharedlist" ]; then \
251 %{__strip} --strip-unneeded --remove-section=.note --remove-section=.comment $elfsharedlist; \
253 if [ -n "$elfarchiveslist" ]; then \
254 %{__strip} --strip-debug --remove-section=.note --remove-section=.comment $elfarchiveslist; \
258 #-----------------------------------------------------------------
259 # remove all RPATH from executable binaries and shared object files
261 # Requires: find, awk, cut, xargs, chrpath, uname
263 #%no_install_post_chrpath 1
264 %__spec_install_post_chrpath {%{!?debug: \
265 %{!?no_install_post_chrpath: \
266 %{?verbose:set -x;} \
267 if [ -d "$RPM_BUILD_ROOT" ]; then \
268 echo "Remove RPATH from executable binaries and shared object files."; \
269 find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" ! -regex ".*/usr/lib[0-9]*/debug/.*" %{?_noautochrpath:! -regex "%{_noautochrpath}"} | xargs -r file | \
270 awk '/ELF.*(executable.*dynamically linked|shared object)/ {print $1}' | cut -d: -f1 | \
271 while read file ; do \
274 for dir in `chrpath -l "$file" | \
275 awk '/RPATH=/ { gsub(/.*RPATH=/,""); gsub(/:/," "); print $0 }'` ; do \
277 /home/* | /tmp/* | /usr/lib | /usr/lib64 | /lib | /lib64 | /usr/local/lib | /usr/local/lib64 | /usr/X11R6/lib | /usr/X11R6/lib64 ) \
278 echo "remove-rpath: $dir in $file"; \
281 if [ "$rpath" = "" ] ; then rpath="$dir" ; \
282 else rpath="$rpath:$dir" ; fi ; \
286 if [ "$rpath" = "" ] ; then chrpath -d "$file" > /dev/null ; \
287 else chrpath -r "$rpath" "$file" > /dev/null ; fi ; \
291 #-----------------------------------------------------------------
292 # Find and gzip all kernel modules
296 #%no_install_post_compress_modules 1
297 %__spec_install_post_compress_modules { \
298 %{!?no_install_post_compress_modules: \
299 %{?verbose:set -x;} \
300 if [ -d "$RPM_BUILD_ROOT" ]; then \
301 echo "Compress kernel modules if any."; \
302 if test -d $RPM_BUILD_ROOT/lib/modules ; then \
303 find $RPM_BUILD_ROOT/lib/modules -name \*o -type f -print | \
304 xargs -r %{__gzip} -9nf; \
305 find $RPM_BUILD_ROOT/lib/modules -name \*o -type l -printf "%p %l\n" | \
306 while read a b; do ln -sf $b.gz $a.gz; rm -f $a; done; \
311 %_source_payload w9.gzdio
312 %_binary_payload w9.bzdio
314 #-----------------------------------------------------------------
315 # Update GConf2 schemas
319 %gconf_schema_install() \
321 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 \
324 %gconf_schema_uninstall() \
325 if [ $1 = 0 ]; then \
327 GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" /usr/bin/gconftool-2 --makefile-uninstall-rule /etc/gconf/schemas/%{?1} > /dev/null \
331 #-----------------------------------------------------------------
332 # Update desktop MIME database
333 # requires: desktop-file-utils
335 %update_desktop_database_post() {{ \
337 /usr/bin/update-desktop-database; \
340 %update_desktop_database_postun() {{ \
341 if [ $1 = 0 ]; then \
343 /usr/bin/update-desktop-database; \
347 #-----------------------------------------------------------------
348 # Update scrollkeeper database
349 # requires: scrollkeeper
351 %scrollkeeper_update_post() \
352 /usr/bin/scrollkeeper-update -q; \
355 %scrollkeeper_update_postun() \
356 if [ $1 = 0 ]; then \
357 /usr/bin/scrollkeeper-update -q; \
361 #-----------------------------------------------------------------
362 # Run ldconfig after installing/deinstalling libraries
372 #-----------------------------------------------------------------
373 # post %install sequence:
374 # - autodeps exceptions
375 # - compress all man and info pages,
376 # - strip all ELF executables and ELF shared objects if not %debug.
377 # - compress kernel modules if any
379 ###################################################################
380 # Requires/Provides automation
381 # exceptions system by Jacek Konieczny <jajcus@pld.org.pl>
383 %__noautoreqfiles %(sed -e s'/#.*//' /etc/rpm/noautoreqfiles)%{?_noautoreqfiles: %{_noautoreqfiles}}
384 %__noautoprovfiles %(sed -e s'/#.*//' /etc/rpm/noautoprovfiles)%{?_noautoprovfiles: %{_noautoprovfiles}}
385 %__noautoreq %(sed -e s'/#.*//' /etc/rpm/noautoreq)%{?_noautoreq: %{_noautoreq}}
386 %__noautoreqdep %(sed -e s'/#.*//' /etc/rpm/noautoreqdep)%{?_noautoreqdep: %{_noautoreqdep}}
387 %__noautoprov %(sed -e s'/#.*//' /etc/rpm/noautoprov)%{?_noautoprov: %{_noautoprov}}
388 #%_noautocompressdoc %{nil}
390 %_missing_doc_files_terminate_build 1%{nil}
391 %_unpackaged_files_terminate_build %{nil}
393 %___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;}'
394 %_emacs_lispdir %(emacs %___emacs_lispdir_helper)
395 %_xemacs_lispdir %(xemacs %___emacs_lispdir_helper)
397 %__php_provides %{nil}
398 %__php_requires %{nil}
399 %__perl_provides %{nil}
400 %__perl_requires %{nil}
401 %__mono_provides %{nil}
402 %__mono_requires %{nil}
404 # Perl specific macro definitions.
405 %perl_privlib %(eval "`%{__perl} -V:installprivlib`"; echo $installprivlib)
406 %perl_archlib %(eval "`%{__perl} -V:installarchlib`"; echo $installarchlib)
407 %perl_vendorlib %(eval "`%{__perl} -V:installvendorlib`"; echo $installvendorlib)
408 %perl_vendorarch %(eval "`%{__perl} -V:installvendorarch`"; echo $installvendorarch)
409 %perl_sitelib %(eval "`%{__perl} -V:installsitelib`"; echo $installsitelib)
410 %perl_sitearch %(eval "`%{__perl} -V:installsitearch`"; echo $installsitearch)
412 %php_pear_dir %{_datadir}/pear
414 # directory where php includes are installed on system.
415 %__php_includedir /usr/include/php
416 # extract php/zend api versions
417 %php_major_version %(awk '/#define PHP_MAJOR_VERSION/{print $3}' %{__php_includedir}/main/php_version.h 2>/dev/null || echo ERROR)
418 %php_api_version %(awk '/#define PHP_API_VERSION/{print $3}' %{__php_includedir}/main/php.h 2>/dev/null || echo ERROR)
419 %php_debug %(awk '/#define ZEND_DEBUG/{print $3}' %{__php_includedir}/main/php_config.h 2>/dev/null || echo ERROR)
420 %zend_module_api %(awk '/#define ZEND_MODULE_API_NO/{print $3}' %{__php_includedir}/Zend/zend_modules.h 2>/dev/null || echo ERROR)
421 %zend_extension_api %(awk '/#define ZEND_EXTENSION_API_NO/{print $3}' %{__php_includedir}/Zend/zend_extensions.h 2>/dev/null || echo ERROR)
422 %zend_zts %(Z=$(grep -sc '^#define ZTS 1' %{__php_includedir}/main/php_config.h); echo ${Z:-ERROR})
425 %__php_api_requires(v:) Requires: php%{-v*}(%{expand:%1}) = %{expand:%{%{!?2:%{1}}%{?2}}}
427 # macros for public use
428 # for php extensions (php-pecl)
429 %requires_php_extension %{__php_api_requires modules_api php_api_version} \
430 %{__php_api_requires -v %php_major_version debug php_debug} \
431 %{__php_api_requires -v %php_major_version thread-safety zend_zts}
433 # for zend extensions
434 %requires_zend_extension %{__php_api_requires zend_module_api} \
435 %{__php_api_requires zend_extension_api} \
436 %{__php_api_requires -v %php_major_version debug php_debug} \
437 %{__php_api_requires -v %php_major_version thread-safety zend_zts}
439 # Python specific macro definitions.
440 # python main version
441 %py_ver %(echo `python -c "import sys; print sys.version[:3]"`)
444 %py_prefix %(echo `python -c "import sys; print sys.prefix"`)
445 %py_libdir %{py_prefix}/%{_lib}/python%{py_ver}
446 %py_scriptdir %{py_prefix}/share/python%{py_ver}
447 %py_incdir /usr/include/python%{py_ver}
448 %py_sitedir %{py_libdir}/site-packages
449 %py_sitescriptdir %{py_scriptdir}/site-packages
450 %py_dyndir %{py_libdir}/lib-dynload
452 # pure python modules compilation
453 %py_comp python -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
455 %py_ocomp python -O -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
457 # Software written in Python language require Python with main version
458 %pyrequires_eq() Requires: %1
461 # Hardlink binary identical .pyc and .pyo files
462 # (idea by glen <at> pld-linux <dot> org)
463 %__spec_install_post_py_hardlink {\
464 %{!?no_install_post_py_hardlink: \
465 [ ! -d "$RPM_BUILD_ROOT" ] || find "$RPM_BUILD_ROOT" -name '*.pyc' | while read a; do \
466 b="$(echo $a|sed -e 's/.pyc$/.pyo/')"; \
467 if cmp -s "$a" "$b"; then \
473 # remove python sources, so that check-files won't complain
474 # (idea by glen <at> pld-linux <dot> org)
476 for d in %{py_sitescriptdir} %{py_sitedir} %*; do \
477 [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -print0 | xargs -0r -l512 rm;\
484 if [ -e /boot/System.map-%1 ]; then \
485 /sbin/depmod -a -F /boot/System.map-%1 %1; \
487 if [ -e /boot/System.map ]; then \
488 /sbin/depmod -a -F /boot/System.map %1; \
490 /sbin/depmod -a %1; \
495 # XMMS specific macros
496 %xmms_prefix %(xmms-config --prefix 2>/dev/null)
497 %xmms_exec_prefix %(xmms-config --exec-prefix 2>/dev/null)
498 %xmms_version %(xmms-config --version 2>/dev/null)
499 %xmms_datadir %(xmms-config --data-dir 2>/dev/null)
500 %xmms_plugindir %(xmms-config --plugin-dir 2>/dev/null)
501 %xmms_visualization_plugindir %(xmms-config --visualization-plugin-dir 2>/dev/null)
502 %xmms_input_plugindir %(xmms-config --input-plugin-dir 2>/dev/null)
503 %xmms_output_plugindir %(xmms-config --output-plugin-dir 2>/dev/null)
504 %xmms_effect_plugindir %(xmms-config --effect-plugin-dir 2>/dev/null)
505 %xmms_general_plugindir %(xmms-config --general-plugin-dir 2>/dev/null)
507 %_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/')
509 %x8664 x86_64 amd64 ia32e
511 # user/group checking macros
516 %userremove /usr/lib/rpm/user_group.sh user del
517 %groupremove /usr/lib/rpm/user_group.sh group del
520 # if %usertestrm myuser; then
521 # /usr/sbin/userdel -r myuser
523 # use these macros only if you need to call userdel/groupdel with
524 # a non-standard option or take an extra action; otherwise use the
525 # %userremove/%groupremove macros
527 %usertestrm /usr/lib/rpm/user_group.sh user testrm
528 %grouptestrm /usr/lib/rpm/user_group.sh group testrm
529 # user group membership management macros
532 # %addusertogroup myuser agroup
534 %addusertogroup /usr/lib/rpm/user_group.sh user addtogroup
536 # banner support (useful in {pre,post}{,un} and triggers)
539 # %banner name [-a] [-e] [-n] [-tn] <<EOF
540 # the banner text, the banner text
541 # the banner text, and following line
543 # You can use any form of here-document, <<'EOF' <<-EOT will do.
544 # NOTE: if your use "<<-EOF", then You can actually indent inside here-document.
546 # -a - append to the banner
547 # -e - send to stderr instead of stdout
548 # -n - no show banner (overrides -t)
549 # -t - show only, if RPM_SCRIPTVERBOSITY >= n; default n=5
551 RPM_SCRIPTVERBOSITY=5 \
552 [ -r /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm \
553 if [ -x /usr/bin/banner.sh ]; then \
554 CMD="/usr/bin/banner.sh %{-e:--stderr} %{!-n:$([ $RPM_SCRIPTVERBOSITY -ge %{-t:%{-t*}}%{!-t:5} ] && echo -s)} %{!-a:-m}%{-a:-M} %1" \
556 CMD="cat%{-e: >&2}" \
558 eval $CMD %2%{?3: %3} \
561 # useradd/groupadd macros written by glen@pld-linux.org.
562 # All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
565 # %useradd [-P package] [-u uid] [-d home_dir] [-s shell] [-c comment]
566 # [-g initial_group] [-G group[,...]] login
569 # -g gid/group. REQUIRED
570 # -s defaults to /bin/false
571 # -d defaults to /usr/share/empty
573 # -r is accepted but ignored (it's always set)
574 # -k skeleton dir. defaults to /usr/share/empty
576 # -P package name. defaults to %{name}
578 %useradd(c:d:e:f:g:G:Mmk:op:s:u:rP:) \
579 %{!-u:%{error:useradd: Required argument -u missing}} \
580 %{!-g:%{error:useradd: Required argument -g missing}} \
581 %{!?1:%{error:useradd: Required parameter login missing}} \
582 if [ -n "`/bin/id -u %{expand:%{%{#}}} 2>/dev/null`" ]; then \
583 if [ "`/bin/id -u %{expand:%{%{#}}}`" != "%{-u*}" ]; then \
584 echo "Error: user %{expand:%{%{#}}} doesn't have uid=%{-u*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
588 echo "Adding user %{expand:%{%{#}}} UID=%{-u*}." \
589 /usr/sbin/useradd \\\
590 %{-m:-m -k %{-k*}%{!-k:/usr/share/empty}} \\\
593 -d %{-d*}%{!-d:/usr/share/empty} \\\
594 -s %{-s*}%{!-s:/bin/false} \\\
595 %{-c:-c "%(set -- %{-c*} %{*}; echo $1)"}\\\
599 %{expand:%{%{#}}} 1>&2 \
603 # %groupadd [-P package] [-g gid] group
608 # %groupadd -P %{name}-base -g %{gid} %{name}
611 %{!-g:%{error:groupadd: Required argument -g missing}} \
612 %{!?1:%{error:groupadd: Required parameter group missing}} \
613 if [ -n "`/usr/bin/getgid %{1}`" ]; then \
614 if [ "`/usr/bin/getgid %{1}`" != "%{-g*}" ]; then \
615 echo "Error: group %{1} doesn't have gid=%{-g*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
619 echo "Adding group %{1} GID=%{-g*}." \
620 /usr/sbin/groupadd -g %{-g*} -r %{1} 1>&2 \
623 # apache_config_{install/uninstall} macros written by glen@pld-linux.org.
624 # All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
626 # The config is installed/removed inside trigger, this means that you can any
627 # time install apache1 or apache package and the configuration file is updated.
628 # if you don't need the config for various reason for specific apache, just
629 # remove the symlink from apache config directory. the trigger will not put the
630 # config again to that version of apache. In other words the config is linked
631 # to apache config directory on first install of PACKAGE or apache.
633 # should be called in trigger body:
634 # %triggerin -- apache1 >= 1.3.33-2
635 # %apache_config_install -v 1
637 # Add package's apache config to apache config.
640 # %apache_config_install -v {1|2} -c %{_sysconfdir}/apache-%{name}.conf -n 99
642 # -v REQUIRED: specify apache version. can be 1 or 2.
643 # -c OPTIONAL: specify full path to PACKAGE's config. Defaults to %{_sysconfdir}/apache-%{name}.conf.
644 # -n OPTIONAL: specify config "slot". defaults to 99
646 # Internal macros. don't use ;).
647 # expands apache config dir by apache version at build time.
648 %__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)
649 # expands apache service name by apache version at build time.
650 %__apache_svcname() %(if [ %{1} = 1 ]; then echo apache; elif [ %{1} = 2 ]; then echo httpd; else echo >&2 Unknown apache version specified; fi)
652 %apache_config_install(v:c:n:) \
653 %{!-v:%{error:apache_config_install: Required argument -v missing}} \
654 %{?debug:set -x; echo "apache_config_install:%{-v*} %{name}-%{version}-%{release} 1:[$1]; 2:[$2]"} \
655 if [ "$1" = "1" ] && [ "$2" = "1" ] && [ -d %{__apache_confdir %{-v*}} ]; then\
656 ln -sf %{-c*}%{!-c:%{_sysconfdir}/apache-%{name}.conf} %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf\
658 # reload apache if the config symlink is there\
659 if [ -L %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf ]; then\
660 # additionally don't reload if target package (the webserver) is upgraded, as webserver is restarted anyway in %post \
661 if [ "$2" != "2" ] && [ -f /var/lock/subsys/%{__apache_svcname %{-v*}} ]; then\
662 /etc/rc.d/init.d/%{__apache_svcname %{-v*}} reload 1>&2\
667 # Remove package's apache config from apache config.
670 # %apache_config_uninstall -v {1|2} -n 99
672 # -v REQUIRED: specify apache version. can be 1 or 2.
673 # -n OPTIONAL: specify config "slot". defaults to 99
674 %apache_config_uninstall(v:n:) \
675 %{!-v:%{error:apache_config_uninstall: Required argument -v missing}} \
676 %{?debug:set -x; echo "apache_config_uninstall:%{-v*} %{name}-%{version}-%{release}: 1:[$1]; 2:[$2]"} \
677 # remove link if either of the packages are gone \
678 if [ "$1" = "0" ] || [ "$2" = "0" ]; then \
679 if [ -L %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf ]; then \
680 rm -f %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf \
681 if [ -f /var/lock/subsys/%{__apache_svcname %{-v*}} ]; then \
682 /etc/rc.d/init.d/%{__apache_svcname %{-v*}} reload 1>&2 \
688 # see browser-plugins.spec / template-browser-plugin.spec
689 # written by glen@pld-linux.org.
690 %nsplugin_install(d:f) { \
691 # create link if it's first install of either of the packages \
692 if [ -n "%{-f:1}" ] || ([ "$1" = "1" ] && [ "$2" = "1" ] && [ -d %{-d*} ]); then \
695 for file in %{*}; do \
696 echo echo Installing $file to %{-d*}; \
697 echo "ln -sf %{_libdir}/browser-plugins/$file %{-d*};"; \
699 ) | ( %banner -t 5 -e %{name}-in ); fi; \
702 %nsplugin_uninstall(d:) { \
703 # remove link if either of the packages are gone \
704 if [ "$1" = "0" ] || [ "$2" = "0" ]; then \
707 for file in %{*}; do \
708 echo echo Removing $file from %{-d*}; \
709 echo "rm -f %{-d*}/$file;"; \
711 ) | ( %banner -t 5 -e %{name}-un ); fi; \
716 # calls usual service restart on package %post, but skips the restart if
717 # administrator has disabled automatic service restarts in either global
718 # /etc/sysconfig/rpm or per service /etc/sysconfig/SERVICE file.
720 # written by glen@pld-linux.org.
721 # All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
724 # %service [-q] SERVICE ACTION ["SERVICE NICE DESCRIPTION"]
726 # -q be silent when service isn't started (for postun scriplets)
729 # we use function, not to globber namespace with useless variables \
730 skip_auto_restart() { \
731 . /etc/sysconfig/rpm; # global setting \
732 [ -f /etc/sysconfig/%1 ] && . /etc/sysconfig/%1; # per service setting \
733 echo ${RPM_SKIP_AUTO_RESTART:-no}; \
735 if [ -f /var/lock/subsys/%1 ]; then \
736 if [ $(skip_auto_restart) = no ]; then \
737 /etc/rc.d/init.d/%1 %2 1>&2; \
739 echo 'Run "/etc/rc.d/init.d/%1 %2" to %2 %{!?3:%1 service}%{?3:%(set -- %{*}; echo "$3")}.'; \
742 %{!-q:echo 'Run "/etc/rc.d/init.d/%1 start" to start %{!?3:%1 service}%{?3:%(set -- %{*}; echo "$3")}.';} \