# $Revision$, $Date$
-# PLD Linux rpm macros
+# PLD Linux rpm macros.
+# <http://www.pld-linux.org/>
+
+# can be used by builder script to to check for version
+%rpm_build_macros %(R="$Revision$"; RR="${R##: }"; echo ${RR%%?})
%epoch 0
%x8664 x86_64 amd64 ia32e
# add parallel build flags: -jN
#
-# if you want to disable parallel build do (replace %% with %)
-# echo '%%_smp_mflags %%{nil}' >> ~/.rpmmacros
+# if you want to disable parallel build do:
+# echo '%_smp_mflags %{nil}' >> ~/.rpmmacros
#
-%__make make %{?_smp_mflags}
-%__scons scons %{?_smp_mflags}
-%__waf waf %{?_smp_mflags}
-%__cmake cmake %{?_smp_mflags}
+%__make /usr/bin/make %{?_smp_mflags}
+%__scons /usr/bin/scons %{?_smp_mflags}
+%__waf /usr/bin/waf %{?_smp_mflags}
+%__cmake /usr/bin/cmake
%_smp_mflags %(_NCPUS=$(/usr/bin/getconf _NPROCESSORS_ONLN); \\\
[ "$_NCPUS" -gt 1 ] && echo "-j$(($_NCPUS * 2))")
%__intltoolize intltoolize --copy --force
%__libtoolize libtoolize --copy --force --install
-# Path to top of build area.
-%_topdir %{expand:%%global _topdir %(test -d ../SPECS -a -d ../SOURCES && (cd ..; pwd) || echo $HOME/rpm)}%_topdir
+# topdir is where builder script lives, fallback to old style if builder script was not found and
+# SPECS/SOURCES dirs exist (XXX: should be reverse?)
+%_topdir %{expand:%%global _topdir %(d=;\
+ d=${d:-$([ -d ../SPECS -a -d ../SOURCES ] && (cd .. && pwd))};\
+ d=${d:-$([ -x ../builder ] && (cd ..; pwd))};\
+ d=${d:-$([ -x builder ] && pwd)};\
+ echo ${d:-$HOME/rpm};\
+)}%_topdir
+
+# if %{_topdir}/builder exists, it's new style structure
+%_specdir %{expand:%%global _specdir %([ -x %{_topdir}/builder ] && echo %{_topdir}/%{name} || echo %{_topdir}/SPECS)}%_specdir
+%_sourcedir %{expand:%%global _sourcedir %([ -x %{_topdir}/builder ] && echo %{_specdir} || echo %{_topdir}/SOURCES)}%_sourcedir
+
+# BUILD/RPMS/SRPMS are one 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})
+%_builddir %{expand:%%global _builddir %([ -d %{_topdir}/../BUILD ] && (cd %{_topdir}/../BUILD; pwd) || echo %{_topdir}/BUILD)}%_builddir
+%_rpmdir %{expand:%%global _rpmdir %([ -d %{_topdir}/../RPMS ] && (cd %{_topdir}/../RPMS; pwd) || echo %{_topdir}/RPMS)}%_rpmdir
+%_srcrpmdir %{expand:%%global _srcrpmdir %([ -d %{_topdir}/../SRPMS ] && (cd %{_topdir}/../SRPMS; pwd) || echo %{_topdir}/SRPMS)}%_srcrpmdir
# The number of cvs changelog entries kept when building package.
%_buildchangelogtruncate 20
%{dependencytracking} \
}
-%__cmake /usr/bin/cmake
%cmake { \
CC="%{__cc}" \
CXX="%{__cxx}" \
%{__cmake} \
}
-# override __scons to add -j4 in your ~/.rpmmacros for parallel make
-%__scons /usr/bin/scons
%scons { \
%{__scons} \
LDFLAGS="${LDFLAGS:-%rpmldflags}" \
}
# waf. see waf.spec
-# override __waf to add -j4 in your ~/.rpmmacros for parallel make
-%__waf /usr/bin/waf
%waf { \
CC="%{__cc}" \
CXX="%{__cxx}" \
%{?configure_cache:--cache-file=%{configure_cache_file}} \
}
+# Simple macros to simplify adding bconded options to configure scripts.
+# Each macro requires bcond name and accepts optional option name, if option
+# isn't specified bcond name is used as option name. Options returning
+# --with and --enable also allow third argument which will be added as value
+# ( --with-option=value or --enable-option=value ) in case or positive
+# condition, but won't be added otherwise ( nothing or just --disable-option ).
+
+# Requirements:
+# BuildRequires: rpmbuild(macros) >= 1.527
+
+# Usage example:
+# %{__enable bcond} - returns --enable-bcond iff build condition is set
+# %{__disable bcond option} - returns --enable-option iff bcond is not set
+# %{__enable_disable bcond option value} - returns --enable-option=value if
+# bcond is set, returns --disable-option otherwise
+
+# expand bconds to --enable-something and --disable-something
+%__enable() %{expand:%%{?with_%{1}:--enable-%{?2}%{!?2:%{1}}%{?3:=%{3}}}}
+%__disable() %{expand:%%{!?with_%{1}:--disable-%{?2}%{!?2:%{1}}}}
+%__enable_disable() %{expand:%%{?with_%{1}:--enable-%{?2}%{!?2:%{1}}%{?3:=%{3}}}%%{!?with_%{1}:--disable-%{?2}%{!?2:%{1}}}}
+
+# same as above, but condition inverted
+%__enable_unless() %{expand:%%{!?with_%{1}:--enable-%{?2}%{!?2:%{1}}%{?3:=%{3}}}}
+%__disable_if() %{expand:%%{?with_%{1}:--disable-%{?2}%{!?2:%{1}}}}
+%__enable_disable_not() %{expand:%%{!?with_%{1}:--enable-%{?2}%{!?2:%{1}}%{?3:=%{3}}}%%{?with_%{1}:--disable-%{?2}%{!?2:%{1}}}}
+
+# expand bconds to --with-something and --without-something
+%__with() %{expand:%%{?with_%{1}:--with-%{?2}%{!?2:%{1}}%{?3:=%{3}}}}
+%__without() %{expand:%%{!?with_%{1}:--without-%{?2}%{!?2:%{1}}}}
+%__with_without() %{expand:%%{?with_%{1}:--with-%{?2}%{!?2:%{1}}%{?3:=%{3}}}%%{!?with_%{1}:--without-%{?2}%{!?2:%{1}}}}
+
+# same as above, but condition inverted
+%__with_unless() %{expand:%%{!?with_%{1}:--with-%{?2}%{!?2:%{1}}%{?3:=%{3}}}}
+%__without_if() %{expand:%%{?with_%{1}:--without-%{?2}%{!?2:%{1}}}}
+%__with_without_not() %{expand:%%{!?with_%{1}:--with-%{?2}%{!?2:%{1}}%{?3:=%{3}}}%%{?with_%{1}:--without-%{?2}%{!?2:%{1}}}}
+
+#-----------------------------------------------------------------
+
# overload to insert debuginfo package
%prep \
%if 0%{?_enable_debug_packages}\
# The directory holding Linux kernel sources
%_kernelsrcdir /usr/src/linux%{_alt_kernel}
+# SysV-style initscripts dir
+%_initddir /etc/rc.d/init.d
+
# If non-empty "debug" macro defined, add "dbg" suffix to release number
%_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
+# -n drm to generate kernel%{_alt_kernel}-drm dependency
+%releq_kernel(n:) %{expand:%%global releq_kernel %(R=$(LC_ALL=C rpm -q --qf '%{N}%{?-n:-%{-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
+%releq_kernel_up(n:) %{expand:%%global releq_kernel_up %(R=$(LC_ALL=C rpm -q --qf '%{N}%{?-n:-%{-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_up
+%releq_kernel_smp(n:) %{expand:%%global releq_kernel_smp %(R=$(LC_ALL=C rpm -q --qf '%{N}%{?-n:-%{-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})}%releq_kernel_smp
-%releq_kernel %{expand:%%global 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
-%releq_kernel_up %{expand:%%global 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_up
-%releq_kernel_smp() %{expand:%%global 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})}%releq_kernel_smp
-%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
+# -s post to generate Requires(post) dependency
+%requires_releq_kernel(s:n:) Requires%{-s:(%{-s*})}: %releq_kernel
+%requires_releq_kernel_up(s:n:) Requires%{-s:(%{-s*})}: %releq_kernel_up
+%requires_releq_kernel_smp(s:n:) Requires%{-s:(%{-s*})}: %releq_kernel_smp
# Requires name = version-release
%requires_releq() %{!?1:ERROR}%{?2:ERROR}%{?1:%{!?2:%{expand:%%requires_eq_to -r %1 %1}}}
fi; \
fi; }; __spec_install_post_chrpath } } }
+# vim: "
+
#-----------------------------------------------------------------
# Find all shared object files with unresolved symbols. Warn
# and terminate if any found (termination can be turned off by define).
# extract php/zend api versions
%php_major_version %{expand:%%global php_major_version %(awk '/#define PHP_MAJOR_VERSION/{print $3}' %{php_includedir}/main/php_version.h 2>/dev/null || echo ERROR)}%php_major_version
+%php_minor_version %{expand:%%global php_minor_version %(awk '/#define PHP_MINOR_VERSION/{print $3}' %{php_includedir}/main/php_version.h 2>/dev/null || echo ERROR)}%php_minor_version
%php_api_version %{expand:%%global php_api_version %(awk '/#define PHP_API_VERSION/{print $3}' %{php_includedir}/main/php.h 2>/dev/null || echo ERROR)}%php_api_version
%php_pdo_api_version %{expand:%%global 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_pdo_api_version
%php_debug %{expand:%%global php_debug %(awk '/#define ZEND_DEBUG/{print $3}' %{php_includedir}/main/php_config.h 2>/dev/null || echo ERROR)}%php_debug
%xorg_xserver_font_abi %{expand:%%global xorg_xserver_font_abi %(awk '/#define ABI_FONT_VERSION/ { split($0,A,/[(,)]/); printf("%d.%d",A[2], A[3]); }' /usr/include/xorg/xf86Module.h 2> /dev/null | echo ERROR)}%xorg_xserver_font_abi
%xorg_xserver_videodrv_abi %{expand:%%global xorg_xserver_videodrv_abi %(awk '/#define ABI_VIDEODRV_VERSION/ { split($0,A,/[(,)]/); printf("%d.%d",A[2], A[3]); }' /usr/include/xorg/xf86Module.h 2> /dev/null || echo ERROR)}%xorg_xserver_videodrv_abi
%xorg_xserver_xinput_abi %{expand:%%global xorg_xserver_xinput_abi %(awk '/#define ABI_XINPUT_VERSION/ { split($0,A,/[(,)]/); printf("%d.%d",A[2], A[3]); }' /usr/include/xorg/xf86Module.h 2> /dev/null || echo ERROR)}%xorg_xserver_xinput_abi
+# vim: '
%requires_xorg_xserver_extension \
%{__xorg_abi_requires_ge ansic xorg_xserver_ansic_abi} \
# Python 3.x
# python main version
-%__python3 python3.0
+%__python3 python3
%py3_ver %{expand:%%global py3_ver %(%{__python3} -c "import sys; print(sys.version[:3])" 2>/dev/null || echo ERROR)}%py3_ver
# directories
%xmms_effect_plugindir %{expand:%%global xmms_effect_plugindir %(xmms-config --effect-plugin-dir 2>/dev/null || echo ERROR)}%xmms_effect_plugindir
%xmms_general_plugindir %{expand:%%global xmms_general_plugindir %(xmms-config --general-plugin-dir 2>/dev/null || echo ERROR)}%xmms_general_plugindir
-%_target_base_arch %{expand:%%global _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/')}%_target_base_arch
+%_target_base_arch %{expand:%%global _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/;s/sparcv./sparc/')}%_target_base_arch
# user/group checking macros
#
%{expand:%{%{#}}} 1>&2 || exit $? \
[ ! -x /usr/sbin/nscd ] || /usr/sbin/nscd -i passwd || : \
fi;
+# vim: "
# Usage:
# %groupadd [-P package] [-g gid] group
#
# Add package's webserver config to webserver webapps dir.
# Usage:
-# %webapp_register WEBSERVER WEBAPP
+# %webapp_register [-f] WEBSERVER WEBAPP
#
-%webapp_register() \
+%webapp_register(f) \
%{?debug:set -x; echo "webapp_register: %{name}-%{version}-%{release} 1:[$1]; 2:[$2]"} \
-if [ "$1" = "1" ] && [ "$2" = "1" ]; then\
+if [ -n "%{-f:1}" ] || [ "$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\
}; __py_lint %* \
%{nil}
-# vim:ts=4 sw=4 noet syn=spec
+# Undos files
+#
+# Author: Paweł Zuzelski <pawelz@pld-linux.org>
+#
+# Usage:
+# %undos list_of_files
+#
+# Requirements:
+# BuildRequires: sed >= 4.0
+# BuildRequires: rpmbuild(macros) >= 1.533
+
+%undos \
+%{__sed} -i -e 's,\\r$,,'
+
+# vim:ts=4 sw=4 noet ft=spec