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

[Xen-changelog] [xen-unstable] tools, build system: Make changing distro-specific layout aspects easier



# HG changeset patch
# User <bruce.edge@xxxxxxxxx>
# Date 1285001665 -3600
# Node ID b59f87f56b1ecf2c560efc41434cf79e94b1e59b
# Parent  81c40c5db26ee3352f3bfff20aaa9bdc08a0472d
tools, build system: Make changing distro-specific layout aspects easier

Introduce CONFIG_LEAF_DIR, SUBSYS_DIR, INITD_DIR variables to cope
better with variation between distributions.

See docs/misc/distro_mapping.txt for details.

Signed-off-by: Bruce Edge <bruce.edge@xxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 Config.mk                               |    6 ++++++
 Makefile                                |    2 +-
 config/StdGNU.mk                        |    2 +-
 docs/misc/distro_mapping.txt            |   27 +++++++++++++++++++++++++++
 tools/hotplug/Linux/Makefile            |   11 ++++++-----
 tools/hotplug/Linux/init.d/xen-watchdog |   19 ++++++++++++++++++-
 tools/hotplug/Linux/init.d/xend         |   12 +++++++++---
 tools/hotplug/Linux/init.d/xendomains   |   14 ++++++++++++--
 tools/xenballoon/xenballoond            |    9 +++++++--
 tools/xenballoon/xenballoond.README     |   15 +++++++++------
 tools/xenballoon/xenballoond.init       |    2 ++
 11 files changed, 98 insertions(+), 21 deletions(-)

diff -r 81c40c5db26e -r b59f87f56b1e Config.mk
--- a/Config.mk Mon Sep 20 16:57:08 2010 +0100
+++ b/Config.mk Mon Sep 20 17:54:25 2010 +0100
@@ -30,6 +30,12 @@ DOCDIR      ?= $(SHAREDIR)/doc/xen
 DOCDIR      ?= $(SHAREDIR)/doc/xen
 MANDIR      ?= $(SHAREDIR)/man
 BASH_COMPLETION_DIR ?= $(CONFIG_DIR)/bash_completion.d
+
+# These are the Red Hat settings.
+# See distro_mapping.txt for other options
+CONFIG_LEAF_DIR ?= sysconfig
+SUBSYS_DIR ?= /var/run/subsys
+INITD_DIR ?= /etc/rc.d/init.d
 
 ifneq ($(EXTRA_PREFIX),)
 EXTRA_INCLUDES += $(EXTRA_PREFIX)/include
diff -r 81c40c5db26e -r b59f87f56b1e Makefile
--- a/Makefile  Mon Sep 20 16:57:08 2010 +0100
+++ b/Makefile  Mon Sep 20 17:54:25 2010 +0100
@@ -203,7 +203,7 @@ uninstall:
        rm -f  $(D)$(CONFIG_DIR)/udev/xen-backend.rules
        rm -f  $(D)$(CONFIG_DIR)/udev/rules.d/xend.rules
        rm -f  $(D)$(CONFIG_DIR)/udev/xend.rules
