X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=rpm.macros;h=68441a24747bea42248bd83ec982b574526f6b19;hb=eb5ba8b8955e706a9db3160772de278a56e454f2;hp=35b09a8e30f982701bd9b1bafb92ef00d83ec1ef;hpb=e1b6d0b60001a6b6dd1292f362e910d10ed58c5f;p=packages%2Frpm-build-macros.git diff --git a/rpm.macros b/rpm.macros index 35b09a8..68441a2 100644 --- a/rpm.macros +++ b/rpm.macros @@ -85,10 +85,10 @@ %_specdir %{expand:%%global _specdir %([ ! -d %{_topdir}/SPECS ] && echo %{_topdir}/%{name} || echo %{_topdir}/SPECS)}%_specdir %_sourcedir %{expand:%%global _sourcedir %([ ! -d %{_topdir}/SOURCES ] && echo %{_specdir} || echo %{_topdir}/SOURCES)}%_sourcedir -# BUILD/RPMS/SRPMS are one same level by default as packages dir, if these exist +# BUILD/RPMS/SRPMS are on same level by default as packages dir, if these exist # if they don't exist assume we are having custom topdir (which is not named as # "packages", i.e ~/rpm/kde/{kdelibs,BUILD/RPMS/SRPMS}) -# NOTE: readlink fails if some parent dir is not readable (/home/services/builder for example can't read /home/services), therfore the extra echo +# NOTE: readlink fails if some parent dir is not readable (/home/services/builder for example can't read /home/services), therefore the extra echo %_builddir %{expand:%%global _builddir %(if [ -d %{_topdir}/BUILD ]; then echo %{_topdir}/BUILD; else readlink -m %{_topdir}/../BUILD || echo %{_topdir}/../BUILD; fi)}%_builddir %_rpmdir %{expand:%%global _rpmdir %(if [ -d %{_topdir}/RPMS ]; then echo %{_topdir}/RPMS; else readlink -m %{_topdir}/../RPMS || echo readlink -m %{_topdir}/../RPMS; fi)}%_rpmdir %_srcrpmdir %{expand:%%global _srcrpmdir %(if [ -d %{_topdir}/SRPMS ]; then echo %{_topdir}/SRPMS; else readlink -m %{_topdir}/../SRPMS || echo readlink -m %{_topdir}/../SRPMS; fi)}%_srcrpmdir @@ -123,8 +123,8 @@ # Regular expressions are supported, but to avoid some character be treated # as regular expression it must be escaped twice. -%filter_out \ - for (i = 1; i in I; i++) { A=0; \ +%filter_out \ + for (i = 1; i in I; i++) { A=0; \ for (f in F) { \ if (I[i] ~ "^" F[f] "$") A=1; \ }; \ @@ -208,6 +208,16 @@ } }') +# override %__spec_build_pre and %__spec_install_pre from macros.rpmbuild +# adding %{_clean_env} +%__spec_build_pre %{_clean_env}\ +%{___build_pre}\ +%{nil} +%__spec_install_pre %{_clean_env}\ +%{___build_pre}\ +%{?buildroot:%{__rm} -rf '%{buildroot}'; %{__mkdir_p} '%{buildroot}'}\ +%{nil} + #----------------------------------------------------------------- %configure2_13 { \ if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \ @@ -221,7 +231,7 @@ %{?__cxx:CXX="%{__cxx}" ; export CXX ; } \ %{?configuredir:%{configuredir}}%{!?configuredir:.}/configure \ --host=%{_target_platform} \ - --prefix=%{_prefix} \ + --prefix=%{_prefix} \ --exec-prefix=%{_exec_prefix} \ --bindir=%{_bindir} \ --sbindir=%{_sbindir} \ @@ -238,6 +248,15 @@ %{dependencytracking} \ } +# Note: pass only standard cmake macros here. +# The only exception is SYSCONF_INSTALL_DIR, used commonly in KDE packages, +# where the default (${CMAKE_INSTALL_PREFIX}/etc) is not FHS-compliant and +# absolute path MUST be used to comply with FHS. +# The other non-standard cmake macros used commonly in KDE +# (INCLUDE_INSTALL_DIR, LIB_INSTALL_DIR, SHARE_INSTALL_PREFIX) +# have sane default values in KDE, and some packages use these names +# in different way (e.g. expect them to be always relative or always +# absolute). %cmake \ %{?__cc:CC="${CC:-%{__cc}}"} \\\ %{?__cxx:CXX="${CXX:-%{__cxx}}"} \\\ @@ -247,13 +266,10 @@ CPPFLAGS="${CPPFLAGS:-%{rpmcppflags}}" \\\ -DCMAKE_BUILD_TYPE=%{!?debug:PLD}%{?debug:Debug} \\\ -DCMAKE_INSTALL_LIBDIR:PATH=%{_libdir} \\\ -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \\\ - -DINCLUDE_INSTALL_DIR:PATH=%{_includedir} \\\ - -DLIB_INSTALL_DIR:PATH=%{_libdir} \\\ - -DSHARE_INSTALL_PREFIX:PATH=%{_datadir} \\\ -DSYSCONF_INSTALL_DIR:PATH=%{_sysconfdir} \\\ - -DCMAKE_CXX_FLAGS_PLD="${CXXFLAGS:-%{rpmcxxflags} -DNDEBUG}" \\\ - -DCMAKE_C_FLAGS_PLD="${CFLAGS:-%{rpmcflags} -DNDEBUG}" \\\ - -DCMAKE_Fortran_FLAGS_PLD="${CFLAGS:-%{rpmcflags} -DNDEBUG}" \\\ + -DCMAKE_CXX_FLAGS_PLD="${CXXFLAGS:-%{rpmcxxflags} -DNDEBUG -DQT_NO_DEBUG}" \\\ + -DCMAKE_C_FLAGS_PLD="${CFLAGS:-%{rpmcflags} -DNDEBUG -DQT_NO_DEBUG}" \\\ + -DCMAKE_Fortran_FLAGS_PLD="${CFLAGS:-%{rpmcflags} -DNDEBUG -DQT_NO_DEBUG}" \\\ -DCMAKE_EXE_LINKER_FLAGS_PLD="${LDFLAGS:-%{rpmldflags}}" \\\ -DCMAKE_SHARED_LINKER_FLAGS_PLD="${LDFLAGS:-%{rpmldflags}}" \\\ -DCMAKE_MODULE_LINKER_FLAGS_PLD="${LDFLAGS:-%{rpmldflags}}" \\\ @@ -283,6 +299,7 @@ CXX="%{__cxx}" \ CPP="%{__cpp}" \ CFLAGS="%{rpmcflags}" \ CXXFLAGS="%{rpmcxxflags}" \ +LINKFLAGS="%{rpmldflags}" \ %{__waf} \ } @@ -291,7 +308,7 @@ CXXFLAGS="%{rpmcxxflags}" \ %configure_cache_file %{buildroot}.configure.cache %configure {./configure \ - LDFLAGS="${LDFLAGS:-%rpmldflags}" \ + LDFLAGS="${LDFLAGS:-%rpmldflags}" \ CFLAGS="${CFLAGS:-%rpmcflags}" \ CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" \ FFLAGS="${FFLAGS:-%rpmcflags}" \ @@ -301,7 +318,7 @@ CXXFLAGS="%{rpmcxxflags}" \ %{?__cxx:CXX="%{__cxx}"} \ --host=%{_target_platform} \ --build=%{_target_platform} \ - --prefix=%{_prefix} \ + --prefix=%{_prefix} \ --exec-prefix=%{_exec_prefix} \ --bindir=%{_bindir} \ --sbindir=%{_sbindir} \ @@ -399,7 +416,7 @@ CXXFLAGS="%{rpmcxxflags}" \ %__unsermake /usr/share/unsermake/unsermake # Current date -%date %(LC_ALL=C date +"%a %b %d %Y") +%date %(LC_ALL=C date +"%a %b %d %Y") # Example files, programs, scripts... %_examplesdir /usr/src/examples @@ -429,8 +446,8 @@ CXXFLAGS="%{rpmcxxflags}" \ %__kernel_qf() %(R=$(cd %{_kernelsrcdir} 2>/dev/null && LC_ALL=C rpm -q --qf '%*' -f include/linux/version.h 2>/dev/null | grep -v 'is not'); echo ${R:-ERROR}) # kernel %{name} and kernel %{epoch}:%{version}-%{release} macro respecing alt_kernel -%kernel_name %{expand:%%global kernel_name %(N=%{__kernel_qf %{N}};echo ${N%%-headers})}%kernel_name -%kernel_version %{expand:%%global kernel_version %{__kernel_qf %|E?{%{E}:}|%{V}-%{R}}}%kernel_version +%kernel_name %(N=%{__kernel_qf %{N}}; echo ${N%%-headers}) +%kernel_version %{__kernel_qf %|E?{%{E}:}|%{V}-%{R}} # -n drm to generate kernel%{_alt_kernel}-drm dependency %releq_kernel(n:) %{kernel_name}%{?-n:-%{-n*}} = %{kernel_version} @@ -443,19 +460,23 @@ CXXFLAGS="%{rpmcxxflags}" \ %requires_releq_kernel_smp(s:n:) Requires%{-s:(%{-s*})}: %releq_kernel_smp # kernel version-release handling -%__kernel_ver %{expand:%%global __kernel_ver %( \\ +%__kernel_ver %( \\ Z=$([ -f '%{_kernelsrcdir}/include/generated/utsrelease.h' ] && awk -F'"' '/UTS_RELEASE/{print $2}' %{_kernelsrcdir}/include/{linux/version,generated/utsrelease}.h 2>/dev/null || awk -F'"' '/UTS_RELEASE/{print $2}' %{_kernelsrcdir}/include/linux/{version,utsrelease}.h 2>/dev/null); \\ Z=${Z:-$(awk -F' = ' '/^VERSION/{v=$2} /^PATCHLEVEL/{p=$2} /^SUBLEVEL/{s=$2} /^EXTRAVERSION/{e=$2} END {printf("%d.%d.%d%s", v, p, s, e)}' %{_kernelsrcdir}/Makefile 2>/dev/null)}; \\ echo ${Z:-ERROR}; \\ -)}%__kernel_ver +) -%__kernel_rel %{expand:%%global __kernel_rel %{__kernel_qf %{R}}}%__kernel_rel -%__kernel_rpmvr %{expand:%%global __kernel_rpmvr %{__kernel_qf %{V}-%{R}}}%__kernel_rpmvr -%_kernel_ver %{expand:%%global _kernel_ver %{__kernel_ver}%{?with_dist_kernel:%(echo %{__kernel_ver} | grep -q -e - || echo -%{__kernel_rel})}}%_kernel_ver -%_kernel_ver_str %{expand:%%global _kernel_ver_str %(echo %{!?_without_dist_kernel:%{__kernel_rpmvr}}%{?_without_dist_kernel:%{__kernel_ver}} | sed -e 's/-/_/g')}%_kernel_ver_str +%_kernel_version_code %( \\ + Z=$(awk '/LINUX_VERSION_CODE/{print $3}' %{_kernelsrcdir}/include/linux/version.h 2>/dev/null); \\ + echo ${Z:-ERROR}; \\ +) + +%_kernel_version_magic() %(echo $((%{1} * 65536 + %{2} * 256 + %{3}))) -# `uname -r` to be used in @release field -%_kernel_vermagic %{expand:%%global _kernel_vermagic %(echo %{_kernel_ver} | sed -e 's/-/_/g')}%_kernel_vermagic +# `uname -r` used for building/installing kernel modules +%_kernel_ver %{__kernel_ver}%{!?_without_dist_kernel:%(echo %{__kernel_ver} | grep -q -e - || echo -%{__kernel_qf %{R}})} +# package version OR `uname -r` for non-dist kernel to be used in @release field +%_kernel_ver_str %(echo %{!?_without_dist_kernel:%{__kernel_qf %{V}-%{R}}}%{?_without_dist_kernel:%{__kernel_ver}} | tr '-' '_') # Requires name = version-release %requires_releq() %{!?1:ERROR}%{?2:ERROR}%{?1:%{!?2:%{expand:%%requires_eq_to -r %1 %1}}} @@ -469,11 +490,11 @@ CXXFLAGS="%{rpmcxxflags}" \ # Requires: name >= version (version based on querying package %2) %requires_ge_to(r) %{!?2:ERROR}%{?3:ERROR}%{?2:%{!?3:%(if ! LC_ALL=C rpm -q --qf 'Requires: %1 >= %|E?{%{E}:}|%{V}%{?-r:-%{R}}\\n' %2 | grep '^Requires:'; then echo "BuildRequires: %2"; fi)}} -# \helper for renaming packages +# helper for renaming packages # %rename old-package %rename() \ Obsoletes: %{1} < %{?epoch:%{epoch}:}%{?version:%{version}}%{?release:-%{release}} \ -Provides: %{1} = %{?epoch:%{epoch}:}%{?version:%{version}}%{?release:-%{release}} +Provides: %{1} = %{?epoch:%{epoch}:}%{?version:%{version}}%{?release:-%{release}} %apache_modules_api %{expand:%%global apache_modules_api %(awk '/#define MODULE_MAGIC_NUMBER_MAJOR/ {print $3}' /usr/include/apache/ap_mmn.h 2>/dev/null || echo ERROR)}%apache_modules_api @@ -903,18 +924,21 @@ fi; \ # Ruby %__ruby /usr/bin/ruby -%ruby_archdir %{expand:%%global ruby_archdir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["archdir"]' 2>/dev/null || echo ERROR)}%ruby_archdir -%ruby_libdir %{expand:%%global ruby_libdir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["rubylibdir"]' 2>/dev/null || echo ERROR)}%ruby_libdir -%ruby_ridir %{expand:%%global ruby_ridir %(%{__ruby} -r rbconfig -e 'include Config; print File.join(CONFIG["datadir"], "ri", CONFIG["ruby_version"], "system")' 2>/dev/null || echo ERROR)}%ruby_ridir -%ruby_rubylibdir %{expand:%%global ruby_rubylibdir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["rubylibdir"]' 2>/dev/null || echo ERROR)}%ruby_rubylibdir -%ruby_vendorarchdir %{expand:%%global ruby_vendorarchdir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["vendorarchdir"]' 2>/dev/null || echo ERROR)}%ruby_vendorarchdir -%ruby_vendorlibdir %{expand:%%global ruby_vendorlibdir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["vendorlibdir"]' 2>/dev/null || echo ERROR)}%ruby_vendorlibdir -%ruby_sitearchdir %{expand:%%global ruby_sitearchdir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["sitearchdir"]' 2>/dev/null || echo ERROR)}%ruby_sitearchdir -%ruby_sitedir %{expand:%%global ruby_sitedir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["sitedir"]' 2>/dev/null || echo ERROR)}%ruby_sitedir -%ruby_sitelibdir %{expand:%%global ruby_sitelibdir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["sitelibdir"]' 2>/dev/null || echo ERROR)}%ruby_sitelibdir +# get rbconfig parameter +%__ruby_rbconfig() %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["%1"]' 2>/dev/null || echo ERROR) + +%ruby_archdir %{expand:%%global ruby_archdir %{__ruby_rbconfig archdir}}%ruby_archdir +%ruby_libdir %{expand:%%global ruby_libdir %{__ruby_rbconfig rubylibdir}}%ruby_libdir +%ruby_ridir %{expand:%%global ruby_ridir %(%{__ruby} -r rbconfig -e 'print File.join(RbConfig::CONFIG["datadir"], "ri", RbConfig::CONFIG["ruby_version"], "system")' 2>/dev/null || echo ERROR)}%ruby_ridir +%ruby_rubylibdir %{expand:%%global ruby_rubylibdir %{__ruby_rbconfig rubylibdir}}%ruby_rubylibdir +%ruby_vendorarchdir %{expand:%%global ruby_vendorarchdir %{__ruby_rbconfig vendorarchdir}}%ruby_vendorarchdir +%ruby_vendorlibdir %{expand:%%global ruby_vendorlibdir %{__ruby_rbconfig vendorlibdir}}%ruby_vendorlibdir +%ruby_sitearchdir %{expand:%%global ruby_sitearchdir %{__ruby_rbconfig sitearchdir}}%ruby_sitearchdir +%ruby_sitedir %{expand:%%global ruby_sitedir %{__ruby_rbconfig sitedir}}%ruby_sitedir +%ruby_sitelibdir %{expand:%%global ruby_sitelibdir %{__ruby_rbconfig sitelibdir}}%ruby_sitelibdir %ruby_rdocdir /usr/share/rdoc -%ruby_vendordir %{expand:%%global ruby_vendordir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["vendordir"]' 2>/dev/null || echo ERROR)}%ruby_vendordir -%ruby_version %{expand:%%global ruby_version %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["ruby_version"]' 2>/dev/null || echo ERROR)}%ruby_version +%ruby_vendordir %{expand:%%global ruby_vendordir %{__ruby_rbconfig vendordir}}%ruby_vendordir +%ruby_version %{expand:%%global ruby_version %{__ruby_rbconfig ruby_version}}%ruby_version %ruby_gemdir %{expand:%%global ruby_gemdir %(%{__ruby} -r rbconfig -e 'print RbConfig::CONFIG["rubylibdir"].sub(RbConfig::CONFIG["ruby_version"], "gems/#{RbConfig::CONFIG["ruby_version"]}")' 2>/dev/null || echo ERROR)}%{ruby_gemdir} %ruby_specdir %{ruby_gemdir}/specifications @@ -947,8 +971,11 @@ fi; \ # NOTE: error output must be empty. otherwise can't build pecl packages if no php*-devel is installed %php_suffix %{expand:%%global php_suffix %(c=$(php-config --sysconfdir 2>/dev/null) || echo '' && echo ${c#/etc/php})%%{nil}}%php_suffix +# phpXY, version always present for using current php version (in regards of php*-devel package) +%php_versuffix %{expand:%%global php_versuffix %((IFS=.; set -- $(php-config --version); echo $1$2))%%{nil}}%php_versuffix + # php cli. version that php headers are installed for -%__php /usr/bin/%{php_name} +%__php /usr/bin/php%{php_versuffix} # helper macro %__php_api_requires(v:) Requires: %{php_name}(%{expand:%1}) = %{expand:%{%{!?2:%{1}}%{?2}}} @@ -1064,7 +1091,7 @@ fi \ # Python 3.x # python main version -%__python3 python3 +%__python3 /usr/bin/python3 %py3_ver %{expand:%%global py3_ver %(%{__python3} -c "import sys; print(sys.version[:3])" 2>/dev/null || echo ERROR)}%py3_ver # directories @@ -1119,9 +1146,11 @@ fi; \ # Usage: # %py_postclean /usr/share/extra -x keepme.py,keeptoo.py # Options: -# -x - comma separated of file basenames to preserve +# -x - comma separated of file basenames to preserve (rpmbuild(macros) >= 1.658) # ARGS - extra directories to clean for .py sources # +# BuildRequires: rpmbuild(macros) >= 1.189 +# %py_postclean(x:) \ for d in %{py_sitescriptdir} %{py_sitedir} %*; do \ [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -print0 %{-x:| grep -ZzvE '/(%(echo '%{-x*}' | tr ',' '|'))$'} | xargs -0r -l512 rm;\ @@ -1486,7 +1515,7 @@ echo -e "\\n" >> %{_mavendepmapdir}/maven2-depmap.xml # JAVA macros specific for PLD # Directory for tomcat context configuration files -%_tomcatconfdir %{_sharedstatedir}/tomcat/conf/Catalina/localhost +%_tomcatconfdir /etc/tomcat/Catalina/localhost # Tomcat cache path %_tomcatcachedir %{_sharedstatedir}/tomcat/work/Catalina/localhost @@ -1699,17 +1728,17 @@ done \ %build_kernel_modules(p:P:m:C:c) \ %{!?-m:%{error:%{0}: Required module name/list missing} exit 1} \ \ -%define Opts \\\\\\\ +%define Opts \\\\\\\ %if "%{_target_base_arch}" != "%{_host_base_arch}" \\\ %if "%{_host_base_arch}" == "x86_64" && "%{_target_base_arch}" == "i386" \\\ - CC="%{kgcc}" ARCH=%{_target_base_arch} \\\ + CC="%{__cc}" ARCH=%{_target_base_arch} \\\ %else \\\ ARCH=%{_target_base_arch} CROSS_COMPILE=%{_target_cpu}-pld-linux- \\\ %endif \\\ %else \\\ - CC="%{kgcc}" \\\ + CC="%{__cc}" \\\ %endif \ -%define MakeOpts HOSTCC="%{kgcc}" SYSSRC=%{_kernelsrcdir} SYSOUT=$PWD/o \\\\\\\ +%define MakeOpts HOSTCC="%{__cc}" SYSSRC=%{_kernelsrcdir} SYSOUT=$PWD/o \\\\\\\ O=$PWD/o %{?with_verbose:V=1} %{Opts} \ \ %{?-C:cd %{-C*}} \ @@ -1725,7 +1754,7 @@ compile() { \ ln -sf %{_kernelsrcdir}/Module.symvers o/Module.symvers \ if [ -f %{_kernelsrcdir}/include/generated/autoconf.h ]; then \ ln -sf %{_kernelsrcdir}/include/generated/autoconf.h o/include/generated/autoconf.h \ - ln -s ../generated/autoconf.h o/include/linux/autoconf.h \ + ln -s ../generated/autoconf.h o/include/linux/autoconf.h \ else \ ln -sf %{_kernelsrcdir}/include/linux/autoconf.h o/include/linux/autoconf.h \ fi \ @@ -1752,7 +1781,27 @@ compile() { \ M=$PWD CONSTIFY_PLUGIN="" %{MakeOpts} \ %{?-C:cd -} \ } \ -compile_old() { \ +compile %{*} \ +%{nil} + +%build_kernel_modules_compat(p:P:m:C:c) \ +%{!?-m:%{error:%{0}: Required module name/list missing} exit 1} \ + \ +%define Opts \\\\\\\ +%if "%{_target_base_arch}" != "%{_host_base_arch}" \\\ + %if "%{_host_base_arch}" == "x86_64" && "%{_target_base_arch}" == "i386" \\\ + CC="%{__cc}" ARCH=%{_target_base_arch} \\\ + %else \\\ + ARCH=%{_target_base_arch} CROSS_COMPILE=%{_target_cpu}-pld-linux- \\\ + %endif \\\ +%else \\\ + CC="%{__cc}" \\\ +%endif \ +%define MakeOpts HOSTCC="%{__cc}" SYSSRC=%{_kernelsrcdir} SYSOUT=$PWD/o \\\\\\\ + O=$PWD/o %{?with_verbose:V=1} %{Opts} \ + \ +%{?-C:cd %{-C*}} \ +compile() { \ local L="<" PATCH_SH; \ [[ '%{*}' != *$L$L* ]] || PATCH_SH="set -x -e;$(cat)" \ set -e -x \ @@ -1767,7 +1816,7 @@ for cfg in ${cfgs:-dist}; do \ ln -sf %{_kernelsrcdir}/Module.symvers-$cfg o/Module.symvers \ if [ -f %{_kernelsrcdir}/include/generated/autoconf-$cfg.h ]; then \ ln -sf %{_kernelsrcdir}/include/generated/autoconf-$cfg.h o/include/generated/autoconf.h \ - ln -s ../generated/autoconf.h o/include/linux/autoconf.h \ + ln -s ../generated/autoconf.h o/include/linux/autoconf.h \ else \ ln -sf %{_kernelsrcdir}/include/linux/autoconf-$cfg.h o/include/linux/autoconf.h \ fi \ @@ -1788,7 +1837,7 @@ for cfg in ${cfgs:-dist}; do \ %endif \ \ %{!?-c:%{__make} -C %{_kernelsrcdir} clean \\\ - RCS_FIND_IGNORE="-name '*.[ks]o' -o" \\\ + RCS_FIND_IGNORE="-name '*.[ks]o' -o" \\\ ${1+"$@"} \\\ M=$PWD %{MakeOpts}} \ \ @@ -1802,11 +1851,7 @@ for cfg in ${cfgs:-dist}; do \ done \ %{?-C:cd -} \ } \ -if [ -r "%{_kernelsrcdir}/.config" ]; then \ - compile %{*} \ -else \ - compile_old %{*} \ -fi \ +compile %{*} \ %{nil} @@ -1825,14 +1870,19 @@ fi \ # with same name exists in kernel already # -n -- name of modprobe config file to use (without .conf extension) # for defining aliases, only useful with -s +# -D -- DESTDIR, base directory for installed files, +# defaults to RPM_BUILD_ROOT -%install_kernel_modules(m:d:s:n:) \ +%install_kernel_modules(m:d:s:n:D:) \ %{!?-m:%{error:%{0}: Required module name (-m) missing}exit 1} \ %{!?-d:%{error:%{0}: Required module directory missing}exit 1} \ %{?-n:%{!?-s:%{error:%{0}: Modprobe .conf file requires module suffix}exit 1}} \ \ -%define KernelD $RPM_BUILD_ROOT/lib/modules/%{_kernel_ver} \ -%define ModprobeD $RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d/%{_kernel_ver} \ +INSTALLROOT=%{-D*} \ +[ -n "$INSTALLROOT" ] || INSTALLROOT=$RPM_BUILD_ROOT \ + \ +%define KernelD $INSTALLROOT/lib/modules/%{_kernel_ver} \ +%define ModprobeD $INSTALLROOT%{_sysconfdir}/modprobe.d/%{_kernel_ver} \ \ __install_kernel_modules() { \ %{!?debug:set +x;} \ @@ -1845,7 +1895,22 @@ for MODULE in {%{-m*},}; do \ echo "alias ${MNAME} ${MNAME}-%{-s*}" >> %{ModprobeD}/%{-n*}.conf} \ done \ } \ -__install_kernel_modules_old() { \ +__install_kernel_modules \ +unset INSTALLROOT \ +%{nil} + +%install_kernel_modules_compat(m:d:s:n:D:) \ +%{!?-m:%{error:%{0}: Required module name (-m) missing}exit 1} \ +%{!?-d:%{error:%{0}: Required module directory missing}exit 1} \ +%{?-n:%{!?-s:%{error:%{0}: Modprobe .conf file requires module suffix}exit 1}} \ + \ +INSTALLROOT=%{-D*} \ +[ -n "$INSTALLROOT" ] || INSTALLROOT=$RPM_BUILD_ROOT \ + \ +%define KernelD $INSTALLROOT/lib/modules/%{_kernel_ver} \ +%define ModprobeD $INSTALLROOT%{_sysconfdir}/modprobe.d/%{_kernel_ver} \ + \ +__install_kernel_modules() { \ %{!?debug:set +x;} \ local cfgs='%{?with_dist_kernel:%{?with_smp: smp}%{?with_up: up}}%{!?with_dist_kernel: nondist}' \ \ @@ -1862,32 +1927,49 @@ for MODULE in {%{-m*},}; do \ done \ done \ } \ -if [ -r "%{_kernelsrcdir}/.config" ]; then \ - __install_kernel_modules \ -else \ - __install_kernel_modules_old \ -fi \ +__install_kernel_modules \ +unset INSTALLROOT \ %{nil} # patchset macros +# generate SourceX urls from range START STOP +# Format can be SINGLE format char of %e, %f, %g, see seq(1) +# The sources start from 10000 +# # Author: Elan Ruusamäe # # Usage: # %patchset_source -f [] # %patchset_patch [] -# # If is omited, it is assumed to be . # # For example in preamble: # %patchset_source -f ftp://ftp.vim.org/pub/editors/vim/patches/7.0/7.0.%03g 33 44 # and in %prep: # %patchset_patch 33 44 - -# generate SourceX urls from range START STOP -# Format can be SINGLE format char of %e, %f, %g, see seq(1) -# The sources start from 10000 -%patchset_source(f:b:) %( - base=%{-b*}%{!-b*:10000}; +# +# Using sources list: +# BuildRequires: rpmbuild(macros) >= 1.426 +# %patchset_source -f -s +# %patchset_patch -s +# For example (ncurses): +# BuildRequires: rpmbuild(macros) >= 1.683 +# %patchset_source -f ftp://dickey.his.com/ncurses/%{basever}/ -s sources +# %patchset_patch -s sources -p1 +# + +%patchset_source(f:b:s:) %( + base=%{-b*}%{!-b*:10000} +%{-s: + baseurl='%{-f*}' + filelist='%{-s*}' + i=$base + while read checksum file; do + printf "Patch%d: %s%s\\n" $i "$baseurl" "$file" + i=$((i+1)) + done < $filelist +} +%{!-s: start=$(expr $base + %1); end=$(expr $base + %{?2}%{!?2:%{1}}); # we need to call seq twice as it doesn't allow two formats @@ -1895,18 +1977,31 @@ fi \ seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2; paste %{tmpdir}/__ps{1,2}; rm -f %{tmpdir}/__ps{1,2}; +} ) \ %{nil} # apply sources from %patchset_source # -p specify -pX for %patch line # -b base offset: defaults to 10000 -%patchset_patch(f:p:b:) %( - base=%{-b*}%{!-b*:10000}; +# -s filelist to read files from +%patchset_patch(f:p:b:s:) %( + base=%{-b*}%{!-b*:10000} + patchlevel=%{-p*:-p%{-p*}} +%{-s: + filelist='%{-s*}' + i=$base + while read checksum file; do + printf "patch%d %s\\n" $i "$patchlevel" | sed -e s,^,%%, + i=$((i+1)) + done < $filelist +} +%{!-s: start=$(expr $base + %1); end=$(expr $base + %{?2}%{!?2:%{1}}); echo ": patchset_patch %1%{?2: to %2}"; - seq -f 'patch%g %{-p*:-p%{-p*}}' $start $end | sed -e s,^,%%,; + seq -f "patch%g $patchlevel" $start $end | sed -e s,^,%%,; +} ) \ %{nil} @@ -2120,20 +2215,25 @@ else: \ # Requirements: # Requires: grep # Requires: sed >= 4.0 -# BuildRequires: rpmbuild(macros) >= 1.552 +# BuildRequires: rpmbuild(macros) >= 1.685 %nagios_nrpe(a:d:c:f:) {\ - m=$(md5sum < /etc/nagios/nrpe.cfg); \ + if %{__grep} -q '^include_dir=/etc/nagios/nrpe.d' /etc/nagios/nrpe.cfg && [ -d /etc/nagios/nrpe.d ]; then \ + file=/etc/nagios/nrpe.d/%{-a*}%{-d*}.cfg; \ + else \ + file=/etc/nagios/nrpe.cfg; \ + fi; \ + m=$(test -f $file && md5sum < $file); \ %{-a:# on -a and config exists \ if [ -f /etc/nagios/nrpe.cfg ]; then \ - if ! %{__grep} -q '^command\[%{-a*}\]' /etc/nagios/nrpe.cfg; then \ - %{__sed} -ne 's/^[ \t]*command_line[ \t]\+\(.\+\)/command[%{-a*}]=\1/p' %{-f*} >> /etc/nagios/nrpe.cfg; \ + if [ ! -f $file ] || ! %{__grep} -q '^command\[%{-a*}\]' $file; then \ + %{__sed} -ne 's/^[ \t]*command_line[ \t]\+\(.\+\)/command[%{-a*}]=\1/p' %{-f*} >> $file; \ fi; \ fi;} \ %{-d:# on package remove, -d and config exists \ - if [ "$1" = "0" -a -f /etc/nagios/nrpe.cfg ]; then \ - %{__sed} -i -e '/^[ \t]*command\[%{-d*}\]/d' /etc/nagios/nrpe.cfg; \ + if [ "$1" = "0" -a -f $file ]; then \ + %{__sed} -i -e '/^[ \t]*command\[%{-d*}\]/d' $file; \ fi;} \ - if [ "$m" != "$(md5sum < /etc/nagios/nrpe.cfg)" ]; then \ + if [ "$m" != "$(md5sum < $file)" ]; then \ %service -q nrpe restart; \ fi; \ }%{nil} @@ -2165,6 +2265,7 @@ fi; \ # pre/post script for -upstart subpackages # # Author: Jacek Konieczny +# Author: Elan Ruusamäe # # Usage: # %upstart_post service_name @@ -2178,15 +2279,16 @@ fi; \ # %upstart_postun %{name} # # Requirements: -# BuildRequires: rpmbuild(macros) >= 1.560 +# BuildRequires: rpmbuild(macros) >= 1.690 # Requires: rc-scripts >= 0.4.3 # migrate from init script to upstart job %upstart_post() \ - if [ -f /var/lock/subsys/%1 ]; then \ + if [ -x /sbin/initctl ] && [ -f /var/lock/subsys/%1 ]; then \ /sbin/service --no-upstart %1 stop \ /sbin/service %1 start \ - fi + fi \ +%{nil} # restart the job after upgrade or migrate to init script on removal # cannot be stopped with 'service' as /etc/init/$name.conf may be missing @@ -2195,7 +2297,8 @@ fi; \ if [ -x /sbin/initctl ] && /sbin/initctl status %1 2>/dev/null | grep -q 'running' ; then \ /sbin/initctl stop %1 >/dev/null 2>&1 \ [ -f /etc/rc.d/init.d/%1 -o -f /etc/init/%1.conf ] && { echo -n "Re-"; /sbin/service %1 start; }; \ - fi + fi \ +%{nil} # Haskell Macros # BuildRequires: rpmbuild(macros) >= 1.608 @@ -2323,6 +2426,18 @@ want_enable_service() { \ %{nil} %systemdunitdir /lib/systemd/system +%systemduserunitdir /usr/lib/systemd/user %systemdtmpfilesdir /usr/lib/tmpfiles.d +#----------------------------------------------------------------- +# Update hardware database index +# +# Requirements: +# BuildRequires: rpmbuild(macros) >= 1.691 +# Requires: udev-core >= 1:196 + +%udev_hwdb_update() \ +/sbin/udevadm hwdb --update >/dev/null 2>&1 || : \ +%{nil} + # EOF