]> git.pld-linux.org Git - packages/rpm.git/blobdiff - rpm.macros
- fix %releq_kernel_* macros to return anything, to prevent spec parse errors
[packages/rpm.git] / rpm.macros
index f54de865ba5a9e8f20909d7fe7488e5c87709103..02fa5ba02c82a0d942d79e1e94aebece7295c151 100644 (file)
@@ -1,10 +1,11 @@
+# $Revision$, $Date$
 # PLD rpm macros
 
 %epoch         0
 %x8664         x86_64 amd64 ia32e
 
 # kernel compiler
-%kgcc          gcc
+%kgcc          %{__cc}
 %kgcc_package  gcc
 
 %_source_payload       w9.gzdio
@@ -74,7 +75,7 @@ fi; \
        --sharedstatedir=%{_sharedstatedir} \
        --mandir=%{_mandir} \
        --infodir=%{_infodir} \
-       --x-libraries=/usr/X11R6/%{_lib} \
+       --x-libraries=%{?_x_libraries}%{!?_x_libraries:%{_libdir}} \
        %{dependencytracking} \
 }
 
@@ -105,7 +106,7 @@ fi; \
        --sharedstatedir=%{_sharedstatedir} \
        --mandir=%{_mandir} \
        --infodir=%{_infodir} \
-       --x-libraries=/usr/X11R6/%{_lib} \
+       --x-libraries=%{?_x_libraries}%{!?_x_libraries:%{_libdir}} \
        %{dependencytracking} \
        %{?configure_cache:--cache-file=%{configure_cache_file:-%{buildroot}.configure.cache}} \
 }
@@ -187,11 +188,12 @@ unset LINGUAS ||:\
 # Requires name = version-release
 %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")
 
-%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)")
-%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)")
-%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)")
-%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)")
+%releq_kernel_up()             %(LC_ALL="C" rpm -qf --qf '%%{name}-up = %%{epoch}:%%{version}-%%{release}\\n' %{_kernelsrcdir}/include/linux/version.h 2>/dev/null || echo ERROR | sed -e 's/ (none):/ /' | sed -e 's:-headers::' | grep -vE "(is not|no such)")
+%releq_kernel_smp()            %(LC_ALL="C" rpm -qf --qf '%%{name}-smp = %%{epoch}:%%{version}-%%{release}\\n' %{_kernelsrcdir}/include/linux/version.h 2>/dev/null || echo ERROR | sed -e 's/ (none):/ /' | sed -e 's:-headers::' | grep -vE "(is not|no such)")
+%requires_releq_kernel_up(s:)          Requires%{-s:(%{-s*})}: %releq_kernel_up
+%requires_releq_kernel_smp(s:)         Requires%{-s:(%{-s*})}: %releq_kernel_smp
 
+%requires_eq()         %(echo '%*' | LC_ALL="C" xargs -r rpm -q --qf 'Requires: %%{name} = %%{epoch}:%%{version}\\n' | sed -e 's/ (none):/ /' -e 's/ 0:/ /' | grep -v "is not")
 %requires_eq_to() %(LC_ALL="C" rpm -q --qf 'Requires: %1 = %%{epoch}:%%{version}\\n' %2 | sed -e 's/ (none):/ /' | grep -v "is not")
 
 %apache_modules_api %(awk '/#define MODULE_MAGIC_NUMBER_MAJOR/ {print $3}' /usr/include/apache/ap_mmn.h 2>/dev/null || echo ERROR)
@@ -324,6 +326,12 @@ fi; } \
        fi; \
 } }
 
+# Remove common Perl files we don't package
+%__spec_install_post_perl_clean {\
+%{!?no_install_post_perl_clean: \
+%{?pdir:rm -f $RPM_BUILD_ROOT{%{perl_archlib}/perllocal.pod,%{perl_vendorarch}/auto/%{pdir}%{?pnam:/%(echo %{pnam} | tr - /)}/.packlist}} \
+} }
+
 #-----------------------------------------------------------------
 # Update GConf2 schemas
 #
@@ -423,12 +431,14 @@ fi \
 %perl_sitearch         %(eval "`%{__perl} -V:installsitearch`"; echo $installsitearch)
 
 # Ruby
