2013-05-08 14:33:11 +04:00
% global _default_pid_dir / run
% global _default_dm_run_dir / run
% global _default_run_dir / run / lvm
% global _default_locking_dir / run / lock / lvm
% global _udevbasedir % { _prefix } / lib / udev
% global _udevdir % { _udevbasedir } / rules . d
2015-09-09 16:59:32 +03:00
% global _tmpfilesdir % { _prefix } / lib / tmpfiles . d
2013-05-08 14:33:11 +04:00
% if ! 0 % { ? fedora }
% global fedora 0
% endif
% if ! 0 % { ? rhel }
% global rhel 0
% endif
2016-09-16 18:30:01 +03:00
% global enableif () \
%% global configure_flags %% { ? configure_flags } --%% ( if test %% 1 - gt 0 ; then echo enable -%% 2 ; else echo disable -%% 2 ; fi )
2013-05-08 14:33:11 +04:00
2016-09-16 18:30:01 +03:00
% global with () \
%% global configure_flags %% ( echo - n " %% { ?configure_flags} " | sed - e " s,--with-%%1=[^ ]*,, " ; test - n " %% { ?2} " && echo -- with -%% 1 =%% 2 ) \
%% global with_flags %% ( echo - n " %% { ?with_flags} " | sed - e " s,%%1,, " ; test - n " %% { ?2} " && test " %% { ?2} " != none && echo %% 1 )
2013-05-08 14:33:11 +04:00
% global services monitor
2016-09-16 18:30:01 +03:00
% global service () \
%% global services %% ( echo - n " %% { ?services} " | sed - e s , %% 1 ,,; test " %%2 " = 1 && echo %% 1 )
2013-05-08 14:33:11 +04:00
2016-09-16 18:30:01 +03:00
% global maybe () \
%% if %% ( test - n " %% { ?2} " && echo 1 || echo 0 ) \
%%* \
%% endif
2013-05-08 14:33:11 +04:00
2016-09-16 18:30:01 +03:00
% global have_with () %% ( if echo %% { with_flags } | grep - q %% 1 ; then echo 1 ; else echo 0 ; fi )
% global have_service () %% ( if echo %% { services } | grep - q %% 1 ; then echo 1 ; else echo 0 ; fi )
2013-05-08 14:33:11 +04:00
2016-09-16 18:30:01 +03:00
% global daemon_reload \
%% if %% { enable_systemd } \
2015-09-09 16:59:32 +03:00
systemctl daemon - reload > / dev / null 2 >& 1 || : \
2016-09-16 18:30:01 +03:00
%% endif \
2013-05-08 14:33:11 +04:00
: \
2016-09-16 18:30:01 +03:00
%% { nil }
2013-05-08 14:33:11 +04:00
2016-09-16 18:30:01 +03:00
% global enable ( s : t : ) \
%% if %% { have_service %% { - s * }} \
%% if %% { enable_systemd } \
2015-09-09 16:59:32 +03:00
if [ $ 1 = 1 ]; then \
2016-09-16 18:30:01 +03:00
systemctl preset lvm2 -%% { - s * } .%% { - t * } > / dev / null 2 >& 1 || : \
2015-09-09 16:59:32 +03:00
fi \
2016-09-16 18:30:01 +03:00
%% else \
/ sbin / chkconfig -- add lvm2 -%% { - s * } \
%% endif \
%% endif \
2013-05-08 14:33:11 +04:00
: \
2016-09-16 18:30:01 +03:00
%% { nil }
2013-05-08 14:33:11 +04:00
2016-09-16 18:30:01 +03:00
% global disable ( s : t : ) \
%% if %% { have_service %% { - s * }} \
%% if %% { enable_systemd } \
2015-09-09 16:59:32 +03:00
if [ $ 1 = 0 ]; then \
2016-09-16 18:30:01 +03:00
systemctl -- no - reload disable lvm2 -%% { - s * } .%% { - t * } > / dev / null 2 >& 1 || : \
2020-10-02 23:13:51 +03:00
%% if " %% { -t*} " == " socket " \
2016-09-16 18:30:01 +03:00
systemctl -- no - reload disable lvm2 -%% { - s * } . service > / dev / null 2 >& 1 || : \
%% endif \
systemctl stop lvm2 -%% { - s * } .%% { - t * } > / dev / null 2 >& 1 || : \
2020-10-02 23:13:51 +03:00
%% if " %% { -t*} " == " socket " \
2016-09-16 18:30:01 +03:00
systemctl stop lvm2 -%% { - s * } . service > / dev / null 2 >& 1 || : \
%% endif \
2015-09-09 16:59:32 +03:00
fi \
2016-09-16 18:30:01 +03:00
%% else \
/ sbin / chkconfig -- del lvm2 -%% { - s * } \
%% endif \
%% endif \
2013-05-08 14:33:11 +04:00
: \
2016-09-16 18:30:01 +03:00
%% { nil }
2013-05-08 14:33:11 +04:00
2016-09-16 18:30:01 +03:00
% global try_restart ( s : t : ) \
%% if %% { have_service %% { - s * }} && %% { enable_systemd } \
2015-09-09 16:59:32 +03:00
if [ $ 1 = 1 ]; then \
2016-09-16 18:30:01 +03:00
systemctl try - restart lvm2 -%% { - s * } .%% { - t * } > / dev / null 2 >& 1 || : \
2015-09-09 16:59:32 +03:00
fi \
2016-09-16 18:30:01 +03:00
%% endif \
2015-09-09 16:59:32 +03:00
: \
2016-09-16 18:30:01 +03:00
%% { nil }
2024-04-12 02:10:49 +03:00
2024-04-15 17:43:44 +03:00
# Resolve RHEL minor version from redhat-release
2024-04-19 21:45:15 +03:00
% if 0 % { ? rhel } > 0
2024-04-15 17:43:44 +03:00
% define rhel_minor_version % ( rhel_version_file = " /etc/redhat-release " ;
2024-04-19 21:45:15 +03:00
if [ - f " $rhel_version_file " ]; then cat " $rhel_version_file " |
2024-04-15 17:43:44 +03:00
cut - f2 - d . | cut - f1 - d ' ' ; else echo 0 ; fi )
2024-04-19 21:45:15 +03:00
% endif
2024-04-15 17:43:44 +03:00
2024-04-12 02:10:49 +03:00
#############################################################
#
# Disable event_activation when creating packages for system
# with installed lvm2-testsuite
#
# This is used for internal package testing to avoid
# updating lvm.conf after test suite installation.
#
% define lvm2_testsuite_build % ( test - d / usr / share / lvm2 - testsuite && echo 0 || echo 1 )