[omd-commits] OMD Git: omd: omd: Finished setversion command; Handles debian distros correctly now; Added to manpage

git version control git at mathias-kettner.de
Thu Jun 9 23:54:24 CEST 2011


Module:   omd
Branch:   master
Commit:   a9481128f866cb23d8d9052a387c0e42e65754d9
URL:      http://omdistro.org/projects/omd/repository/revisions/a9481128f866cb23d8d9052a387c0e42e65754d9

Author:   Lars Michelsen <lm at mathias-kettner.de>
Date:     Thu Jun  9 23:53:33 2011 +0200
Commiter: Lars Michelsen <lm at mathias-kettner.de>
Date:     Thu Jun  9 23:53:33 2011 +0200

omd: Finished setversion command; Handles debian distros correctly now; Added to manpage

---

 packages/omd/omd   |   25 ++++++++++++++++++++-----
 packages/omd/omd.8 |    8 ++++++++
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/packages/omd/omd b/packages/omd/omd
index 385e663..79f8277 100644
--- a/packages/omd/omd
+++ b/packages/omd/omd
@@ -1840,9 +1840,12 @@ def main_uninstall(args, options={}):
 
 def main_setversion(args, options={}):
     if len(args) == 0:
+        versions = [ (v, "Version %s" % v) for v in omd_versions() if not v == default_version() ]
+        if use_update_alternatives():
+            versions = [ ('auto', 'Auto (Update-Alternatives)') ] + versions
         ok, version = dialog_menu("Choose new default",
                 "Please choose the version to make the new default",
-                [ (v, "Version %s" % v) for v in omd_versions() if not v == default_version() ],
+                versions,
                 None,
                 "Make default",
                 "Cancel")
@@ -1851,14 +1854,26 @@ def main_setversion(args, options={}):
     else:
         version = args[0]
 
-    if not version in omd_versions():
+    if version != 'auto' and not version in omd_versions():
         bail_out("The given version does not exist.")
     if version == default_version():
         bail_out("The given version is already default.")
 
-    if os.path.exists("/omd/versions/default"):
-        os.remove("/omd/versions/default")
-    os.symlink("/omd/versions/%s" % version, "/omd/versions/default")
+    # Special handling for debian based distros which use update-alternatives
+    # to control the path to the omd binary, manpage and so on
+    if use_update_alternatives():
+        if version == 'auto':
+            os.system("update-alternatives --auto omd")
+        else:
+            os.system("update-alternatives --set omd /omd/versions/%s" % version)
+    else:
+        if os.path.exists("/omd/versions/default"):
+            os.remove("/omd/versions/default")
+        os.symlink("/omd/versions/%s" % version, "/omd/versions/default")
+
+
+def use_update_alternatives():
+    return os.path.exists("/var/lib/dpkg/alternatives/omd")
 
 
 def main_version(args, options={}):
diff --git a/packages/omd/omd.8 b/packages/omd/omd.8
index fcc1378..011fa5c 100644
--- a/packages/omd/omd.8
+++ b/packages/omd/omd.8
@@ -56,6 +56,14 @@ Show a list of all installed versions of OMD. The option \fB-b\fP or \fB--bare\f
 makes the output leave out a hint to the default version and easier parseable by
 scripts.
 .TP
+.B omd setversion [VERSION]
+Sets the default OMD version to be used for new sites. Can be called with a target
+version as optional argument or without argument to get a menu of available versions displayed.
+
+This mainly updates the symlink \fB/omd/versions/default\fP. On debian based distributions
+it calls update-alternatives to change the default versions. In this case there is a special
+option \fBauto\fP available to let update-alternatives choose the default OMD version.
+.TP
 .B omd setup                       
 Prepare operating system for OMD. This includes installing all software
 packages from your linux distribution that the components of OMD need



More information about the omd-commits mailing list