Signed-off-by: Martin Wilck <mwilck@xxxxxxxx> Reviewed-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx> --- Makefile.inc | 17 ++++++++++++++--- kpartx/kpartx_id | 8 ++++---- multipath/11-dm-mpath.rules.in | 4 ++-- multipath/multipath.rules.in | 6 +++--- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/Makefile.inc b/Makefile.inc index 28b6032..fe9f1bf 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -42,9 +42,11 @@ etc_prefix := $(prefix) # Where to install systemd-related files. systemd is usually installed under /usr # Note: systemd installations with "split-usr=true" use separate "prefixdir" and # "rootprefixdir". Our systemd_prefix corresponds to "prefixdir". -# In this case, override only unitdir and libudevdir below to use -# systemd's "rootprefixdir" instead of $(systemd_prefix) +# In this case, override only unitdir, libudevdir and sys_execprefix below +# to use systemd's "rootprefixdir" instead of $(systemd_prefix) systemd_prefix := /usr +# Prefix for binaries that are owned by other packages (including systemd) +sys_execprefix := /usr # Make sure all prefix variables end in "/" append-slash = $(1)$(if $(filter %/,$(1)),,/) @@ -53,6 +55,7 @@ override exec_prefix := $(call append-slash,$(exec_prefix)) override usr_prefix := $(call append-slash,$(usr_prefix)) override etc_prefix := $(call append-slash,$(etc_prefix)) override systemd_prefix := $(call append-slash,$(systemd_prefix)) +override sys_execprefix := $(call append-slash,$(sys_execprefix)) unitdir := $(systemd_prefix)lib/systemd/system tmpfilesdir := $(systemd_prefix)lib/tmpfiles.d @@ -74,6 +77,7 @@ runtimedir := $(if $(shell test -L /var/run -o ! -d /var/run && echo 1),/ru devmapper_incdir := $(or $(shell $(PKG_CONFIG) --variable=includedir devmapper),/usr/include) libudev_incdir := $(or $(shell $(PKG_CONFIG) --variable=includedir libudev),/usr/include) kernel_incdir := /usr/include +sysdir_bin := $(sys_execprefix)bin ifeq ($(V),) Q := @ @@ -150,4 +154,11 @@ NV_VERSION_SCRIPT = $(DEVLIB:%.so=%-nv.version) %: %.in @echo creating $@ - $(Q)sed 's:@CONFIGFILE@:'$(TGTDIR)$(configfile)':g;s:@CONFIGDIR@:'$(TGTDIR)$(configdir)':g;s:@STATE_DIR@:'$(TGTDIR)$(statedir)':g;s:@RUNTIME_DIR@:'$(runtimedir)':g;s/@MODPROBE_UNIT@/'$(MODPROBE_UNIT)'/g;s:@BINDIR@:'$(TGTDIR)$(bindir)':g' $< >$@ + $(Q)sed -e 's:@CONFIGFILE@:'$(TGTDIR)$(configfile)':g' \ + -e 's:@CONFIGDIR@:'$(TGTDIR)$(configdir)':g' \ + -e 's:@STATE_DIR@:'$(TGTDIR)$(statedir)':g' \ + -e 's:@BINDIR@:'$(TGTDIR)$(bindir)':g' \ + -e 's:@SYSDIR_BIN@:'$(sysdir_bin)': g' \ + -e 's:@RUNTIME_DIR@:'$(runtimedir)':g' \ + -e 's/@MODPROBE_UNIT@/'$(MODPROBE_UNIT)'/g' \ + $< >$@ diff --git a/kpartx/kpartx_id b/kpartx/kpartx_id index 4672927..f9211d2 100755 --- a/kpartx/kpartx_id +++ b/kpartx/kpartx_id @@ -21,8 +21,6 @@ # sent upstream but has not been accepted yet. # -DMSETUP=/sbin/dmsetup - MAJOR=$1 MINOR=$2 UUID=$3 @@ -32,12 +30,14 @@ if [ -z "$MAJOR" -o -z "$MINOR" ]; then exit 1; fi +DMSETUP=$(command -v dmsetup) || DMSETUP=/sbin/dmsetup + # Device-mapper not installed; not an error -if [ ! -x $DMSETUP ] ; then +if [ ! -x "$DMSETUP" ] ; then + echo "$0: dmsetup not found" >&2 exit 0 fi - # Table UUIDs are always '<type>-<uuid>'. dmuuid=${UUID#*-} dmtbl=${UUID%%-*} diff --git a/multipath/11-dm-mpath.rules.in b/multipath/11-dm-mpath.rules.in index 0562edd..30647b9 100644 --- a/multipath/11-dm-mpath.rules.in +++ b/multipath/11-dm-mpath.rules.in @@ -9,7 +9,7 @@ ENV{.DM_SUSPENDED}!="?*", ENV{.DM_SUSPENDED}="$env{DM_SUSPENDED}" # Coldplug event while device is suspended (e.g. during a reload) ACTION=="add", ENV{DM_ACTIVATION}=="1", ENV{.DM_SUSPENDED}=="1", \ - PROGRAM="/bin/logger -t 11-dm-mpath.rules -p daemon.warning \"Coldplug event for suspended device\"", \ + PROGRAM="@SYSDIR_BIN@/logger -t 11-dm-mpath.rules -p daemon.warning \"Coldplug event for suspended device\"", \ ENV{DM_COLDPLUG_SUSPENDED}="1", GOTO="scan_import" # Coldplug event. Import previously set properties. @@ -70,7 +70,7 @@ LABEL="check_mpath_unchanged" IMPORT{db}="DM_COLDPLUG_SUSPENDED" ENV{DM_COLDPLUG_SUSPENDED}=="1", ENV{.DM_SUSPENDED}!="1", \ ENV{DM_ACTIVATION}="1", ENV{MPATH_UNCHANGED}="0", \ - PROGRAM="/bin/logger -t 11-dm-mpath.rules -p daemon.notice \"Forcing activation of previously suspended device\"", \ + PROGRAM="@SYSDIR_BIN@/logger -t 11-dm-mpath.rules -p daemon.notice \"Forcing activation of previously suspended device\"", \ GOTO="check_mpath_ready" # DM_SUBSYSTEM_UDEV_FLAG0 is the "RELOAD" flag for multipath subsystem. diff --git a/multipath/multipath.rules.in b/multipath/multipath.rules.in index 780bf85..2ac1972 100644 --- a/multipath/multipath.rules.in +++ b/multipath/multipath.rules.in @@ -2,7 +2,7 @@ SUBSYSTEM!="block", GOTO="end_mpath" KERNEL!="sd*|dasd*|nvme*", GOTO="end_mpath" ACTION=="remove", TEST=="@RUNTIME_DIR@/multipath/find_multipaths/$major:$minor", \ - RUN+="/usr/bin/rm -f @RUNTIME_DIR@/multipath/find_multipaths/$major:$minor" + RUN+="@SYSDIR_BIN@/rm -f @RUNTIME_DIR@/multipath/find_multipaths/$major:$minor" ACTION!="add|change", GOTO="end_mpath" IMPORT{cmdline}="nompath" @@ -69,7 +69,7 @@ ENV{.SAVED_FM_WAIT_UNTIL}=="?*", GOTO="pretend_mpath" # # We must trigger an "add" event because LVM2 will only act on those. -RUN+="/usr/bin/systemd-run --unit=cancel-multipath-wait-$kernel --description 'cancel waiting for multipath siblings of $kernel' --no-block --timer-property DefaultDependencies=no --timer-property Conflicts=shutdown.target --timer-property Before=shutdown.target --timer-property Conflicts=initrd-cleanup.service --timer-property Before=initrd-cleanup.service --timer-property AccuracySec=500ms --property DefaultDependencies=no --property Conflicts=shutdown.target --property Before=shutdown.target --property Conflicts=initrd-cleanup.service --property Before=initrd-cleanup.service --on-active=$env{FIND_MULTIPATHS_WAIT_UNTIL} /usr/bin/udevadm trigger --action=add $sys$devpath" +RUN+="@SYSDIR_BIN@/systemd-run --unit=cancel-multipath-wait-$kernel --description 'cancel waiting for multipath siblings of $kernel' --no-block --timer-property DefaultDependencies=no --timer-property Conflicts=shutdown.target --timer-property Before=shutdown.target --timer-property Conflicts=initrd-cleanup.service --timer-property Before=initrd-cleanup.service --timer-property AccuracySec=500ms --property DefaultDependencies=no --property Conflicts=shutdown.target --property Before=shutdown.target --property Conflicts=initrd-cleanup.service --property Before=initrd-cleanup.service --on-active=$env{FIND_MULTIPATHS_WAIT_UNTIL} @SYSDIR_BIN@/udevadm trigger --action=add $sys$devpath" LABEL="pretend_mpath" ENV{DM_MULTIPATH_DEVICE_PATH}="1" @@ -85,7 +85,7 @@ ENV{FIND_MULTIPATHS_WAIT_UNTIL}!="?*", GOTO="end_mpath" ENV{FIND_MULTIPATHS_WAIT_UNTIL}=="0", GOTO="end_mpath" ENV{FIND_MULTIPATHS_WAIT_CANCELLED}="1" -RUN+="/usr/bin/systemctl stop cancel-multipath-wait-$kernel.timer" +RUN+="@SYSDIR_BIN@/systemctl stop cancel-multipath-wait-$kernel.timer" # If "multipath -u" failed, no values are imported from the program, # and we are still using the values for DM_MULTIPATH_DEVICE_PATH and -- 2.45.2