diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 236: allow deploying from an image compressed with gzip, bzip2 or xz

Message ID 20120229013610.1957.21541.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Michael-Doyle Hudson Feb. 29, 2012, 1:36 a.m. UTC
Merge authors:
  Michael Hudson-Doyle (mwhudson)
Related merge proposals:
  https://code.launchpad.net/~mwhudson/lava-dispatcher/deploy-from-compressed-image-bug-940036/+merge/94904
  proposed by: Michael Hudson-Doyle (mwhudson)
------------------------------------------------------------
revno: 236 [merge]
committer: Michael Hudson-Doyle <michael.hudson@linaro.org>
branch nick: trunk
timestamp: Wed 2012-02-29 14:34:44 +1300
message:
  allow deploying from an image compressed with gzip, bzip2 or xz
modified:
  lava_dispatcher/client/master.py
  lava_dispatcher/utils.py


--
lp:lava-dispatcher
https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk

You are subscribed to branch lp:lava-dispatcher.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava_dispatcher/client/master.py'
--- lava_dispatcher/client/master.py	2012-02-26 22:17:45 +0000
+++ lava_dispatcher/client/master.py	2012-02-29 01:33:14 +0000
@@ -20,13 +20,14 @@ 
 # with this program; if not, see <http://www.gnu.org/licenses>.
 
 import contextlib
+import logging
 import os
 import pexpect
 import shutil
-import traceback
+import subprocess
 from tempfile import mkdtemp
-import logging
 import time
+import traceback
 
 from lava_dispatcher.utils import (
     download,
@@ -261,6 +262,19 @@ 
     def master_str(self):
         return self.device_option("MASTER_STR")
 
+    def decompress(self, image_file):
+        for suffix, command in [('.gz', 'gunzip'),
+                                ('.xz', 'unxz'),
+                                ('.bz2', 'bunzip2')]:
+            if image_file.endswith(suffix):
+                logging.info("Uncompressing %s with %s", image_file, command)
+                uncompressed_name = image_file[:-len(suffix)]
+                subprocess.check_call(
+                    [command, '-c', image_file], stdout=open(uncompressed_name, 'w'))
+                return uncompressed_name
+        return image_file
+
+
     def deploy_linaro(self, hwpack=None, rootfs=None, image=None,
                       kernel_matrix=None, use_cache=True, rootfstype='ext3'):
         LAVA_IMAGE_TMPDIR = self.context.lava_image_tmpdir
@@ -283,6 +297,7 @@ 
                     image_file = download_with_cache(image, tarball_dir, lava_cachedir)
                 else:
                     image_file = download(image, tarball_dir)
+                image_file = self.decompress(image_file)
             boot_tgz, root_tgz = self._generate_tarballs(image_file)
         except CriticalError:
             raise

=== modified file 'lava_dispatcher/utils.py'
--- lava_dispatcher/utils.py	2012-02-07 19:16:17 +0000
+++ lava_dispatcher/utils.py	2012-02-28 03:19:36 +0000
@@ -86,7 +86,7 @@ 
     splitter.whitespace = ","
     splitter.whitespace_split = True
     newlines_to_spaces = lambda x: x.replace('\n', ' ')
-    strip_newlines = lambda x: newlines_to_spaces(x).strip(' ')    
+    strip_newlines = lambda x: newlines_to_spaces(x).strip(' ')
     return map(strip_newlines, list(splitter))
 
 def logging_system(cmd):