]> git.pld-linux.org Git - packages/rpm-build-macros.git/blobdiff - rpm.macros
autotag: make git complatible (however needs to be in package dir)
[packages/rpm-build-macros.git] / rpm.macros
index 5875e026e475689e6515047b6bc8927b67d532ed..9bcf7a7d3b57f768f0311ba589eb7b141a799d0c 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 \
@@ -521,7 +521,9 @@ CXXFLAGS="%{rpmcxxflags}" \
                                        l=${l#/usr/share/man/}; \
                                        l=${l#/usr/X11R6/man/}; \
                                else \
-                                       l=$m; \
+                                       l=${a#$RPM_BUILD_ROOT$i/}; \
+                                       l=${l%/*}; \
+                                       l="$l/$m"; \
                                fi; \
                                rm -f $a; \
                                echo ".so $l" > $a; \
@@ -686,6 +688,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 +1029,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 +1274,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
 #
@@ -1448,7 +1477,7 @@ fi \
 
 # Command invoking PEAR CLI
 # Same as /usr/bin/pear, except we force GMT timezone
-%__pear        %__php -doutput_buffering=1 -dopen_basedir="" -dmemory_limit=-1 -ddate.timezone=GMT %{php_pear_dir}/pearcmd.php
+%__pear        %__php -doutput_buffering=1 -dopen_basedir="" -dmemory_limit=-1 -ddate.timezone=GMT /usr/share/pear/pearcmd.php
 
 %pear_install(a:d:n:zD) \
 %__pear \\\
@@ -1616,6 +1645,45 @@ done \
                                                                                                                                        \
 %{?-C:cd %{-C*}}                                                                                                       \
 compile() {                                                                                                                    \
+       local L="<" PATCH_SH;                                                                                   \
+       [[ '%{*}' != *$L$L* ]] || PATCH_SH="set -x -e;$(cat)"                   \
+       set -e -x                                                                                                               \
+                                                                                                                                       \
+       [ -r "%{_kernelsrcdir}/.config" ] || exit 1                                             \
+       rm -rf o                                                                                                                \
+       install -d o/include/linux o/include/generated o/arch/x86/include o/arch/powerpc/lib    \
+       ln -sf %{_kernelsrcdir}/.config o/.config                                               \
+       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        \
+       else                                                                                                                    \
+               ln -sf %{_kernelsrcdir}/include/linux/autoconf.h o/include/linux/autoconf.h \
+       fi                                                                                                                              \
+       if [ -d %{_kernelsrcdir}/arch/x86/include/generated ]; then             \
+               ln -s %{_kernelsrcdir}/arch/x86/include/generated o/arch/x86/include    \
+       fi                                                                                                                              \
+                                                                                                                                       \
+       set +x                                                                                                                  \
+       [ -z "$PATCH_SH" ] || echo "$PATCH_SH" | %__spec_build_shell    \
+       set -x                                                                                                                  \
+                                                                                                                                       \
+       install -d o/include/config                                                                             \
+       touch o/include/config/MARKER                                                                   \
+       ln -sf %{_kernelsrcdir}/include/config/auto.conf o/include/config/auto.conf     \
+       ln -sf %{_kernelsrcdir}/scripts o/scripts                                               \
+                                                                                                                                       \
+       %{!?-c:%{__make} -C %{_kernelsrcdir} clean                                              \\\
+               RCS_FIND_IGNORE="-name '*.[ks]o' -o"                                            \\\
+               ${1+"$@"}                                                                                                       \\\
+               M=$PWD %{MakeOpts}}                                                                                     \
+                                                                                                                                       \
+       %{__make} -C %{_kernelsrcdir} modules                                                   \\\
+               ${1+"$@"}                                                                                                       \\\
+               M=$PWD CONSTIFY_PLUGIN="" %{MakeOpts}                                           \
+%{?-C:cd -}                                                                                                                    \
+}                                                                                                                                      \
+compile_old() {                                                                                                                \
        local L="<" PATCH_SH;                                                                                   \
        [[ '%{*}' != *$L$L* ]] || PATCH_SH="set -x -e;$(cat)"                   \
        set -e -x                                                                                                               \
@@ -1665,7 +1733,11 @@ for cfg in ${cfgs:-dist}; do                                        \
 done                                                                                                                           \
 %{?-C:cd -}                                                                                                                    \
 }                                                                                                                                      \
-compile %{*}\
+if [ -r "%{_kernelsrcdir}/.config" ]; then     \
+       compile %{*}                                                    \
+else                                                                           \
+       compile_old %{*}                                                \
+fi                                                                                     \
 %{nil}
 
 
@@ -1694,6 +1766,17 @@ compile %{*}\
 %define ModprobeD $RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d/%{_kernel_ver} \
                                                                                                                                        \
 __install_kernel_modules() {                                                                           \
+%{!?debug:set +x;} \
+                                                                                                                                       \
+for MODULE in {%{-m*},}; do                                                                                    \
+       [ -n "${MODULE}" ] || continue                                                                  \
+       MNAME=${MODULE##*/}                                                                                     \
+       install -D ${MODULE}.ko %{KernelD}/%{-d*}/${MNAME}%{-s:-%{-s*}}.ko      \
+       %{?-s:install -d %{ModprobeD}                                                   \
+               echo "alias ${MNAME} ${MNAME}-%{-s*}" >> %{ModprobeD}/%{-n*}.conf}      \
+done                                                                                                                           \
+}                                                                                                                                      \
+__install_kernel_modules_old() {                                                                       \
 %{!?debug:set +x;} \
 local cfgs='%{?with_dist_kernel:%{?with_smp: smp}%{?with_up: up}}%{!?with_dist_kernel: nondist}' \
                                                                                                                                        \
@@ -1710,7 +1793,11 @@ for MODULE in {%{-m*},}; do                                                                                      \
        done                                                                                                                    \
 done                                                                                                                           \
 }                                                                                                                                      \
-__install_kernel_modules                                                                                       \
+if [ -r "%{_kernelsrcdir}/.config" ]; then     \
+       __install_kernel_modules                                \
+else                                                                           \
+       __install_kernel_modules_old                    \
+fi                                                                                     \
 %{nil}
 
 # patchset macros
@@ -1754,6 +1841,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 +2074,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,53 +2135,117 @@ else: \
 %{nil}
 
 
-# pre/post script for -systemd subpackages
+# pre/post script for packages supporting systemd units
 #
 # Author: Bartlomiej Zimon <uzi18@o2.pl>
+#                Jan Rękorajski <baggins@mimuw.edu.pl>
 #
 # Usage:
 # %systemd_reload
+# %systemd_service <unit command> service_name1.service service_name2.service
+# %systemd_service_enable service_name1.service service_name2.service
+# %systemd_service_disable service_name1.service service_name2.service
+# %systemd_service_start service_name1.service service_name2.service
+# %systemd_service_stop service_name1.service service_name2.service
+# %systemd_service_restart service_name1.service service_name2.service
+# %systemd_service_reload service_name1.service service_name2.service
+#
 # %systemd_post service_name1.service service_name2.service
-# %systemd_preun  service_name1.service service_name2.service
+# %systemd_preun service_name1.service service_name2.service
+# %systemd_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.626
-# Requires:     systemd-units >= 37-0.10
+# BuildRequires:       rpmbuild(macros) >= 1.647
+# Requires:    systemd-units >= 38
 
 %systemd_reload /bin/systemd_booted && SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog /bin/systemctl --quiet daemon-reload || :
 
+%systemd_service_enable() \
+       export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog \
+       /bin/systemctl --quiet enable %{*} || : \
+       /bin/systemd_booted && echo 'Run "/bin/systemctl start %{*}" to start %{*}.' || : \
+%{nil}
+
+%systemd_service_disable() \
+       export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog \
+       /bin/systemctl --quiet disable %{*} || : \
+%{nil}
+
+%systemd_service() \
+       export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog \
+       /bin/systemd_booted && /bin/systemctl --quiet %{*} || : \
+%{nil}
+
+%systemd_service_start() \
+       export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog \
+       /bin/systemd_booted && /bin/systemctl --quiet start %{*} || : \
+%{nil}
+
+%systemd_service_stop() \
+       export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog \
+       /bin/systemd_booted && /bin/systemctl --quiet stop %{*} || : \
+%{nil}
+
+%systemd_service_restart() \
+       export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog \
+       /bin/systemd_booted && /bin/systemctl --quiet try-restart %{*} || : \
+%{nil}
+
+%systemd_service_reload() \
+       export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog \
+       /bin/systemd_booted && /bin/systemctl --quiet reload %{*} || : \
+%{nil}
+
+%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 || : \
        if [ $1 -eq 1 ]; then \
                /bin/systemctl --quiet enable %{*} || : \
+               /bin/systemd_booted && echo 'Run "/bin/systemctl start %{*}" to start %{*}.' || : \
+       elif [ -z "$NORESTART" ]; then \
+               /bin/systemd_booted && /bin/systemctl --quiet try-restart %{*} || : \
+       else \
+               /bin/systemd_booted && echo 'Run "/bin/systemctl restart %{*}" to restart %{*}.' || : \
        fi \
-       if [ $1 -gt 1 ]; 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 %{*} || : \
-               if /bin/systemd_booted; then \
-                       /bin/systemctl --quiet stop %{*} || : \
-               fi \
-       fi
+               export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog \
+               /bin/systemd_booted && /bin/systemctl --quiet stop %{*} || : \
+               /bin/systemctl --quiet disable %{*} || : \
+       fi \
+%{nil}
 
 %systemdunitdir /lib/systemd/system
+%systemdtmpfilesdir /usr/lib/tmpfiles.d
 
 # EOF
This page took 0.048963 seconds and 4 git commands to generate.