+#
+%__noautoreqfiles %(sed -e s'/#.*//' /etc/rpm/noautoreqfiles)%{?_noautoreqfiles: %{_noautoreqfiles}}
+%__noautoprovfiles %(sed -e s'/#.*//' /etc/rpm/noautoprovfiles)%{?_noautoprovfiles: %{_noautoprovfiles}}
+%__noautoreq %(sed -e s'/#.*//' /etc/rpm/noautoreq)%{?_noautoreq: %{_noautoreq}}
+%__noautoreqdep %(sed -e s'/#.*//' /etc/rpm/noautoreqdep)%{?_noautoreqdep: %{_noautoreqdep}}
+%__noautoprov %(sed -e s'/#.*//' /etc/rpm/noautoprov)%{?_noautoprov: %{_noautoprov}}
+#%_noautocompressdoc %{nil}
+#
+%_missing_doc_files_terminate_build 1%{nil}
+%_unpackaged_files_terminate_build %{nil}
+# (X)emacs support
+%___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;}'
+%_emacs_lispdir %(emacs %___emacs_lispdir_helper)
+%_xemacs_lispdir %(xemacs %___emacs_lispdir_helper)
+
+%__php_provides %{nil}
+%__php_requires %{nil}
+%__perl_provides %{nil}
+%__perl_requires %{nil}
+%__mono_provides %{nil}
+%__mono_requires %{nil}
+
+# Perl specific macro definitions.
+%perl_privlib %(eval "`%{__perl} -V:installprivlib`"; echo $installprivlib)
+%perl_archlib %(eval "`%{__perl} -V:installarchlib`"; echo $installarchlib)
+%perl_vendorlib %(eval "`%{__perl} -V:installvendorlib`"; echo $installvendorlib)
+%perl_vendorarch %(eval "`%{__perl} -V:installvendorarch`"; echo $installvendorarch)
+%perl_sitelib %(eval "`%{__perl} -V:installsitelib`"; echo $installsitelib)
+%perl_sitearch %(eval "`%{__perl} -V:installsitearch`"; echo $installsitearch)
+
+# Ruby
+%ruby_archdir %(ruby -r rbconfig -e 'print Config::CONFIG["archdir"]' 2>/dev/null || echo ERROR)
+%ruby_ridir %(ruby -r rbconfig -e 'include Config; print File.join(CONFIG["datadir"], "ri", CONFIG["ruby_version"], "system")' 2>/dev/null || echo ERROR)
+%ruby_rubylibdir %(ruby -r rbconfig -e 'print Config::CONFIG["rubylibdir"]' 2>/dev/null || echo ERROR)
+%ruby_sitearchdir %(ruby -r rbconfig -e 'print Config::CONFIG["sitearchdir"]' 2>/dev/null || echo ERROR)
+%ruby_sitelibdir %(ruby -r rbconfig -e 'print Config::CONFIG["sitelibdir"]' 2>/dev/null || echo ERROR)
+%ruby_version %(ruby -r rbconfig -e 'print Config::CONFIG["ruby_version"]' 2>/dev/null || echo ERROR)
+%ruby_ver_requires_eq Requires: ruby(ver) = %ruby_version
+%ruby_mod_ver_requires_eq Requires: ruby-modules(ver) = %ruby_version
+
+%php_pear_dir %{_datadir}/pear
+
+# directory where php includes are installed on system.
+%__php_includedir /usr/include/php
+# extract php/zend api versions
+%php_major_version %(awk '/#define PHP_MAJOR_VERSION/{print $3}' %{__php_includedir}/main/php_version.h 2>/dev/null || echo ERROR)
+%php_api_version %(awk '/#define PHP_API_VERSION/{print $3}' %{__php_includedir}/main/php.h 2>/dev/null || echo ERROR)
+%php_pdo_api_version %(awk '/#define PDO_DRIVER_API/{print $3}' %{__php_includedir}/ext/pdo/php_pdo_driver.h 2>/dev/null || echo ERROR)
+%php_debug %(awk '/#define ZEND_DEBUG/{print $3}' %{__php_includedir}/main/php_config.h 2>/dev/null || echo ERROR)
+%zend_module_api %(awk '/#define ZEND_MODULE_API_NO/{print $3}' %{__php_includedir}/Zend/zend_modules.h 2>/dev/null || echo ERROR)
+%zend_extension_api %(awk '/#define ZEND_EXTENSION_API_NO/{print $3}' %{__php_includedir}/Zend/zend_extensions.h 2>/dev/null || echo ERROR)
+%zend_zts %(Z=$(grep -sc '^#define ZTS 1' %{__php_includedir}/main/php_config.h); echo ${Z:-ERROR})
+
+# helper macro
+%__php_api_requires(v:) Requires: php%{-v*}(%{expand:%1}) = %{expand:%{%{!?2:%{1}}%{?2}}}
+
+# macros for public use
+# for php extensions (php-pecl)
+%requires_php_extension %{__php_api_requires modules_api php_api_version} \
+%{__php_api_requires -v %php_major_version debug php_debug} \
+%{__php_api_requires -v %php_major_version thread-safety zend_zts}
+
+# for zend extensions
+%requires_zend_extension %{__php_api_requires zend_module_api} \
+%{__php_api_requires zend_extension_api} \
+%{__php_api_requires -v %php_major_version debug php_debug} \
+%{__php_api_requires -v %php_major_version thread-safety zend_zts}
+
+# for php pdo modules (php-pecl-PDO_*)
+%requires_php_pdo_module %{__php_api_requires PDO_API php_pdo_api_version}
+
+# Python specific macro definitions.
+# python main version
+%py_ver %(python -c "import sys; print sys.version[:3]")
+
+# directories
+%py_prefix %(python -c "import sys; print sys.prefix")
+%py_libdir %{py_prefix}/%{_lib}/python%{py_ver}
+%py_scriptdir %{py_prefix}/share/python%{py_ver}
+%py_incdir /usr/include/python%{py_ver}
+%py_sitedir %{py_libdir}/site-packages
+%py_sitescriptdir %{py_scriptdir}/site-packages
+%py_dyndir %{py_libdir}/lib-dynload
+
+# pure python modules compilation
+%py_comp python -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
+
+%py_ocomp python -O -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
+
+# Software written in Python language require Python with main version
+%pyrequires_eq() Requires: %1
+
+# Hardlink binary identical .pyc and .pyo files
+# (idea by glen <at> pld-linux <dot> org)
+%__spec_install_post_py_hardlink {\
+%{!?no_install_post_py_hardlink: __spec_install_post_py_hardlink() { \
+[ ! -d "$RPM_BUILD_ROOT" ] || find "$RPM_BUILD_ROOT" -name '*.pyc' | while read a; do \
+ b="$(echo $a|sed -e 's/.pyc$/.pyo/')"; \
+ if cmp -s "$a" "$b"; then \
+ ln -f "$a" "$b"; \
+ fi; \
+done \
+}; __spec_install_post_py_hardlink } }
+
+# remove python sources, so that check-files won't complain
+# (idea by glen <at> pld-linux <dot> org)
+%py_postclean() \
+for d in %{py_sitescriptdir} %{py_sitedir} %*; do \
+ [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -print0 | xargs -0r -l512 rm;\
+done \
+%{nil}
+
+# depmod macro
+%depmod() { \
+umask 022; \
+if [ -e /boot/System.map-%1 ]; then \
+ /sbin/depmod -a -F /boot/System.map-%1 %1; \
+else \
+ if [ -e /boot/System.map ]; then \
+ /sbin/depmod -a -F /boot/System.map %1; \
+ else \
+ /sbin/depmod -a %1; \
+ fi \
+fi; \
+}
+
+# XMMS specific macros
+%xmms_prefix %(xmms-config --prefix 2>/dev/null)
+%xmms_exec_prefix %(xmms-config --exec-prefix 2>/dev/null)
+%xmms_version %(xmms-config --version 2>/dev/null)
+%xmms_datadir %(xmms-config --data-dir 2>/dev/null)
+%xmms_plugindir %(xmms-config --plugin-dir 2>/dev/null)
+%xmms_visualization_plugindir %(xmms-config --visualization-plugin-dir 2>/dev/null)
+%xmms_input_plugindir %(xmms-config --input-plugin-dir 2>/dev/null)
+%xmms_output_plugindir %(xmms-config --output-plugin-dir 2>/dev/null)
+%xmms_effect_plugindir %(xmms-config --effect-plugin-dir 2>/dev/null)
+%xmms_general_plugindir %(xmms-config --general-plugin-dir 2>/dev/null)
+
+%_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/')
+
+# user/group checking macros
+#
+# Usage:
+# %userremove myuser
+#
+%userremove /usr/lib/rpm/user_group.sh user del
+%groupremove /usr/lib/rpm/user_group.sh group del
+#
+# Usage:
+# if %usertestrm myuser; then
+# /usr/sbin/userdel -r myuser
+# Note:
+# use these macros only if you need to call userdel/groupdel with
+# a non-standard option or take an extra action; otherwise use the
+# %userremove/%groupremove macros
+#
+%usertestrm /usr/lib/rpm/user_group.sh user testrm
+%grouptestrm /usr/lib/rpm/user_group.sh group testrm
+# user group membership management macros
+#
+# Usage:
+# %addusertogroup myuser agroup
+#
+%addusertogroup /usr/lib/rpm/user_group.sh user addtogroup
+
+# banner support (useful in {pre,post}{,un} and triggers)
+#
+# Usage:
+# %banner name [-a] [-e] [-n] [-tn] <<EOF
+# the banner text, the banner text
+# the banner text, and following line
+#EOF
+# You can use any form of here-document, <<'EOF' <<-EOT will do.
+# NOTE: if your use "<<-EOF", then You can actually indent inside here-document.
+#
+# -a - append to the banner
+# -e - send to stderr instead of stdout
+# -n - no show banner (overrides -t)
+# -t - show only, if RPM_SCRIPTVERBOSITY >= n; default n=5
+%banner(aent:) \
+RPM_SCRIPTVERBOSITY=5 \
+[ -r /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm \
+if [ -x /usr/bin/banner.sh ]; then \
+ CMD="/usr/bin/banner.sh %{-e:--stderr} %{!-n:$([ $RPM_SCRIPTVERBOSITY -ge %{-t:%{-t*}}%{!-t:5} ] && echo -s)} %{!-a:-m}%{-a:-M} %1" \
+else \
+ CMD="cat%{-e: >&2}" \
+fi \
+eval $CMD %2%{?3: %3} \
+%nil
+
+# useradd/groupadd macros written by glen@pld-linux.org.
+# All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
+#
+# Usage:
+# %useradd [-P package] [-u uid] [-d home_dir] [-s shell] [-c comment]
+# [-g initial_group] [-G group[,...]] login
+#
+# -u uid. REQUIRED
+# -g gid/group. REQUIRED
+# -s defaults to /bin/false
+# -d defaults to /usr/share/empty
+# -c No default
+# -r is accepted but ignored (it's always set)
+# -k skeleton dir. defaults to /usr/share/empty
+# rpm specific flags
+# -P package name. defaults to %{name}
+#
+%useradd(c:d:e:f:g:G:Mmk:op:s:u:rP:) \
+%{!-u:%{error:useradd: Required argument -u missing}} \
+%{!-g:%{error:useradd: Required argument -g missing}} \
+%{!?1:%{error:useradd: Required parameter login missing}} \
+if [ -n "`/bin/id -u %{expand:%{%{#}}} 2>/dev/null`" ]; then \
+ if [ "`/bin/id -u %{expand:%{%{#}}}`" != "%{-u*}" ]; then \
+ echo "Error: user %{expand:%{%{#}}} doesn't have uid=%{-u*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
+ exit 1 \
+ fi \
+else \
+ echo "Adding user %{expand:%{%{#}}} UID=%{-u*}." \
+ /usr/sbin/useradd \\\
+ %{-m:-m -k %{-k*}%{!-k:/usr/share/empty}} \\\
+ -u %{-u*} \\\
+ -r \\\
+ -d %{-d*}%{!-d:/usr/share/empty} \\\
+ -s %{-s*}%{!-s:/bin/false} \\\
+ %{-c:-c "%(set -- %{-c*} %{*}; echo $1)"}\\\
+ -g %{-g*} \\\
+ %{-M} \\\
+ %{-G:-G %{-G*}} \\\
+ %{expand:%{%{#}}} 1>&2 || exit $? \
+ [ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i passwd \
+fi;
+
+# Usage:
+# %groupadd [-P package] [-g gid] group
+#
+# -g gid. REQUIRED
+#
+# Sample:
+# %groupadd -P %{name}-base -g %{gid} %{name}
+
+%groupadd(g:P:rfo) \
+%{!-g:%{error:groupadd: Required argument -g missing}} \
+%{!?1:%{error:groupadd: Required parameter group missing}} \
+if [ -n "`/usr/bin/getgid %{1}`" ]; then \
+ if [ "`/usr/bin/getgid %{1}`" != "%{-g*}" ]; then \
+ echo "Error: group %{1} doesn't have gid=%{-g*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
+ exit 1 \
+ fi \
+else \
+ echo "Adding group %{1} GID=%{-g*}." \
+ /usr/sbin/groupadd -g %{-g*} -r %{1} 1>&2 || exit $? \
+ [ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i group \
+fi;
+
+# apache_config_{install/uninstall} macros written by glen@pld-linux.org.
+# All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
+#
+# You should use webapp macros instead. these are here until single piece of them is gone from specs ;)
+#
+# The config is installed/removed inside trigger, this means that you can any
+# time install apache1 or apache package and the configuration file is updated.
+# if you don't need the config for various reason for specific apache, just
+# remove the symlink from apache config directory. the trigger will not put the
+# config again to that version of apache. In other words the config is linked
+# to apache config directory on first install of PACKAGE or apache.
+#
+# should be called in trigger body:
+# %triggerin -- apache1 >= 1.3.33-2
+# %apache_config_install -v 1
+#
+# Add package's apache config to apache config.
+#
+# Usage:
+# %apache_config_install -v {1|2} -c %{_sysconfdir}/apache-%{name}.conf -n 99
+#
+# -v REQUIRED: specify apache version. can be 1 or 2.
+# -c OPTIONAL: specify full path to PACKAGE's config. Defaults to %{_sysconfdir}/apache-%{name}.conf.
+# -n OPTIONAL: specify config "slot". defaults to 99
+# -f OPTIONAL: force symlink creation regardless if package was upraded. useful in triggers
+#
+# Internal macros. don't use ;).
+# expands apache config dir by apache version at build time.
+%__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)
+# expands apache service name by apache version at build time.
+%__apache_svcname() %(if [ %{1} = 1 ]; then echo apache; elif [ %{1} = 2 ]; then echo httpd; else echo >&2 Unknown apache version specified; fi)
+
+%apache_config_install(fv:c:n:) \
+%{!-v:%{error:apache_config_install: Required argument -v missing}} \
+%{?debug:set -x; echo "apache_config_install:%{-v*} %{name}-%{version}-%{release} 1:[$1]; 2:[$2]"} \
+if [ -n "%{-f:1}" ] || ([ "$1" = "1" ] && [ "$2" = "1" ]) && [ -d %{__apache_confdir %{-v*}} ]; then\
+ ln -sf %{-c*}%{!-c:%{_sysconfdir}/apache-%{name}.conf} %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf\
+fi\
+# reload apache if the config symlink is there\
+if [ -L %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf ]; then\
+ # additionally don't reload if target package (the webserver) is upgraded, as webserver is restarted anyway in %post \
+ if [ "$2" != "2" ] && [ -f /var/lock/subsys/%{__apache_svcname %{-v*}} ]; then\
+ /etc/rc.d/init.d/%{__apache_svcname %{-v*}} reload 1>&2\
+ fi\
+fi\
+%{nil}
+
+# Remove package's apache config from apache config.
+#
+# Usage:
+# %apache_config_uninstall -v {1|2} -n 99
+#
+# -v REQUIRED: specify apache version. can be 1 or 2.
+# -n OPTIONAL: specify config "slot". defaults to 99
+%apache_config_uninstall(v:n:) \
+%{!-v:%{error:apache_config_uninstall: Required argument -v missing}} \
+%{?debug:set -x; echo "apache_config_uninstall:%{-v*} %{name}-%{version}-%{release}: 1:[$1]; 2:[$2]"} \
+# remove link if either of the packages are gone \
+if [ "$1" = "0" ] || [ "$2" = "0" ]; then \
+ if [ -L %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf ]; then \
+ rm -f %{__apache_confdir %{-v*}}/%{-n*}%{!-n:99}_%{name}.conf \
+ if [ -f /var/lock/subsys/%{__apache_svcname %{-v*}} ]; then \
+ /etc/rc.d/init.d/%{__apache_svcname %{-v*}} reload 1>&2 \
+ fi \
+ fi \