On 01/20/2012 04:56 AM, Ian Campbell wrote:
>> Am I wrong here
>> again? :)
>>
>> Can you comment on my grep -v solution?
>
> Why not have a look at one of the undoubtedly many packages which
> already does this?
Attached to this mail is a version that keeps eventual comments an admin
has put in the /etc/default/xen file. See choose_xl_with_debconf_2.patch.
Together with the xen-utils-common.xend.init.patch, this solves #655301.
Bastian, can you apply these patches?
Cheers,
Thomas
diff -u -N -r bastian/debian/control zigo/debian/control
--- bastian/debian/control 2011-10-26 07:56:43.000000000 +0000
+++ zigo/debian/control 2012-01-28 21:56:58.000000000 +0000
@@ -4,11 +4,11 @@
Maintainer: Debian Xen Team <[email protected]>
Uploaders: Guido Trotter <[email protected]>, Bastian Blank <[email protected]>
Standards-Version: 3.8.4
-Build-Depends: debhelper (>> 7)
+Build-Depends: debhelper (>> 7), po-debconf
Package: xen-utils-common
Architecture: all
-Depends: gawk, lsb-base, udev, xenstore-utils, ${misc:Depends}
+Depends: gawk, lsb-base, udev, xenstore-utils, debconf, ${misc:Depends}
Description: XEN administrative tools - common files
The userspace tools to manage a system virtualized through the XEN virtual
machine monitor.
diff -u -N -r bastian/debian/po/fr.po zigo/debian/po/fr.po
--- bastian/debian/po/fr.po 1970-01-01 00:00:00.000000000 +0000
+++ zigo/debian/po/fr.po 2012-01-28 21:56:58.000000000 +0000
@@ -0,0 +1,59 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+"Project-Id-Version: xen-common VERSION\n"
+"Report-Msgid-Bugs-To: [email protected]\n"
+"POT-Creation-Date: 2011-12-22 15:45+0000\n"
+"PO-Revision-Date: 2011-12-22 15:45+0000\n"
+"Last-Translator: Thomas Goirand <[email protected]>\n"
+"Language-Team: French <[email protected]>\n"
+"Language: fr\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. Type: select
+#. Choices
+#: ../xen-utils-common.templates:1001
+msgid "xm, xl"
+msgstr ""
+
+#. Type: select
+#. Description
+#: ../xen-utils-common.templates:1002
+msgid "Xen toolstack to use:"
+msgstr ""
+
+#. Type: select
+#. Description
+#: ../xen-utils-common.templates:1002
+msgid ""
+"There exists several tool stacks to configure a Xen system: xm is the old "
+"traditional python based userland tools, running with xend, while xl is new, "
+"and Xen Light based. You can only use one of them at a time, and switching "
+"from one to another requires rebooting. If you decide to use xl, then the "
+"settings in your xend-config.sxp will be ignored, and you will have to setup "
+"networking on your own (no pre-built bridging scripts are provided for "
+"example)."
+msgstr ""
+
+#. Type: select
+#. Description
+#: ../xen-utils-common.templates:1002
+msgid ""
+"The xm and xl toolstack are compatible (just the userland executable is "
+"called differently), and your old xm/xend virtual machine startup files will "
+"continue to work (xl knows its syntax) but they shouldn't contain python "
+"code."
+msgstr ""
+
+#. Type: select
+#. Description
+#: ../xen-utils-common.templates:1002
+msgid ""
+"Note that if you wish to use Xen with XCP (Xen Cloud Platform), then using "
+"xl is mandatory."
+msgstr "Nottez que si vous voulez utiliser XCP (Xen Cloud Platform), alors "
+"l'utilisation de xl est obligatoire."
diff -u -N -r bastian/debian/po/POTFILES.in zigo/debian/po/POTFILES.in
--- bastian/debian/po/POTFILES.in 1970-01-01 00:00:00.000000000 +0000
+++ zigo/debian/po/POTFILES.in 2012-01-28 21:56:58.000000000 +0000
@@ -0,0 +1 @@
+[type: gettext/rfc822deb] xen-utils-common.templates
diff -u -N -r bastian/debian/po/templates.pot zigo/debian/po/templates.pot
--- bastian/debian/po/templates.pot 1970-01-01 00:00:00.000000000 +0000
+++ zigo/debian/po/templates.pot 2012-01-28 21:56:58.000000000 +0000
@@ -0,0 +1,61 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: [email protected]\n"
+"POT-Creation-Date: 2011-12-22 15:45+0000\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <[email protected]>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. Type: select
+#. Choices
+#: ../xen-utils-common.templates:1001
+msgid "xm, xl"
+msgstr ""
+
+#. Type: select
+#. Description
+#: ../xen-utils-common.templates:1002
+msgid "Xen toolstack to use:"
+msgstr ""
+
+#. Type: select
+#. Description
+#: ../xen-utils-common.templates:1002
+msgid ""
+"There exists several tool stacks to configure a Xen system: xm is the old "
+"traditional python based userland tools, running with xend, while xl is new, "
+"and Xen Light based. You can only use one of them at a time, and switching "
+"from one to another requires rebooting. If you decide to use xl, then the "
+"settings in your xend-config.sxp will be ignored, and you will have to setup "
+"networking on your own (no pre-built bridging scripts are provided for "
+"example)."
+msgstr ""
+
+#. Type: select
+#. Description
+#: ../xen-utils-common.templates:1002
+msgid ""
+"The xm and xl toolstack are compatible (just the userland executable is "
+"called differently), and your old xm/xend virtual machine startup files will "
+"continue to work (xl knows its syntax) but they shouldn't contain python "
+"code."
+msgstr ""
+
+#. Type: select
+#. Description
+#: ../xen-utils-common.templates:1002
+msgid ""
+"Note that if you wish to use Xen with XCP (Xen Cloud Platform), then using "
+"xl is mandatory."
+msgstr ""
diff -u -N -r bastian/debian/rules zigo/debian/rules
--- bastian/debian/rules 2011-10-26 23:03:27.000000000 +0000
+++ zigo/debian/rules 2012-01-28 21:56:58.000000000 +0000
@@ -30,6 +30,7 @@
dh_testdir
rm -rf $(BUILD_DIR) $(STAMPS_DIR) debian/lib/python/*/*.pyc
dh_clean
+ #debconf-updatepo
NO_ORIG = .svn .svk debian
@@ -66,6 +67,7 @@
dh_testroot
dh_install --sourcedir=debian/tmp
dh_installchangelogs
+ dh_installdebconf
dh_installdocs
dh_installexamples
dh_installinit -p xen-utils-common --name xen
diff -u -N -r bastian/debian/xen-utils-common.config zigo/debian/xen-utils-common.config
--- bastian/debian/xen-utils-common.config 1970-01-01 00:00:00.000000000 +0000
+++ zigo/debian/xen-utils-common.config 2012-01-28 21:56:58.000000000 +0000
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+set -e
+
+action=$1
+version=$2
+. /usr/share/debconf/confmodule
+db_version 2.0
+
+if [ -f /etc/default/xen ] ; then
+ . /etc/default/xen
+fi
+
+if [ "x${TOOLSTACK}" = "xxl" ] ; then
+ db_set xen/toolstack xl
+fi
+
+db_input high xen/toolstack || true
+db_go
+
+#DEBHELPER#
+
+exit 0
diff -u -N -r bastian/debian/xen-utils-common.postinst zigo/debian/xen-utils-common.postinst
--- bastian/debian/xen-utils-common.postinst 2009-11-16 18:49:53.000000000 +0000
+++ zigo/debian/xen-utils-common.postinst 2012-01-28 22:06:40.000000000 +0000
@@ -2,10 +2,39 @@
set -e
+. /usr/share/debconf/confmodule
+db_version 2.0
+
+CONFFILE="/etc/default/xen"
+
case "$1" in
configure)
install -d -m 0700 /var/lib/xenstored
install -d -m 2750 -g adm /var/log/xen
+
+ db_get xen/toolstack
+ debconf_xen_toolstack=${RET}
+ if [ ! -e /etc/default/xen ] ; then
+ echo "# Configuration for Xen system
+# ----------------------------
+
+# There exists several tool stacks to configure a Xen system.
+#
+# Attention: You need to reboot after changing this!
+TOOLSTACK=${debconf_xen_toolstack}
+" >${CONFFILE}
+ fi
+ cp -a -f ${CONFFILE} ${CONFFILE}.tmp
+ # If the admin deleted or commented some variables but then set
+ # them via debconf, (re-)add them to the config file.
+ test -z "${debconf_xen_toolstack}" || \
+ grep -Eq '^ *TOOLSTACK=' ${CONFFILE} || \
+ echo "TOOLSTACK=" >>${CONFFILE}
+
+ sed -e "s|^ *TOOLSTACK=.*|TOOLSTACK=\"${debconf_xen_toolstack}\"|" \
+ < "${CONFFILE}" > "${CONFFILE}.tmp"
+
+ mv -f "${CONFFILE}.tmp" "${CONFFILE}"
;;
abort-upgrade|abort-remove|abort-deconfigure)
diff -u -N -r bastian/debian/xen-utils-common.templates zigo/debian/xen-utils-common.templates
--- bastian/debian/xen-utils-common.templates 1970-01-01 00:00:00.000000000 +0000
+++ zigo/debian/xen-utils-common.templates 2012-01-28 21:56:58.000000000 +0000
@@ -0,0 +1,19 @@
+Template: xen/toolstack
+Type: select
+_Choices: xm, xl
+_Description: Xen toolstack to use:
+ There exists several tool stacks to configure a Xen system: xm is the old
+ traditional python based userland tools, running with xend, while xl is
+ new, and Xen Light based. You can only use one of them at a time, and
+ switching from one to another requires rebooting. If you decide to use xl,
+ then the settings in your xend-config.sxp will be ignored, and you will
+ have to setup networking on your own (no pre-built bridging scripts are
+ provided for example).
+ .
+ The xm and xl toolstack are compatible (just the userland executable is
+ called differently), and your old xm/xend virtual machine startup files
+ will continue to work (xl knows its syntax) but they shouldn't contain
+ python code.
+ .
+ Note that if you wish to use Xen with XCP (Xen Cloud Platform), then using
+ xl is mandatory.
--- xen-utils-common.xend.init.orig 2012-01-17 21:07:25.000000000 +0000
+++ xen-utils-common.xend.init 2012-01-17 21:12:58.000000000 +0000
@@ -25,6 +25,9 @@
[ "$VERSION" ] || exit 0
[ -x "$XEND" ] || exit 0
+[ -r /etc/default/xen ] && . /etc/default/xen
+[ -z "${TOOLSTACK}" ] && TOOLSTACK="xm"
+
[ -r /etc/default/xend ] && . /etc/default/xend
. /lib/init/vars.sh
@@ -54,17 +57,21 @@
xend_start()
{
- log_progress_msg "xend"
- $XEND status && return 1
- $XEND start || return 2
-
- i=0
- while [ $i -lt 10 ]; do
- $XEND status && return 0 || true
- i=$(($i + 1))
- sleep 1
- done
- return 2
+ if [ ${TOOLSTACK} = "xm" ] ; then
+ log_progress_msg "xend"
+ $XEND status && return 1
+ $XEND start || return 2
+
+ i=0
+ while [ $i -lt 10 ]; do
+ $XEND status && return 0 || true
+ i=$(($i + 1))
+ sleep 1
+ done
+ return 2
+ else
+ return 0
+ fi
}
xend_stop()