[Kimchi-devel] [PATCH 4/6] Update Kimchi to use the installed spice-html5

Aline Manera alinefm at linux.vnet.ibm.com
Fri Oct 10 21:16:54 UTC 2014


spice-html5 is present in almost all supported Linux distributions
(RHEL6.5, Fedora20 and Ubuntu 14.04). So in those cases we should not package
the spice-html5 code into Kimchi and instead of that uses the spice-html5 package
as dependency.

This patch change the build process to check the spice-html5 package
availability in order to decide to package or not the spice-html5 code.

spice-html5 package is not available for RHEL7 and openSUSE 13.1. So
for those distributions, you must run the following command to Kimchi
includes the spice-html5 into its package.

./autogen.sh --with-spice-html5

Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
---
 contrib/DEBIAN/control.in     |  3 ++-
 contrib/kimchi.spec.fedora.in |  8 ++++++++
 contrib/kimchi.spec.suse.in   |  2 +-
 docs/README.md                | 10 +++++++++-
 src/kimchi/Makefile.am        | 11 +++++++++--
 src/kimchi/config.py.in       | 33 ++++++++++++++++++++++++++-------
 tests/test_config.py.in       | 15 ++++++++++++++-
 ui/js/src/kimchi.api.js       |  2 +-
 8 files changed, 70 insertions(+), 14 deletions(-)

diff --git a/contrib/DEBIAN/control.in b/contrib/DEBIAN/control.in
index 7372a58..08ef72d 100644
--- a/contrib/DEBIAN/control.in
+++ b/contrib/DEBIAN/control.in
@@ -27,7 +27,8 @@ Depends: python-cherrypy3 (>= 3.2.0),
          firewalld,
          nginx,
          python-guestfs,
-         libguestfs-tools
+         libguestfs-tools,
+         spice-html5
 Build-Depends: libxslt,
                python-libxml2,
                python-requests
diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in
index 29583e4..8c3c264 100644
--- a/contrib/kimchi.spec.fedora.in
+++ b/contrib/kimchi.spec.fedora.in
@@ -35,6 +35,10 @@ BuildRequires:	libxslt
 BuildRequires:	libxml2-python
 BuildRequires:	python-requests
 
+%if 0%{?rhel} == 6 || 0%{?fedora} >= 19
+Requires:	spice-html5
+%endif
+
 %if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
 %global with_systemd 1
 %endif
@@ -66,7 +70,11 @@ Web server application to manage KVM/Qemu virtual machines
 
 
 %build
+%if 0%{?rhel} != 6 || 0%{?fedora} < 19
+%configure --with-spice-html5
+%else
 %configure
+%endif
 make
 
 
diff --git a/contrib/kimchi.spec.suse.in b/contrib/kimchi.spec.suse.in
index 2936787..43794c0 100644
--- a/contrib/kimchi.spec.suse.in
+++ b/contrib/kimchi.spec.suse.in
@@ -45,7 +45,7 @@ Web server application to manage KVM/Qemu virtual machines
 %setup
 
 %build
-%configure
+%configure --with-spice-html5
 make
 
 %install
diff --git a/docs/README.md b/docs/README.md
index 7703037..432cb4e 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -57,6 +57,10 @@ Install Dependencies
                         policycoreutils-python python-libguestfs \
                         libguestfs-tools python-requests python-websockify \
                         novnc
+
+     # If using RHEL6 or Fedora, install the following additional package:
+     $ sudo yum install spice-html5
+
      # If using RHEL6, install the following additional packages:
      $ sudo yum install python-unittest2 python-ordereddict
      # Restart libvirt to allow configuration changes to take effect
@@ -80,7 +84,7 @@ for more information on how to configure your system to access this repository.
                            sosreport python-ipaddr python-lxml nfs-common \
                            open-iscsi lvm2 xsltproc python-parted nginx \
                            firewalld python-guestfs libguestfs-tools \
-                           python-requests websockify novnc
+                           python-requests websockify novnc spice-html5
 
     Packages version requirement:
         python-jsonschema >= 1.3.0
@@ -112,8 +116,12 @@ information on how configure your system to access this repository.
 
 Build and Install
 -----------------
+    For RHEL7 and openSUSE 13.1:
+    $ ./autogen.sh --with-spice-html5
 
+    Otherwise:
     $ ./autogen.sh --system
+
     $ make
     $ sudo make install   # Optional if running from the source tree
 
diff --git a/src/kimchi/Makefile.am b/src/kimchi/Makefile.am
index e2b5de8..84def58 100644
--- a/src/kimchi/Makefile.am
+++ b/src/kimchi/Makefile.am
@@ -27,6 +27,12 @@ EXTRA_DIST = \
 	API.json \
 	config.py.in
 
+if WITH_SPICE
+WITH_SPICE=yes
+else
+WITH_SPICE=no
+endif
+
 kimchidir = $(pythondir)/kimchi
 
 install-data-local:
@@ -38,13 +44,14 @@ uninstall-local:
 
 do_substitution = \
 	sed -e 's,[@]prefix[@],$(prefix),g'             \
