[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 08/13] tools/hotplug: use XEN_SCRIPT_DIR instead of hardcoded path



Helper scripts get installed into XEN_SCRIPT_DIR, but initscripts,
helper scripts and udev rules still refer to the hardcoded location
/etc/xen/scripts/. Update scripts, rules and Makefile to refer to
@@XEN_SCRIPT_DIR@@ instead.

Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>
---
 .gitignore                                         |  8 +++++
 tools/hotplug/Linux/Makefile                       | 40 +++++++++++++++++++---
 .../Linux/init.d/{xen-watchdog => xen-watchdog.in} |  2 +-
 .../Linux/init.d/{xencommons => xencommons.in}     |  2 +-
 .../Linux/init.d/{xendomains => xendomains.in}     |  2 +-
 tools/hotplug/Linux/{vif-setup => vif-setup.in}    |  2 +-
 .../{xen-backend.rules => xen-backend.rules.in}    | 16 ++++-----
 ...-hotplug-common.sh => xen-hotplug-common.sh.in} |  2 +-
 tools/hotplug/Linux/{xendomains => xendomains.in}  |  2 +-
 9 files changed, 57 insertions(+), 19 deletions(-)
 rename tools/hotplug/Linux/init.d/{xen-watchdog => xen-watchdog.in} (97%)
 rename tools/hotplug/Linux/init.d/{xencommons => xencommons.in} (99%)
 rename tools/hotplug/Linux/init.d/{xendomains => xendomains.in} (97%)
 rename tools/hotplug/Linux/{vif-setup => vif-setup.in} (60%)
 rename tools/hotplug/Linux/{xen-backend.rules => xen-backend.rules.in} (60%)
 rename tools/hotplug/Linux/{xen-hotplug-common.sh => xen-hotplug-common.sh.in} 
(98%)
 rename tools/hotplug/Linux/{xendomains => xendomains.in} (99%)

diff --git a/.gitignore b/.gitignore
index 685df89..cf2febe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -159,6 +159,14 @@ tools/flask/utils/flask-set-bool
 tools/flask/utils/flask-label-pci
 tools/fs-back/fs-backend
 tools/hotplug/common/hotplugpath.sh
