blob: de17ba01f89a54c0b3f3b6671712d8d0d5b625f9 [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
Brad Bishop19323692019-04-05 15:28:33 -040010 self.targetdir = "~/buildtest/"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050011 BuildProject.__init__(self, uri, foldername, dl_dir=dl_dir)
12
13 def download_archive(self):
Brad Bishop19323692019-04-05 15:28:33 -040014 self.target.run("mkdir " + self.targetdir + " || true")
15
Brad Bishop6e60e8b2018-02-01 10:27:11 -050016 self._download_archive()
17
18 status, output = self.target.copyTo(self.localarchive, self.targetdir)
19 if status:
20 raise Exception('Failed to copy archive to target, '
21 'output: %s' % output)
22
23 cmd = 'tar xf %s%s -C %s' % (self.targetdir,
24 self.archive,
25 self.targetdir)
26 status, output = self.target.run(cmd)
27 if status:
28 raise Exception('Failed to extract archive, '
29 'output: %s' % output)
30
31 # Change targetdir to project folder
32 self.targetdir = self.targetdir + self.fname
33
34 # The timeout parameter of target.run is set to 0
35 # to make the ssh command run with no timeout.
36 def _run(self, cmd):
37 ret = self.target.run(cmd, 0)
38 msg = "Command %s failed with exit code %s: %s" % (cmd, ret[0], ret[1])
39 if ret[0] != 0:
40 raise Exception(msg)
41 return ret[0]