]> git.pld-linux.org Git - packages/rpm.git/blobdiff - rpm.macros
- add %ppc from rpm.spec
[packages/rpm.git] / rpm.macros
index a44c14bb22d2fc62c82211dc229f1ac4aa251adf..9462354d45a46161482864b63b60ef1b78ccbde4 100644 (file)
@@ -3,11 +3,14 @@
 
 %epoch         0
 %x8664         x86_64 amd64 ia32e
+%ppc           ppc ppc7400 ppc7450
 
 # kernel compiler
 %kgcc          %{__cc}
 %kgcc_package  gcc
 
+%__rm                  /bin/rm --interactive=never
+
 # Build system path macros.
 #
 %__autoconf            autoconf %{?debug:-Wall}
@@ -32,6 +35,9 @@
 %__intltoolize         intltoolize --copy --force
 %__libtoolize          libtoolize --copy --force
 
+#      Path to top of build area.
+%_topdir               %(test -d ../SPECS && (cd ..; pwd) || echo $HOME/rpm)
+
 #      The number of cvs changelog entries kept when building package.
 %_buildchangelogtruncate 20
 
@@ -173,7 +179,7 @@ CXXFLAGS="%{rpmcxxflags}" \
 }
 
 #----------------------------------------------------------------
-%global configure_cache 0
+#%configure_cache 0
 %configure_cache_file  %{buildroot}.configure.cache
 
 %configure {./configure \
@@ -202,9 +208,17 @@ CXXFLAGS="%{rpmcxxflags}" \
        --infodir=%{_infodir} \
        --x-libraries=%{?_x_libraries}%{!?_x_libraries:%{_libdir}} \
        %{dependencytracking} \
-       %{?configure_cache:--cache-file=%{configure_cache_file:-%{buildroot}.configure.cache}} \
+       %{?configure_cache:--cache-file=%{configure_cache_file}} \
 }
 
+# overload to insert debuginfo package
+%prep \
+%if 0%{?_enable_debug_packages}\
+%{debug_package}\
+%endif\
+%%prep\
+%{nil}
+
 # Location of autoconf macros
 %_aclocaldir   %(aclocal --print-ac-dir)
 
@@ -255,24 +269,25 @@ CXXFLAGS="%{rpmcxxflags}" \
 %_rpmfilename          %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
 
 # 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")
+%requires_releq()              %(echo '%*' | LC_ALL="C" xargs -r rpm -q --qf 'Requires: %{N} = %|E?{%{E}:}|%{V}-%{R}\\n' | grep -v 'is not')
 
