]> git.pld-linux.org Git - packages/rpm-build-macros.git/blobdiff - rpm.macros
- 1.640
[packages/rpm-build-macros.git] / rpm.macros
index 9e895b46244bdb8dd790bd53dd3eb696dfcbc8f8..08bcc8f8c14ef4d3d735a45609a2f4e78f70a6bf 100644 (file)
@@ -37,7 +37,7 @@
 %__cmake       /usr/bin/cmake
 
 %_smp_mflags %(_NCPUS=$(/usr/bin/getconf _NPROCESSORS_ONLN); \\\
-                               [ "$_NCPUS" -gt 1 ] && echo "-j$(($_NCPUS * 2))")
+                               [ "$_NCPUS" -gt 2 ] && echo "-j$(($_NCPUS / 2))")
 
 %__gettextize { \
        if grep -qs 'AM_GNU_GETTEXT.*external' configure.{ac,in} ; then \
@@ -686,6 +686,30 @@ __spec_install_post_check_so() { \
        %{!?no_install_post_check_so:return $fail;} \
 }; __spec_install_post_check_so }}
 
+#-----------------------------------------------------------------
+# Verify that for each directory under /var/run package contains
+# tmpfiles.d configuration. Warn and terminate build if config is
+# missing.
+#
+#%no_install_post_check_tmpfiles 1
+#
+%__spec_install_post_check_tmpfiles { \
+__spec_install_post_check_tmpfiles() { \
+%{!?debug:set +x;} \
+       fail=0; \
+       echo "Checking /var/run <-> tmpfiles.d completeness..."; \
+       for d in $RPM_BUILD_ROOT/var/run/*; do \
+               [ -d "$d" ] || continue; \
+               d=${d##$RPM_BUILD_ROOT}; \
+               if ! grep -qsF "$d" $RPM_BUILD_ROOT/usr/lib/tmpfiles.d/*.conf $RPM_BUILD_ROOT/etc/tmpfiles.d/*.conf; then\
+                   echo "No tmpfiles configuration for '$d'";\
+                       fail=1 ; \
+               fi \
+       done ; \
+       echo " DONE"; \
+       %{!?no_install_post_check_tmpfiles:return $fail;} \
+}; __spec_install_post_check_tmpfiles }}
+
 #-----------------------------------------------------------------
 # Find and gzip all kernel modules
 #
@@ -1003,6 +1027,10 @@ fi \
 
 %py3_ocomp             %{__python3} -O -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
 
+# node.js libdir
+# Requirements:
+# BuildRequires: rpmbuild(macros) >= 1.634
+%nodejs_libdir         /usr/lib/node_modules
 
 # Hardlink binary identical .pyc and .pyo files
 %__spec_install_post_py_hardlink {\
@@ -1244,8 +1272,7 @@ fi \
 # Requires:    rc-scripts
 # -n option:
 # BuildRequires:       rpmbuild(macros) >= 1.450
-%service(qn) {{%(export noop=%{-n:1} quiet=%{-q:1}; /usr/lib/rpm/service_generator.sh %{*}) };}
-
+%service(qn) {{%(export noop=%{-n:1} quiet=%{-q:1} RPM_BUILD_ROOT=%{buildroot}; /usr/lib/rpm/service_generator.sh %{*}) };}
 
 # Java macros. based on jpackage macros.java
 #
@@ -1754,6 +1781,9 @@ __install_kernel_modules                                                                                  \
 ) \
 %{nil}
 
+# return EXPANDED source url N from current spec
+%sourceurl(n:) %(test "$IN_RPM" = 1 && exit 1; export IN_RPM=1; rpmbuild --nodigest --nosignature --nobuild -D "prep %%dump" %{_specdir}/%{name}.spec 2>&1 | awk '$2 ~ /^SOURCEURL%{-n*}/ {print $3}')
+
 # browser plugins v2
 # Author: Elan Ruusamäe <glen@pld-linux.org>
 #
@@ -1984,10 +2014,15 @@ else: \
 # %cacti_import_template %{resourcedir}/cacti_host_template_varnish.xml
 #
 # Requires:    cacti >= 0.8.7e-8
-# BuildRequires:       rpmbuild(macros) >= 1.554
+# BuildRequires:       rpmbuild(macros) >= 1.630
+# Note: 1.1 (cacti-0.8.7h) adds requirement for --with-template-rras or --with-user-rras option
 
 %cacti_import_template() {\
-/usr/share/cacti/cli/import_template.php --filename=%1 || :; \
+v=$(%{__sed} -rne 's/.+Add Graphs Script ([0-9\.]+).+/\1/p' /usr/share/cacti/cli/import_template.php); \
+if [ "$v" != "1.0" ]; then \
+       rra="--with-template-rras"; \
+fi; \
+/usr/share/cacti/cli/import_template.php --filename=%1 $rra || :; \
 }%{nil}
 
 # pre/post script for -upstart subpackages
@@ -2040,34 +2075,50 @@ else: \
 %{nil}
 
 
-# pre/post script for -systemd subpackages
+# pre/post script for packages supporting systemd units
 #
 # Author: Bartlomiej Zimon <uzi18@o2.pl>
 #
 # Usage:
 # %systemd_reload
 # %systemd_post service_name1.service service_name2.service
-# %systemd_preun  service_name1.service service_name2.service
+# %systemd_preun service_name1.service service_name2.service
+# %systend_trigger service_name1.service service_name2.service
 #
 # Sample:
-# %post systemd
-# %systemd_reload
-# or if service must be enabled by default:
-# %post systemd
+# %post
 # %systemd_post %{name}.service
 #
-# %preun systemd
+# %preun
 # %systemd_preun %{name}.service
 #
-# %postun systemd
+# %postun
 # %systemd_reload
 #
+# %triggerpostun -- %{name} < first-version-with-systemd-units
+# %systemd_trigger %{name}.service
+#
 # Requirements:
 # BuildRequires: rpmbuild(macros) >= 1.627
 # Requires:     systemd-units >= 37-0.10
 
 %systemd_reload /bin/systemd_booted && SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog /bin/systemctl --quiet daemon-reload || :
 
+%systemd_trigger() \
+want_enable_service() { \
+       [ -f /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm \
+       [ ${RPM_ENABLE_SYSTEMD_SERVICE:-yes} = no ] && return 1 \
+       /sbin/chkconfig --list ${1%.service} 2>/dev/null | grep -qsv "[0-6]:on" && return 1 \
+       return 0 \
+}\
+       export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog \
+       for s in %{*}; do \
+               if want_enable_service $s; then \
+                       /bin/systemctl --quiet enable $s || : \
+               fi \
+       done \
+%{nil}
+
 %systemd_post() \
        export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog \
        /bin/systemd_booted && /bin/systemctl --quiet daemon-reload || : \
@@ -2077,15 +2128,17 @@ else: \
        if [ $1 -gt 1 ] && [ -z "$NORESTART" ]; then \
                /bin/systemctl --quiet try-restart %{*} || : \
        fi \
+%{nil}
 
 %systemd_preun() \
        if [ $1 -eq 0 ]; then \
                export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog; \
-               /bin/systemctl --no-reaload --quiet disable %{*} || : \
+               /bin/systemctl --no-reload --quiet disable %{*} || : \
                if /bin/systemd_booted; then \
                        /bin/systemctl --quiet stop %{*} || : \
                fi \
-       fi
+       fi \
+%{nil}
 
 %systemdunitdir /lib/systemd/system
 
This page took 0.046033 seconds and 4 git commands to generate.