-%ruby_archdir          %(ruby -r rbconfig -e 'print Config::CONFIG["archdir"]')
-%ruby_rubylibdir               %(ruby -r rbconfig -e 'print Config::CONFIG["rubylibdir"]')
-%ruby_ridir            %(ruby -r rbconfig -e 'include Config; print File.join(CONFIG["datadir"], "ri", CONFIG["ruby_vers
-ion"], "system")')
-%ruby_sitearchdir      %(ruby -r rbconfig -e 'print Config::CONFIG["sitearchdir"]')
-%ruby_version          %(ruby -r rbconfig -e 'print Config::CONFIG["ruby_version"]')
+%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
 
@@ -641,6 +651,8 @@ 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
@@ -660,6 +672,7 @@ fi;
 #  -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.
@@ -667,10 +680,10 @@ 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(v:c:n:) \
+%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 [ "$1" = "1" ] && [ "$2" = "1" ] && [ -d %{__apache_confdir %{-v*}} ]; then\
+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\
@@ -703,6 +716,43 @@ if [ "$1" = "0" ] || [ "$2" = "0" ]; then \
 fi \
 %{nil}
 
+# webapp macros
+#
+# The config is installed/removed inside trigger, this means that you can any
+# time install apache1/apache/lighttpd package and the configuration file is
+# updated.  if you don't need the config for various reason for specific
+# webserver, just remove the symlink from config directory using webapp
+# program. the trigger will not recreate the symlink on upgrades. In other
+# words the config is linked to webserver config directory on first install of
+# PACKAGE or WEBSERVER.
+#
+# Add package's webserver config to webserver webapps dir.
+# Usage:
+#   %webapp_register WEBSERVER WEBAPP
+#
+%webapp_register() \
+%{?debug:set -x; echo "webapp_register: %{name}-%{version}-%{release} 1:[$1]; 2:[$2]"} \
+if [ "$1" = "1" ] && [ "$2" = "1" ]; then\
+       /usr/sbin/webapp register %1 %2\
+fi\
+# reload webserver if the config symlink is there and skip reload if webserver is upgraded\
+if [ -L /etc/%1/webapps.d/%2.conf ] && [ "$2" -lt "2" ]; then\
+       %{expand:%service -q %%1 reload}\
+fi\
+%{nil}
+
+# Remove package's config from webserver webapps dir.
+# Usage:
+#   %webapp_register [-f] WEBSERVER WEBAPP
+%webapp_unregister(f) \
+%{?debug:set -x; echo "webapp_unregister: %{name}-%{version}-%{release}: 1:[$1]; 2:[$2]"} \
+# remove link if either of the packages are gone \
+if [ -n "%{-f:1}" ] || [ "$1" = "0" ] || [ "$2" = "0" ] && [ -L /etc/%1/webapps.d/%2.conf ]; then \
+       /usr/sbin/webapp unregister %1 %2\
+       %{expand:%service -q %%1 reload}\
+fi \
+%{nil}
+
 # see browser-plugins.spec / template-browser-plugin.spec
 # written by glen@pld-linux.org.
 %nsplugin_install(d:f) { \
@@ -741,22 +791,6 @@ if [ "$1" = "0" ] || [ "$2" = "0" ]; then \
 # Usage:
 #   %service [-q] SERVICE ACTION ["SERVICE NICE DESCRIPTION"]
 #
-#  -q be silent when service isn't started (for postun scriplets)
-#
-%service(q) {{ \
-# we use function, not to globber namespace with useless variables \
-skip_auto_restart() { \
-       . /etc/sysconfig/rpm; # global setting \
-       [ -f /etc/sysconfig/%1 ] && . /etc/sysconfig/%1; # per service setting \
-       echo ${RPM_SKIP_AUTO_RESTART:-no}; \
-}; \
-if [ -f /var/lock/subsys/%1 ]; then \
-       if [ $(skip_auto_restart) = no ]; then \
-               /etc/rc.d/init.d/%1 %2 1>&2; \
-%{!-q:else} \
-       %{!-q:echo 'Run "/etc/rc.d/init.d/%1 %2" to %2 %{!?3:%1 service}%{?3:%(set -- %{*}; echo "$3")}.';} \
-       fi \
-%{!-q:else} \
-       %{!-q:echo 'Run "/etc/rc.d/init.d/%1 start" to start %{!?3:%1 service}%{?3:%(set -- %{*}; echo "$3")}.';} \
-fi }; }
-
+#  -q be silent when service isn't started (for scriplets restaring other package's services)
+#
+%service(q) {{%(export quiet=%{-q:1}; /usr/lib/rpm/service_generator.sh %{*}) };}
This page took 0.062001 seconds and 4 git commands to generate.