blob: 5af55d736e464e8c7944d69e95d170d89461544a [file] [log] [blame]
Brad Bishop6e60e8b2018-02-01 10:27:11 -05001# Copyright (C) 2016 Intel Corporation
2# Released under the MIT license (see COPYING.MIT)
3
4from oeqa.utils.buildproject import BuildProject
5
6class TargetBuildProject(BuildProject):
7
8 def __init__(self, target, uri, foldername=None, dl_dir=None):
9 self.target = target
10 self.targetdir = "~/"
11 BuildProject.__init__(self, uri, foldername, dl_dir=dl_dir)
12
13 def download_archive(self):
14 self._download_archive()
15
16 status, output = self.target.copyTo(self.localarchive, self.targetdir)
17 if status:
18 raise Exception('Failed to copy archive to target, '
19 'output: %s' % output)
20
21 cmd = 'tar xf %s%s -C %s' % (self.targetdir,
22 self.archive,
23 self.targetdir)
24 status, output = self.target.run(cmd)
25 if status:
26 raise Exception('Failed to extract archive, '
27 'output: %s' % output)
28
29 # Change targetdir to project folder
30 self.targetdir = self.targetdir + self.fname
31
32 # The timeout parameter of target.run is set to 0
33 # to make the ssh command run with no timeout.
34 def _run(self, cmd):
35 ret = self.target.run(cmd, 0)
36 msg = "Command %s failed with exit code %s: %s" % (cmd, ret[0], ret[1])
37 if ret[0] != 0:
38 raise Exception(msg)
39 return ret[0]