=== modified file 'lava_dispatcher/actions/android_deploy.py'
@@ -20,6 +20,7 @@
# along with this program; if not, see <http://www.gnu.org/licenses>.
from lava_dispatcher.actions import BaseAction
+from lava_dispatcher.client.fastmodel import LavaFastModelClient
from lava_dispatcher.client.master import LavaMasterImageClient
@@ -39,6 +40,7 @@
}
def run(self, boot, system, data, pkg=None, use_cache=True, rootfstype='ext4'):
- if not isinstance(self.client, LavaMasterImageClient):
+ if not isinstance(self.client, LavaMasterImageClient) and \
+ not isinstance(self.client, LavaFastModelClient):
raise RuntimeError("Invalid LavaClient for this action")
self.client.deploy_linaro_android(boot, system, data, pkg, use_cache, rootfstype)
=== modified file 'lava_dispatcher/client/fastmodel.py'
@@ -23,6 +23,7 @@
import logging
import os
import pexpect
+import shutil
import threading
from lava_dispatcher.client.base import (
@@ -31,6 +32,7 @@
)
from lava_dispatcher.client.lmc_utils import (
image_partition_mounted,
+ generate_android_image,
get_partition_offset,
)
from lava_dispatcher.downloader import (
@@ -91,6 +93,28 @@
else:
self._customize_ubuntu()
+ def deploy_linaro_android(self, boot, system, data, pkg=None,
+ use_cache=True, rootfstype='ext4'):
+ logging.info("Deploying Android on %s" % self.hostname)
+
+ self._boot = download_image(boot, self.context, decompress=False)
+ self._data = download_image(data, self.context, decompress=False)
+ self._system = download_image(system, self.context, decompress=False)
+
+ self._sd_image = '%s/android.img' % os.path.dirname(self._system)
+
+ generate_android_image(
+ 'vexpress-a9', self._boot, self._data, self._system, self._sd_image)
+
+ # now grab the axf file from the boot partition
+ with image_partition_mounted(self._sd_image, self.boot_part) as mntdir:
+ src = '%s/linux-system-ISW.axf' % mntdir
+ self._axf = \
+ '%s/%s' % (os.path.dirname(self._system),os.path.split(src)[1])
+ shutil.copyfile(src, self._axf)
+
+ self._customize_android()
+
def _close_sim_proc(self):
self._sim_proc.close(True)
=== modified file 'lava_dispatcher/client/lmc_utils.py'
@@ -115,6 +115,14 @@
raise
return image_file
+def generate_android_image(device, boot, data, system, ofile, size="2000M"):
+ cmd = ("flock /var/lock/lava-lmc.lck sudo linaro-android-media-create "
+ "--dev %s --image_file %s --image_size %s "
+ "--boot %s --userdata %s --system %s" %
+ (device, ofile, size, boot, data,system) )
+ logging.info("Generating android image with: %s" % cmd)
+ _run_linaro_media_create(cmd)
+
def get_partition_offset(image, partno):
cmd = 'parted %s -m -s unit b print' % image
part_data = getoutput(cmd)
=== modified file 'lava_dispatcher/downloader.py'
@@ -75,15 +75,15 @@
fd.close()
@contextlib.contextmanager
-def _decompressor_stream(url, imgdir):
+def _decompressor_stream(url, imgdir, decompress):
fd = None
decompressor = None
fname,suffix = _url_to_fname_suffix(url, imgdir)
- if suffix == 'gz':
+ if suffix == 'gz' and decompress:
decompressor = zlib.decompressobj(16+zlib.MAX_WBITS)
- elif suffix == 'bz2':
+ elif suffix == 'bz2' and decompress:
decompressor = bz2.BZ2Decompressor()
else:
fname = '%s.%s' % (fname, suffix) #don't remove the file's real suffix
@@ -107,9 +107,10 @@
filename = os.path.join(path, '.'.join(parts[:-1]))
return (filename, suffix)
-def download_image(url, context, imgdir=None, delete_on_exit=True):
+def download_image(url, context, imgdir=None,
+ delete_on_exit=True, decompress=True):
'''downloads a image that's been compressed as .bz2 or .gz and
- decompresses it on the file to the cache directory
+ optionally decompresses it on the file to the cache directory
'''
logging.info("Downloading image: %s" % url)
if not imgdir:
@@ -129,7 +130,7 @@
raise Exception("Unsupported url protocol scheme: %s" % url.scheme)
with reader(url, context.lava_proxy, context.lava_cookies) as r:
- with _decompressor_stream(url, imgdir) as (writer, fname):
+ with _decompressor_stream(url, imgdir, decompress) as (writer, fname):
bsize = 32768
buff = r.read(bsize)
while buff: