From 74735e36db71b0b728bd93bbabe802b0375b3884 Mon Sep 17 00:00:00 2001
From: Nikos Skalkotos <skalkoto@grnet.gr>
Date: Mon, 6 Oct 2014 15:53:35 +0300
Subject: [PATCH] Detect more Ubuntu variants

Detect Kubuntu, Lubuntu and Xubuntu
---
 image_creator/os_type/ubuntu.py | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/image_creator/os_type/ubuntu.py b/image_creator/os_type/ubuntu.py
index 570fd32..7b73ab4 100644
--- a/image_creator/os_type/ubuntu.py
+++ b/image_creator/os_type/ubuntu.py
@@ -17,6 +17,8 @@
 
 """This module hosts OS-specific code for Ubuntu Linux"""
 
+import re
+
 from image_creator.os_type.linux import Linux
 
 
@@ -27,12 +29,19 @@ class Ubuntu(Linux):
         """Collect metadata about the OS"""
 
         super(Ubuntu, self)._do_collect_metadata()
-        apps = self.image.g.inspect_list_applications(self.root)
-        for app in apps:
-            if app['app_name'] == 'kubuntu-desktop':
-                self.meta['OS'] = 'kubuntu'
-                descr = self.meta['DESCRIPTION'].replace('Ubuntu', 'Kubuntu')
-                self.meta['DESCRIPTION'] = descr
+
+        regexp = re.compile('^(k|l|x)?ubuntu-desktop$')
+        variant = ""
+        for app in self.image.g.inspect_list_applications(self.root):
+            match = regexp.match(app['app_name'])
+            if match:
+                variant = match.group(1) + 'ubuntu'
                 break
 
+        if variant:
+            self.meta['OS'] = variant
+            descr = self.meta['DESCRIPTION'].replace('Ubuntu',
+                                                     variant.capitalize())
+            self.meta['DESCRIPTION'] = descr
+
 # vim: set sta sts=4 shiftwidth=4 sw=4 et ai :
-- 
GitLab