-	-e 's,[@]datadir[@],$(datadir),g'         \
+	-e 's,[@]datadir[@],$(datadir),g'               \
 	-e 's,[@]sysconfdir[@],$(sysconfdir),g'         \
 	-e 's,[@]localstatedir[@],$(localstatedir),g'   \
 	-e 's,[@]pkgdatadir[@],$(pkgdatadir),g'         \
 	-e 's,[@]kimchidir[@],$(kimchidir),g'           \
 	-e 's,[@]kimchiversion[@],$(PACKAGE_VERSION),g' \
-	-e 's,[@]kimchirelease[@],$(PACKAGE_RELEASE),g'
+	-e 's,[@]kimchirelease[@],$(PACKAGE_RELEASE),g' \
+	-e 's,[@]withspice[@],$(WITH_SPICE),g'
 
 
 config.py: config.py.in Makefile
diff --git a/src/kimchi/config.py.in b/src/kimchi/config.py.in
index 097c017..0822bab 100644
--- a/src/kimchi/config.py.in
+++ b/src/kimchi/config.py.in
@@ -31,6 +31,7 @@ from kimchi.xmlutils import xpath_get_text
 
 __version__ = "@kimchiversion@"
 __release__ = "@kimchirelease@"
+__with_spice__ = "@withspice@"
 
 DEFAULT_LOG_LEVEL = "debug"
 
@@ -87,6 +88,14 @@ class Paths(object):
     def __init__(self):
         self.prefix = self.get_prefix()
         self.installed = (self.prefix == '@pkgdatadir@')
+        self.ui_dir = self.add_prefix('ui')
+        self.spice_file = os.path.join(self.ui_dir,
+                                       'spice-html5/pages/spice_auto.html')
+
+        if __with_spice__ == "yes":
+            self.spice_dir = self.add_prefix('ui/spice-html5')
+        else:
+            self.spice_dir = '@datadir@/spice-html5'
 
         if self.installed:
             self.state_dir = '@localstatedir@/lib/kimchi'
@@ -94,19 +103,16 @@ class Paths(object):
             self.conf_dir = '@sysconfdir@/kimchi'
             self.src_dir = '@kimchidir@'
             self.plugins_dir = '@kimchidir@/plugins'
+            self.mo_dir = '@prefix@/share/locale'
+            self.spice_css_file = os.path.join(self.spice_dir, 'spice.css')
         else:
             self.state_dir = self.add_prefix('data')
             self.log_dir = self.add_prefix('log')
             self.conf_dir = self.add_prefix('src')
             self.src_dir = self.add_prefix('src/kimchi')
             self.plugins_dir = self.add_prefix('plugins')
-
-        self.ui_dir = self.add_prefix('ui')
-
-        if self.installed:
-            self.mo_dir = '@prefix@/share/locale'
-        else:
             self.mo_dir = self.add_prefix('mo')
+            self.spice_css_file = os.path.join(self.spice_dir, 'css/spice.css')
 
     def get_prefix(self):
         if __file__.startswith("/"):
@@ -191,9 +197,22 @@ class KimchiConfig(dict):
             'tools.nocache.on': True,
             'tools.kimchiauth.on': True
         },
-        '/spice.html': {
+        '/spice_auto.html': {
+            'tools.staticfile.on': True,
+            'tools.staticfile.filename': paths.spice_file,
+            'tools.nocache.on': True,
             'tools.kimchiauth.on': True
         },
+        '/spice-html5': {
+            'tools.staticdir.on': True,
+            'tools.staticdir.dir': paths.spice_dir,
+            'tools.nocache.on': True
+        },
+        '/spice-html5/spice.css': {
+            'tools.staticfile.on': True,
+            'tools.staticfile.filename': paths.spice_css_file,
+            'tools.nocache.on': True,
+        },
         '/kimchi-ui.html': {
             'tools.kimchiauth.on': True
         },
diff --git a/tests/test_config.py.in b/tests/test_config.py.in
index af7adc1..1145ffd 100644
--- a/tests/test_config.py.in
+++ b/tests/test_config.py.in
@@ -112,9 +112,22 @@ class ConfigTests(unittest.TestCase):
                 'tools.nocache.on': True,
                 'tools.kimchiauth.on': True
             },
-            '/spice.html': {
+            '/spice_auto.html': {
+                'tools.staticfile.on': True,
+                'tools.staticfile.filename': paths.spice_file,
+                'tools.nocache.on': True,
                 'tools.kimchiauth.on': True
             },
+            '/spice-html5': {
+                'tools.staticdir.on': True,
+                'tools.staticdir.dir': paths.spice_dir,
+                'tools.nocache.on': True
+            },
+            '/spice-html5/spice.css': {
+                'tools.staticfile.on': True,
+                'tools.staticfile.filename': paths.spice_css_file,
+                'tools.nocache.on': True,
+            },
             '/kimchi-ui.html': {
                 'tools.kimchiauth.on': True
             },
diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
index f0506fa..f129fb1 100644
--- a/ui/js/src/kimchi.api.js
+++ b/ui/js/src/kimchi.api.js
@@ -385,7 +385,7 @@ var kimchi = {
                 dataType : "json"
             }).done(function(data, textStatus, xhr) {
                 url = 'https://' + location.hostname + ':' + proxy_port;
-                url += "/console.html?url=spice.html&port=" + proxy_port;
+                url += "/console.html?url=spice_auto.html&port=" + proxy_port;
                 url += "&listen=" + location.hostname;
                 /*
                  * From python documentation base64.urlsafe_b64encode(s)
-- 
1.9.3




More information about the Kimchi-devel mailing list