2017-04-05 11:32:45 +00:00
|
|
|
# Copyright 2016 The Chromium Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
2017-04-19 17:36:00 +00:00
|
|
|
|
2017-04-05 11:32:45 +00:00
|
|
|
from recipe_engine import recipe_api
|
|
|
|
|
2018-05-24 13:14:18 +00:00
|
|
|
import default
|
2019-04-12 16:27:39 +00:00
|
|
|
import ssh
|
2017-04-05 11:32:45 +00:00
|
|
|
|
|
|
|
|
2018-05-24 13:14:18 +00:00
|
|
|
"""Chromebook flavor, used for running code on Chromebooks."""
|
|
|
|
|
|
|
|
|
2019-04-12 16:27:39 +00:00
|
|
|
class ChromebookFlavor(ssh.SSHFlavor):
|
2017-04-05 11:32:45 +00:00
|
|
|
|
2017-04-07 14:04:08 +00:00
|
|
|
def __init__(self, m):
|
2018-05-24 13:14:18 +00:00
|
|
|
super(ChromebookFlavor, self).__init__(m)
|
2018-05-18 11:36:55 +00:00
|
|
|
self.chromeos_homedir = '/home/chronos/user/'
|
2018-05-24 13:14:18 +00:00
|
|
|
self.device_dirs = default.DeviceDirs(
|
2018-05-18 11:36:55 +00:00
|
|
|
bin_dir = self.chromeos_homedir + 'bin',
|
|
|
|
dm_dir = self.chromeos_homedir + 'dm_out',
|
|
|
|
perf_data_dir = self.chromeos_homedir + 'perf',
|
|
|
|
resource_dir = self.chromeos_homedir + 'resources',
|
|
|
|
images_dir = self.chromeos_homedir + 'images',
|
2018-07-19 17:27:49 +00:00
|
|
|
lotties_dir = self.chromeos_homedir + 'lotties',
|
2018-05-18 11:36:55 +00:00
|
|
|
skp_dir = self.chromeos_homedir + 'skps',
|
|
|
|
svg_dir = self.chromeos_homedir + 'svgs',
|
2019-08-01 17:39:34 +00:00
|
|
|
mskp_dir = self.chromeos_homedir + 'mskp',
|
2018-05-18 11:36:55 +00:00
|
|
|
tmp_dir = self.chromeos_homedir)
|
2017-04-07 14:04:08 +00:00
|
|
|
|
|
|
|
def install(self):
|
2019-04-12 16:27:39 +00:00
|
|
|
super(ChromebookFlavor, self).install()
|
2017-04-07 14:04:08 +00:00
|
|
|
|
|
|
|
# Ensure the home dir is marked executable
|
2019-04-12 16:27:39 +00:00
|
|
|
self.ssh('remount %s as exec' % self.chromeos_homedir,
|
|
|
|
'sudo', 'mount', '-i', '-o', 'remount,exec', '/home/chronos')
|
2017-04-07 14:04:08 +00:00
|
|
|
|
|
|
|
def _copy_dir(self, src, dest):
|
|
|
|
# We can't use rsync to communicate with the chromebooks because the
|
|
|
|
# chromebooks don't have rsync installed on them.
|
|
|
|
self.m.python.inline(str('scp -r %s %s' % (src, dest)),
|
|
|
|
"""
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
src = sys.argv[1] + '/*'
|
|
|
|
dest = sys.argv[2]
|
|
|
|
print subprocess.check_output('scp -r %s %s' % (src, dest), shell=True)
|
|
|
|
""", args=[src, dest], infra_step=True)
|
|
|
|
|
|
|
|
def copy_directory_contents_to_device(self, host_path, device_path):
|
2019-04-12 16:27:39 +00:00
|
|
|
self._copy_dir(host_path, self.scp_device_path(device_path))
|
2017-04-07 14:04:08 +00:00
|
|
|
|
|
|
|
def copy_directory_contents_to_host(self, device_path, host_path):
|
2019-04-12 16:27:39 +00:00
|
|
|
self._copy_dir(self.scp_device_path(device_path), host_path)
|