-%releq_kernel()                        %((LC_ALL="C" rpm -qf --qf '%%{name} = %%{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_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)")
+%releq_kernel()                        %(R=$(LC_ALL=C rpm -q --qf '%{N} = %|E?{%{E}:}|%{V}-%{R}' -f %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | grep -v 'is not' | sed -e 's:-headers::;s:-config::'); echo ${R:-ERROR})
+%releq_kernel_up()             %(R=$(LC_ALL=C rpm -q --qf '%{N}-up = %|E?{%{E}:}|%{V}-%{R}' -f %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | grep -v 'is not' | sed -e 's:-headers::;s:-config::'); echo ${R:-ERROR})
+%releq_kernel_smp()            %(R=$(LC_ALL=C rpm -q --qf '%{N}-smp = %|E?{%{E}:}|%{V}-%{R}' -f %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | grep -v 'is not' | sed -e 's:-headers::;s:-config::'); echo ${R:-ERROR})
 %requires_releq_kernel(s:)             Requires%{-s:(%{-s*})}: %releq_kernel
 %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")
+# XXX: why epoch 0 is stripped?
+%requires_eq()         %(echo '%*' | LC_ALL="C" xargs -r rpm -q --qf 'Requires: %{N} = %|E?{%{E}:}|%{V}\\n' | sed -e 's/ 0:/ /' | grep -v 'is not')
+%requires_eq_to() %(LC_ALL="C" rpm -q --qf 'Requires: %1 = %|E?{%{E}:}|%{V}' %2 | 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)
 
 # kernel version-release handling
 %__kernel_ver  %( VER_H=%{_kernelsrcdir}/include/linux/utsrelease.h; [ -f $VER_H ] || VER_H=%{_kernelsrcdir}/include/linux/version.h; [ -f $VER_H ] && (grep UTS_RELEASE $VER_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))
-%__kernel_rel  %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{RELEASE}" | grep -v "is not")
-%__kernel_rpmvr        %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{VERSION}-%{RELEASE}" | grep -v "is not")
+%__kernel_rel  %(LC_ALL=C rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{R}" | grep -v "is not")
+%__kernel_rpmvr        %(LC_ALL=C rpm -qf %{_kernelsrcdir}/include/linux/fs.h 2>/dev/null --qf "%{V}-%{R}" | grep -v "is not")
 %_kernel_ver   %{__kernel_ver}%{?with_dist_kernel:%(echo %{__kernel_ver} | grep -q -e - || echo -%{__kernel_rel})}
 %_kernel_ver_str %(echo %{!?_without_dist_kernel:%{__kernel_rpmvr}}%{?_without_dist_kernel:%{__kernel_ver}} | sed -e 's/-/_/g')
 
@@ -359,7 +374,7 @@ if [ -d "$RPM_BUILD_ROOT" ]; then \
                        echo "DONE"; \
                fi; \
        fi; \
-       filelist=`find $RPM_BUILD_ROOT -type f ! -regex ".*/usr/lib[0-9]*/debug/.*\.debug" ! -regex ".*/lib/modules/.*" ! -regex ".*%{_docdir}/.*" ! -regex ".*%{_includedir}/.*" %{?_noautostrip:! -regex "%{_noautostrip}"} %{?_autostripall:! -regex "%{_autostripall}"} %{?_autostripunneeded:! -regex "%{_autostripunneeded}"} %{?_autostripdebug:! -regex "%{_autostripdebug}"}`; \
+       filelist=$(find $RPM_BUILD_ROOT -type f ! -regex ".*/usr/lib[0-9]*/debug/.*\.debug" ! -regex ".*/lib/modules/.*" ! -regex ".*%{_docdir}/.*" ! -regex ".*%{_includedir}/.*" %{?_noautostrip:! -regex "%{_noautostrip}"} %{?_autostripall:! -regex "%{_autostripall}"} %{?_autostripunneeded:! -regex "%{_autostripunneeded}"} %{?_autostripdebug:! -regex "%{_autostripdebug}"}); \
        if [ -n "$filelist" ]; then \
                filetypes=`echo "$filelist" | xargs -r -d'\\n' file`; \
                elfexelist=`echo "$filetypes" | awk -F: '/ELF.*executable/ {print $1}'`; \
@@ -384,9 +399,9 @@ if [ -d "$RPM_BUILD_ROOT" ]; then \
                        echo "DONE"; \
                fi; \
        fi; \
-    filelist_all=%{?_autostripall:`find $RPM_BUILD_ROOT -type f -regex "%{_autostripall}"`}; \
-    filelist_unneeded=%{?_autostripunneeded:`find $RPM_BUILD_ROOT -type f -regex "%{_autostripunneeded}"`}; \
-    filelist_debug=%{?_autostripdebug:`find $RPM_BUILD_ROOT -type f -regex "%{_autostripdebug}"`}; \
+    filelist_all=%{?_autostripall:$(find $RPM_BUILD_ROOT -type f -regex "%{_autostripall}")}; \
+    filelist_unneeded=%{?_autostripunneeded:$(find $RPM_BUILD_ROOT -type f -regex "%{_autostripunneeded}")}; \
+    filelist_debug=%{?_autostripdebug:$(find $RPM_BUILD_ROOT -type f -regex "%{_autostripdebug}")}; \
        if [ -n "$filelist_all" ]; then \
                printf "Stripping everything from %d additional files..." $(echo "$filelist_all" | wc -l); \
                chmod u+w $filelist_all; \
@@ -795,7 +810,7 @@ eval $CMD %{?2:%2}%{?3: %3}) \
 %{nil}
 
 # useradd/groupadd macros
-# Author: Elan Ruusamäe <glen@pld-linux.org>
+# Author: Elan Ruusamäe <glen@pld-linux.org>
 #
 # Usage:
 #   %useradd [-P package] [-u uid] [-d home_dir] [-s shell] [-c comment]
@@ -859,7 +874,7 @@ else \
 fi;
 
 # webapp macros
-# Author: Elan Ruusamäe <glen@pld-linux.org>
+# Author: Elan Ruusamäe <glen@pld-linux.org>
 #
 # The config is installed/removed inside trigger, this means that you can any
 # time install apache1/apache/lighttpd package and the configuration file is
@@ -897,7 +912,7 @@ fi \
 %{nil}
 
 # service macro.
-# Author: Elan Ruusamäe <glen@pld-linux.org>
+# Author: Elan Ruusamäe <glen@pld-linux.org>
 #
 # calls usual service restart on package %post, but skips the restart if
 # administrator has disabled automatic service restarts in either global
@@ -1038,7 +1053,7 @@ echo -e "</dependencies>\\n" >> %{_mavendepmapdir}/maven2-depmap.xml
 
 
 # PEAR install macros
-# Author: Elan Ruusamäe <glen@pld-linux.org>
+# Author: Elan Ruusamäe <glen@pld-linux.org>
 #
 # Usage:
 #      %%pear_package_setup [-a #] [-n FMT]
@@ -1109,13 +1124,13 @@ fi \
 cat %{-z:$_N/}.install.log | %__pear_install_log \
 \
 # undos sources \
-find -type f -print0 | xargs -0 sed -i -e 's,\\r$,,' \
+find -type f -print0 | xargs -0 sed -i -e 's,\\r$,,' \
 %{!?_noautocompressdoc:%global _noautocompressdoc %{nil}}%{expand:%%global _noautocompressdoc %{_noautocompressdoc} optional-packages.txt} \
 %{!?_noautoprov:%global _noautoprov %{nil}}%{expand:%%global _noautoprov %{_noautoprov} 'pear(tests/.*)'} \
 %{nil}
 
 # Copies exctracted PEAR package structure and PEAR registry to buildroot.
-# Author: Elan Ruusamäe <glen@pld-linux.org>
+# Author: Elan Ruusamäe <glen@pld-linux.org>
 %pear_package_install() \
 cp -a ./%{php_pear_dir}/{.registry,*} $RPM_BUILD_ROOT%{php_pear_dir} \
 find $RPM_BUILD_ROOT%{php_pear_dir} '(' -name '*~' -o -name '*.orig' ')' | xargs -r rm -v \
@@ -1128,7 +1143,7 @@ fi \
 
 
 # Register OpenLDAP schema.
-# Author: Elan Ruusamäe <glen@pld-linux.org>
+# Author: Elan Ruusamäe <glen@pld-linux.org>
 #
 # Usage:
 #   %%openldap_schema_register [-d core,nis] %{schemadir}/horde.schema
@@ -1155,7 +1170,7 @@ fi \
 %{nil}
 
 # Unregister OpenLDAP schema.
-# Author: Elan Ruusamäe <glen@pld-linux.org>
+# Author: Elan Ruusamäe <glen@pld-linux.org>
 #
 # Usage:
 #   %%openldap_schema_unregister %{schemadir}/horde.schema
@@ -1211,14 +1226,14 @@ done \
 %define Opts                                                                                                           \\\\\\\
 %if "%{_target_base_arch}" != "%{_arch}"                                                       \\\
        %if "%{_arch}" == "x86_64" && "%{_target_base_arch}" == "i386"  \\\
-       CC="%{__cc}" CPP="%{__cpp}" ARCH=%{_target_base_arch}                   \\\
+       CC="%{kgcc}" ARCH=%{_target_base_arch}                                                  \\\
        %else                                                                                                                   \\\
        ARCH=%{_target_base_arch} CROSS_COMPILE=%{_target_cpu}-pld-linux- \\\
        %endif                                                                                                                  \\\
 %else                                                                                                                          \\\
-       CC="%{__cc}" CPP="%{__cpp}"                                                                             \\\
+       CC="%{kgcc}"                                                                                                    \\\
 %endif                                                                                                                         \
-%define        MakeOpts HOSTCC="%{__cc}" SYSSRC=%{_kernelsrcdir} SYSOUT=$PWD/o \\\\\\\
+%define        MakeOpts HOSTCC="%{kgcc}" SYSSRC=%{_kernelsrcdir} SYSOUT=$PWD/o \\\\\\\
                O=$PWD/o %{?with_verbose:V=1} %{Opts}                                           \
                                                                                                                                        \
 %{?-C:cd %{-C*}}                                                                                                       \
@@ -1308,7 +1323,7 @@ done                                                                                                                              \
 %{nil}
 
 # patchset macros
-# Author: Elan Ruusamäe <glen@pld-linux.org>
+# Author: Elan Ruusamäe <glen@pld-linux.org>
 #
 # Usage:
 #   %patchset_source -f <seq(1) format> <start> [<end>]
@@ -1349,7 +1364,7 @@ done                                                                                                                              \
 %{nil}
 
 # browser plugins v2
-# Author: Elan Ruusamäe <glen@pld-linux.org>
+# Author: Elan Ruusamäe <glen@pld-linux.org>
 #
 # Usage:
 #      %browser_plugins_add_browser <name> -p <plugindir>
@@ -1375,4 +1390,56 @@ done                                                                                                                             \
        %{-b:cat >> $blacklist_file %{-b*}} \
 %{nil}
 
+# Helper for LUA.
+# split string separated by space into quoted list
+#
+# Author: Elan Ruusamäe <glen@pld-linux.org>
+#
+# %__lua_split /bin/sh /bin/pdksh -> "/bin/sh", "/bin/pdksh"
+%__lua_split() %(echo "%*" | awk '{for (i=1;i<=NF;i++) printf("\\"%%s\\"%%s", $i, i == NF ? "" : ", ")}')
+
+# adjust /etc/shells by adding and removing shells from there
+# Author: Elan Ruusamäe <glen@pld-linux.org>
+#
+# Usage:
+#   %post      -p %add_etc_shells -p /bin/sh /bin/pdksh
+#   %preun     -p %remove_etc_shells -p /bin/sh /bin/pdksh
+#
+#  -p (optional) -- specifies that result is embeded %post script (prepends <lua> as first line)
+
+%add_etc_shells(p) %{-p:<lua>}\
+t = {}\
+f = io.open("/etc/shells", "r")\
+if f then\
+       for l in f:lines() do t[l]=l; end\
+       f:close()\
+end\
+for _, s in ipairs({%{expand:%%__lua_split %*}}) do\
+       if not t[s] then\
+               print("Adding "..s.." to /etc/shells")\
+               f = io.open("/etc/shells", "a"); f:write(s.."\\n"); f:close()\
+       end\
+end\
+%{nil}
+
+%remove_etc_shells(p) %{-p:<lua>}\
+%{-p:if arg[2] == 0 then}\
+       t = {}\
+       f = io.open("/etc/shells", "r")\
+       if f then\
+               for l in f:lines() do t[l]=l; end\
+               f:close()\
+       end\
+       for _, l in pairs({%{expand:%%__lua_split %*}}) do\
+               print("Removing "..l.." from /etc/shells")\
+               t[l] = nil\
+       end\
+       s=""\
+       for _, l in pairs(t) do\
+               s=s..l.."\\n"\
+       end\
+       io.open("/etc/shells", "w"):write(s)\
+%{-p:end} \
+%{nil}
+
 # vim:ts=4 sw=4 noet syn=spec
This page took 0.040129 seconds and 4 git commands to generate.