-       rm -f  $(D)$(CONFIG_DIR)/sysconfig/xendomains
+       rm -f  $(D)$(SYSCONFIG_DIR)/xendomains
        rm -rf $(D)/var/run/xen* $(D)/var/lib/xen*
        rm -rf $(D)/boot/*xen*
        rm -rf $(D)/lib/modules/*xen*
diff -r 81c40c5db26e -r b59f87f56b1e config/StdGNU.mk
--- a/config/StdGNU.mk  Mon Sep 20 16:57:08 2010 +0100
+++ b/config/StdGNU.mk  Mon Sep 20 17:54:25 2010 +0100
@@ -49,7 +49,7 @@ CONFIG_DIR = $(PREFIX)/etc
 CONFIG_DIR = $(PREFIX)/etc
 endif
 
-SYSCONFIG_DIR = $(CONFIG_DIR)/sysconfig
+SYSCONFIG_DIR = $(CONFIG_DIR)/$(CONFIG_LEAF_DIR)
 
 XEN_CONFIG_DIR = $(CONFIG_DIR)/xen
 XEN_SCRIPT_DIR = $(XEN_CONFIG_DIR)/scripts
diff -r 81c40c5db26e -r b59f87f56b1e docs/misc/distro_mapping.txt
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/misc/distro_mapping.txt      Mon Sep 20 17:54:25 2010 +0100
@@ -0,0 +1,27 @@
+With directory layout differences between Red Hat, Debian, Suse and
+other distros one needs to set the variables for the elements below
+
+-----------------+------------------+---------------+----------------+
+                 | RedHat (default) |  Debian       |  Suse          |
+-----------------+------------------+---------------+----------------+
+CONFIG_LEAF_DIR  | sysconfig        | default       | sysconfig      |
+SUBSYS_DIR       | /var/run/subsys  | /var/run      | /var/run       |
+INITD_DIR        | /etc/rc.d/init.d | /etc/init.d   | /etc/init.d    |
+-----------------+------------------+---------------+----------------+
+
+The build currently defaults to the elements used by Red Hat.
+For others, these env variables must be set in the shell env
+or modified in Config.mk before running make.
+
+This mechanism sets the location that files are installed to, but does
+not change the code itself. Scripts that refer to files affected by these
+directories must check each possible location at run time.
+
+To add support for new distributions that don't use the above locations,
+one must grep for the above elements and add appropriate checks.
+
+For example if a new distro uses /etc/bork as it's config dir, It's not
+sufficient to set CONFIG_LEAF_DIR=bork, one must also add tests for the
+existance of the bork dir in every context where config files are read.
+
+
diff -r 81c40c5db26e -r b59f87f56b1e tools/hotplug/Linux/Makefile
--- a/tools/hotplug/Linux/Makefile      Mon Sep 20 16:57:08 2010 +0100
+++ b/tools/hotplug/Linux/Makefile      Mon Sep 20 17:54:25 2010 +0100
@@ -62,16 +62,17 @@ build:
 .PHONY: install
 install: all install-initd install-scripts $(HOTPLUGS)
 
+# See docs/misc/distro_mapping.txt for INITD_DIR location
 .PHONY: install-initd
 install-initd:
-       [ -d $(DESTDIR)$(CONFIG_DIR)/init.d ] || $(INSTALL_DIR) 
$(DESTDIR)$(CONFIG_DIR)/init.d
+       [ -d $(DESTDIR)$(INITD_DIR) ] || $(INSTALL_DIR) $(DESTDIR)$(INITD_DIR)
        [ -d $(DESTDIR)$(SYSCONFIG_DIR) ] || $(INSTALL_DIR) 
$(DESTDIR)$(SYSCONFIG_DIR)
-       $(INSTALL_PROG) $(XEND_INITD) $(DESTDIR)$(CONFIG_DIR)/init.d
-       $(INSTALL_PROG) $(XENDOMAINS_INITD) $(DESTDIR)$(CONFIG_DIR)/init.d
+       $(INSTALL_PROG) $(XEND_INITD) $(DESTDIR)$(INITD_DIR)
+       $(INSTALL_PROG) $(XENDOMAINS_INITD) $(DESTDIR)$(INITD_DIR)
        $(INSTALL_PROG) $(XENDOMAINS_SYSCONFIG) 
$(DESTDIR)$(SYSCONFIG_DIR)/xendomains
-       $(INSTALL_PROG) $(XENCOMMONS_INITD) $(DESTDIR)$(CONFIG_DIR)/init.d
+       $(INSTALL_PROG) $(XENCOMMONS_INITD) $(DESTDIR)$(INITD_DIR)
        $(INSTALL_PROG) $(XENCOMMONS_SYSCONFIG) 
$(DESTDIR)$(SYSCONFIG_DIR)/xencommons
-       $(INSTALL_PROG) init.d/xen-watchdog $(DESTDIR)$(CONFIG_DIR)/init.d
+       $(INSTALL_PROG) init.d/xen-watchdog $(DESTDIR)$(INITD_DIR)
 
 .PHONY: install-scripts
 install-scripts:
diff -r 81c40c5db26e -r b59f87f56b1e tools/hotplug/Linux/init.d/xen-watchdog
--- a/tools/hotplug/Linux/init.d/xen-watchdog   Mon Sep 20 16:57:08 2010 +0100
+++ b/tools/hotplug/Linux/init.d/xen-watchdog   Mon Sep 20 17:54:25 2010 +0100
@@ -18,7 +18,24 @@
 #
 
 # Source function library.
-. /etc/init.d/functions
+if [ -e  /etc/init.d/functions ] ; then
+    . /etc/init.d/functions
+elif [ -e /lib/lsb/init-functions ] ; then
+    . /lib/lsb/init-functions
+    success () {
+        log_success_msg $*
+    }
+    failure () {
+        log_failure_msg $*
+    }
+else
+    success () {
+        echo $*
+    }
+    failure () {
+        echo $*
+    }
+fi
 
 start() {
        local r
diff -r 81c40c5db26e -r b59f87f56b1e tools/hotplug/Linux/init.d/xend
--- a/tools/hotplug/Linux/init.d/xend   Mon Sep 20 16:57:08 2010 +0100
+++ b/tools/hotplug/Linux/init.d/xend   Mon Sep 20 17:54:25 2010 +0100
@@ -40,14 +40,20 @@ case "$1" in
                echo "xencommons should be started first."
                exit 1
        fi
-       mkdir -p /var/lock/subsys
-       touch /var/lock/subsys/xend
+       # mkdir shouldn't be needed as most distros have this already created. 
Default to using subsys.
+       # See docs/misc/distro_mapping.txt
+       mkdir -p /var/lock
+       if [ -d /var/lock/subsys ] ; then
+               touch /var/lock/subsys/xend
+       else
+               touch /var/lock/xend
+       fi
        xend start
        await_daemons_up
        ;;
   stop)
        xend stop
-       rm -f /var/lock/subsys/xend
+       rm -f /var/lock/subsys/xend /var/lock/xend
        ;;
   status)
        xend status
diff -r 81c40c5db26e -r b59f87f56b1e tools/hotplug/Linux/init.d/xendomains
--- a/tools/hotplug/Linux/init.d/xendomains     Mon Sep 20 16:57:08 2010 +0100
+++ b/tools/hotplug/Linux/init.d/xendomains     Mon Sep 20 17:54:25 2010 +0100
@@ -46,8 +46,18 @@ if ! [ -e /proc/xen/privcmd ]; then
        exit 0
 fi
 
-LOCKFILE=/var/lock/subsys/xendomains
-XENDOM_CONFIG=/etc/sysconfig/xendomains
+# See docs/misc/distro_mapping.txt
+if [ -d /var/lock/subsys ]; then
+       LOCKFILE=/var/lock/subsys/xendomains
+else
+       LOCKFILE=/var/lock/xendomains
+fi
+
+if [ -d /etc/sysconfig ]; then
+       XENDOM_CONFIG=/etc/sysconfig/xendomains
+else
+       XENDOM_CONFIG=/etc/default/xendomains
+fi
 
 test -r $XENDOM_CONFIG || { echo "$XENDOM_CONFIG not existing";
        if [ "$1" = "stop" ]; then exit 0;
diff -r 81c40c5db26e -r b59f87f56b1e tools/xenballoon/xenballoond
--- a/tools/xenballoon/xenballoond      Mon Sep 20 16:57:08 2010 +0100
+++ b/tools/xenballoon/xenballoond      Mon Sep 20 17:54:25 2010 +0100
@@ -21,7 +21,7 @@
 # If xenbus is running and the /usr/bin/xenstore-* tools are installed,
 # "xenbus is enabled".
 #
-# Parameters are documented in /etc/sysconfig/xenballoon.conf. Although 
+# Parameters are documented in <SYSCONFIG>/xenballoon.conf. Although
 # some are not used with directed ballooning, all must be set properly.
 # If xenbus is enabled, some of these parameters may be overridden by values
 # set by domain0 via xenbus.
@@ -237,7 +237,12 @@ fi
 fi
 preswapnow=0
 
-. /etc/sysconfig/xenballoon.conf
+# See docs/misc/distro_mapping.txt
+if [ -f /etc/sysconfig/xenballoon.conf ]; then
+       . /etc/sysconfig/xenballoon.conf
+elif [ -f /etc/default/xenballoon.conf ]; then
+       . /etc/default/xenballoon.conf
+fi
 
 while true;
 do
diff -r 81c40c5db26e -r b59f87f56b1e tools/xenballoon/xenballoond.README
--- a/tools/xenballoon/xenballoond.README       Mon Sep 20 16:57:08 2010 +0100
+++ b/tools/xenballoon/xenballoond.README       Mon Sep 20 17:54:25 2010 +0100
@@ -56,16 +56,20 @@ Guest prerequisites to use xenballoond:
     be installed.  Binaries can be obtained, for example, by building
     xen-vvv.gz/tools in a guest-binary-compatible development tree
 
-Instructions to install/deploy xenballoond (in Redhat-based system):
+Instructions to install/deploy xenballoond:
+  (see docs/misc/distro_mapping.txt for SYSCONFIG and INITD_DIR definitions)
 - in each guest:
   - ensure pre-requisites are met (see above)
-  - place xenballoon.conf in /etc/sysconfig
+  - place xenballoon.conf in <SYSCONFIG>
   - place xenballoond in /usr/sbin
-  - copy xenballoond.init to /etc/rc.d/init.d/xenballoond (note file rename)
-  - edit /etc/sysconfig/xenballoond.conf as desired (especially note that
+  - copy xenballoond.init to <INITD_DIR>/xenballoond (note file rename)
+  - edit <SYSCONFIG>/xenballoond.conf as desired (especially note that
     selfballooning defaults as off)
   - start xenballoond with "service xenballoond start", and/or configure
-    xenballoond to start at init (e.g. "chkconfig xenballoond on")
+    xenballoond to start at init
+        (Red Hat e.g. "chkconfig xenballoond on")
+        (Debian e.g. " update-rc.d xenballoond defaults")
+        (Suse e.g. " insserv xenballoond")
 - in domain0:
   - if monitoring is desired, xenballoon-monitor may be installed in /usr/sbin
 - note that certain xenballoond.conf variables may be overridden by domain0
@@ -73,7 +77,6 @@ Instructions to install/deploy xenballoo
   xenballoond.conf
 
 TODO:
-080630 modifications to support SUSE-based and debian-based guests
 080630 domain0 ballooning policy module
 080630 experiment with more aggressive (optionally) memory minimum targets
 080630 BUG: xenballoond doesn't properly record the fact that it's running;
diff -r 81c40c5db26e -r b59f87f56b1e tools/xenballoon/xenballoond.init
--- a/tools/xenballoon/xenballoond.init Mon Sep 20 16:57:08 2010 +0100
+++ b/tools/xenballoon/xenballoond.init Mon Sep 20 17:54:25 2010 +0100
@@ -29,6 +29,8 @@
 
 if [ -f /etc/sysconfig/xenballoon.conf ]; then
        . /etc/sysconfig/xenballoon.conf
+elif [ -f /etc/default/xenballoon.conf ]; then
+       . /etc/default/xenballoon.conf
 fi
 
 # Check that balloon driver is present

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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