+tools/hotplug/Linux/init.d/xen-watchdog
+tools/hotplug/Linux/init.d/xencommons
+tools/hotplug/Linux/init.d/xendomains
+tools/hotplug/Linux/vif-setup
+tools/hotplug/Linux/xen-backend.rules
+tools/hotplug/Linux/xen-hotplug-common.sh
+tools/hotplug/Linux/xendomains
+tools/hotplug/Linux/_used_path.sh
 tools/include/xen/*
 tools/include/xen-foreign/*.(c|h|size)
 tools/include/xen-foreign/checker
diff --git a/tools/hotplug/Linux/Makefile b/tools/hotplug/Linux/Makefile
index d5de9e6..fb9f1e6 100644
--- a/tools/hotplug/Linux/Makefile
+++ b/tools/hotplug/Linux/Makefile
@@ -32,18 +32,47 @@ XEN_SCRIPT_DATA += block-common.sh
 UDEV_RULES_DIR = $(CONFIG_DIR)/udev
 UDEV_RULES = xen-backend.rules $(UDEV_RULES-y)
 
+USED_PATH = "_used_path.sh"
+genpath-target = $(call buildmakevars2file,$(USED_PATH))
+$(eval $(genpath-target))
+
+XEN_SCRIPT_DIR_INPUTS := \
+        init.d/xen-watchdog.in \
+        init.d/xencommons.in \
+        init.d/xendomains.in \
+        vif-setup.in \
+        xen-backend.rules.in \
+        xen-hotplug-common.sh.in \
+        xendomains.in
+
+.SUFFIXES:
+XEN_SCRIPT_DIR_OUTPUTS := $(patsubst %.in,%,$(XEN_SCRIPT_DIR_INPUTS))
+%: %.in
+       set -e; \
+               rm -f $@.new ; \
+               sed 's|@@XEN_SCRIPT_DIR@@|$(XEN_SCRIPT_DIR)|g' $< >$@.new ; \
+               $(call move-if-changed,$@.new,$@)
+
+init.d/%: init.d/%.in
+       set -e; \
+               rm -f $@.new ; \
+               sed 's|@@XEN_SCRIPT_DIR@@|$(XEN_SCRIPT_DIR)|g' $< >$@.new ; \
+               $(call move-if-changed,$@.new,$@)
+
+$(XEN_SCRIPT_DIR_OUTPUTS): $(USED_PATH)
+
 .PHONY: all
-all:
+all: build
 
 .PHONY: build
-build:
+build: $(XEN_SCRIPT_DIR_OUTPUTS)
 
 .PHONY: install
 install: all install-initd install-scripts install-udev
 
 # See docs/misc/distro_mapping.txt for INITD_DIR location
 .PHONY: install-initd
-install-initd:
+install-initd: all
        [ -d $(DESTDIR)$(INITD_DIR) ] || $(INSTALL_DIR) $(DESTDIR)$(INITD_DIR)
        [ -d $(DESTDIR)$(SYSCONFIG_DIR) ] || $(INSTALL_DIR) 
$(DESTDIR)$(SYSCONFIG_DIR)
        [ -d $(DESTDIR)$(LIBEXEC) ] || $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC)
@@ -55,7 +84,7 @@ install-initd:
        $(INSTALL_PROG) init.d/xen-watchdog $(DESTDIR)$(INITD_DIR)
 
 .PHONY: install-scripts
-install-scripts:
+install-scripts: all
        [ -d $(DESTDIR)$(XEN_SCRIPT_DIR) ] || \
                $(INSTALL_DIR) $(DESTDIR)$(XEN_SCRIPT_DIR)
        set -e; for i in $(XEN_SCRIPTS); \
@@ -68,7 +97,7 @@ install-scripts:
        done
 
 .PHONY: install-udev
-install-udev:
+install-udev: all
        [ -d $(DESTDIR)$(UDEV_RULES_DIR) ] || \
                $(INSTALL_DIR) $(DESTDIR)$(UDEV_RULES_DIR)/rules.d
        set -e; for i in $(UDEV_RULES); \
@@ -78,3 +107,4 @@ install-udev:
 
 .PHONY: clean
 clean:
+       rm -f $(XEN_SCRIPT_DIR_OUTPUTS)
diff --git a/tools/hotplug/Linux/init.d/xen-watchdog 
b/tools/hotplug/Linux/init.d/xen-watchdog.in
similarity index 97%
rename from tools/hotplug/Linux/init.d/xen-watchdog
rename to tools/hotplug/Linux/init.d/xen-watchdog.in
index 3592fda..d0d7966 100644
--- a/tools/hotplug/Linux/init.d/xen-watchdog
+++ b/tools/hotplug/Linux/init.d/xen-watchdog.in
@@ -17,7 +17,7 @@
 ### END INIT INFO
 #
 
-. /etc/xen/scripts/hotplugpath.sh
+. @@XEN_SCRIPT_DIR@@/hotplugpath.sh
 
 DAEMON=${SBINDIR}/xenwatchdogd
 base=$(basename $DAEMON)
diff --git a/tools/hotplug/Linux/init.d/xencommons 
b/tools/hotplug/Linux/init.d/xencommons.in
similarity index 99%
rename from tools/hotplug/Linux/init.d/xencommons
rename to tools/hotplug/Linux/init.d/xencommons.in
index 4ebd636..c62bdb8 100644
--- a/tools/hotplug/Linux/init.d/xencommons
+++ b/tools/hotplug/Linux/init.d/xencommons.in
@@ -18,7 +18,7 @@
 # Description:       Starts and stops the daemons neeeded for xl/xend
 ### END INIT INFO
 
-. /etc/xen/scripts/hotplugpath.sh
+. @@XEN_SCRIPT_DIR@@/hotplugpath.sh
 
 if [ -d /etc/sysconfig ]; then
        xencommons_config=/etc/sysconfig
diff --git a/tools/hotplug/Linux/init.d/xendomains 
b/tools/hotplug/Linux/init.d/xendomains.in
similarity index 97%
rename from tools/hotplug/Linux/init.d/xendomains
rename to tools/hotplug/Linux/init.d/xendomains.in
index d0122fc..8eb7e6e 100644
--- a/tools/hotplug/Linux/init.d/xendomains
+++ b/tools/hotplug/Linux/init.d/xendomains.in
@@ -24,7 +24,7 @@
 #                    systemd systems.
 ### END INIT INFO
 
-. /etc/xen/scripts/hotplugpath.sh
+. @@XEN_SCRIPT_DIR@@/hotplugpath.sh
 
 case "$1" in
     start)
diff --git a/tools/hotplug/Linux/vif-setup b/tools/hotplug/Linux/vif-setup.in
similarity index 60%
rename from tools/hotplug/Linux/vif-setup
rename to tools/hotplug/Linux/vif-setup.in
index bcc462e..ce1ba56 100644
--- a/tools/hotplug/Linux/vif-setup
+++ b/tools/hotplug/Linux/vif-setup.in
@@ -4,6 +4,6 @@ if test "$script"
 then
     exec $script $*
 else
-    exec /etc/xen/scripts/vif-bridge $*
+    exec @@XEN_SCRIPT_DIR@@/vif-bridge $*
 fi
 
diff --git a/tools/hotplug/Linux/xen-backend.rules 
b/tools/hotplug/Linux/xen-backend.rules.in
similarity index 60%
rename from tools/hotplug/Linux/xen-backend.rules
rename to tools/hotplug/Linux/xen-backend.rules.in
index a0d409e..8e01533 100644
--- a/tools/hotplug/Linux/xen-backend.rules
+++ b/tools/hotplug/Linux/xen-backend.rules.in
@@ -1,10 +1,10 @@
-SUBSYSTEM=="xen-backend", KERNEL=="tap*", ENV{UDEV_CALL}="1", 
RUN+="/etc/xen/scripts/blktap $env{ACTION}"
-SUBSYSTEM=="xen-backend", KERNEL=="vbd*", ENV{UDEV_CALL}="1", 
RUN+="/etc/xen/scripts/block $env{ACTION}"
-SUBSYSTEM=="xen-backend", KERNEL=="vif2-*", RUN+="/etc/xen/scripts/vif2 
$env{ACTION}"
-SUBSYSTEM=="xen-backend", KERNEL=="vif-*", ENV{UDEV_CALL}="1", 
ACTION=="online", RUN+="/etc/xen/scripts/vif-setup online type_if=vif"
-SUBSYSTEM=="xen-backend", KERNEL=="vif-*", ENV{UDEV_CALL}="1", 
ACTION=="offline", RUN+="/etc/xen/scripts/vif-setup offline type_if=vif"
-SUBSYSTEM=="xen-backend", KERNEL=="vscsi*", RUN+="/etc/xen/scripts/vscsi 
$env{ACTION}"
-SUBSYSTEM=="xen-backend", ACTION=="remove", ENV{UDEV_CALL}="1", 
RUN+="/etc/xen/scripts/xen-hotplug-cleanup"
+SUBSYSTEM=="xen-backend", KERNEL=="tap*", ENV{UDEV_CALL}="1", 
RUN+="@@XEN_SCRIPT_DIR@@/blktap $env{ACTION}"
+SUBSYSTEM=="xen-backend", KERNEL=="vbd*", ENV{UDEV_CALL}="1", 
RUN+="@@XEN_SCRIPT_DIR@@/block $env{ACTION}"
+SUBSYSTEM=="xen-backend", KERNEL=="vif2-*", RUN+="@@XEN_SCRIPT_DIR@@/vif2 
$env{ACTION}"
+SUBSYSTEM=="xen-backend", KERNEL=="vif-*", ENV{UDEV_CALL}="1", 
ACTION=="online", RUN+="@@XEN_SCRIPT_DIR@@/vif-setup online type_if=vif"
+SUBSYSTEM=="xen-backend", KERNEL=="vif-*", ENV{UDEV_CALL}="1", 
ACTION=="offline", RUN+="@@XEN_SCRIPT_DIR@@/vif-setup offline type_if=vif"
+SUBSYSTEM=="xen-backend", KERNEL=="vscsi*", RUN+="@@XEN_SCRIPT_DIR@@/vscsi 
$env{ACTION}"
+SUBSYSTEM=="xen-backend", ACTION=="remove", ENV{UDEV_CALL}="1", 
RUN+="@@XEN_SCRIPT_DIR@@/xen-hotplug-cleanup"
 KERNEL=="evtchn", NAME="xen/%k"
 SUBSYSTEM=="xen", KERNEL=="blktap[0-9]*", NAME="xen/%k", MODE="0600"
 SUBSYSTEM=="blktap2", KERNEL=="blktap[0-9]*", NAME="xen/blktap-2/%k", 
MODE="0600"
@@ -12,4 +12,4 @@ KERNEL=="blktap-control", NAME="xen/blktap-2/control", 
MODE="0600"
 KERNEL=="gntdev", NAME="xen/%k", MODE="0600"
 KERNEL=="pci_iomul", NAME="xen/%k", MODE="0600"
 KERNEL=="tapdev[a-z]*", NAME="xen/blktap-2/tapdev%m", MODE="0600"
-SUBSYSTEM=="net", KERNEL=="vif*-emu", ACTION=="add", ENV{UDEV_CALL}="1", 
RUN+="/etc/xen/scripts/vif-setup $env{ACTION} type_if=tap"
+SUBSYSTEM=="net", KERNEL=="vif*-emu", ACTION=="add", ENV{UDEV_CALL}="1", 
RUN+="@@XEN_SCRIPT_DIR@@/vif-setup $env{ACTION} type_if=tap"
diff --git a/tools/hotplug/Linux/xen-hotplug-common.sh 
b/tools/hotplug/Linux/xen-hotplug-common.sh.in
similarity index 98%
rename from tools/hotplug/Linux/xen-hotplug-common.sh
rename to tools/hotplug/Linux/xen-hotplug-common.sh.in
index 7af4688..8128b9e 100644
--- a/tools/hotplug/Linux/xen-hotplug-common.sh
+++ b/tools/hotplug/Linux/xen-hotplug-common.sh.in
@@ -112,7 +112,7 @@ xenstore_write() {
 # Execute each hook in the <hook> directory.
 #
 call_hooks() {
-  for f in /etc/xen/scripts/${1}-${2}.d/*.hook; do
+  for f in @@XEN_SCRIPT_DIR@@/${1}-${2}.d/*.hook; do
     if [ -x "$f" ]; then . "$f"; fi
   done
 }
diff --git a/tools/hotplug/Linux/xendomains b/tools/hotplug/Linux/xendomains.in
similarity index 99%
rename from tools/hotplug/Linux/xendomains
rename to tools/hotplug/Linux/xendomains.in
index 0794bb9..0882ef6 100644
--- a/tools/hotplug/Linux/xendomains
+++ b/tools/hotplug/Linux/xendomains.in
@@ -27,7 +27,7 @@
 #                    boots / shuts down.
 ### END INIT INFO
 
-. /etc/xen/scripts/hotplugpath.sh
+. @@XEN_SCRIPT_DIR@@/hotplugpath.sh
 
 CMD=${SBINDIR}/xl
 HEADCOMP="Xen saved domain"

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.