blob: f4f4816a9b96e1ed395a906a6e2989a9fa81e73d [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
Brad Bishop6e60e8b2018-02-01 10:27:11 -05002# Copyright (C) 2016 Intel Corporation
Brad Bishopc342db32019-05-15 21:57:59 -04003#
4# SPDX-License-Identifier: MIT
5#
Brad Bishop6e60e8b2018-02-01 10:27:11 -05006
7from oeqa.utils.buildproject import BuildProject
8
9class TargetBuildProject(BuildProject):
10
11 def __init__(self, target, uri, foldername=None, dl_dir=None):
12 self.target = target
Brad Bishop19323692019-04-05 15:28:33 -040013 self.targetdir = "~/buildtest/"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050014 BuildProject.__init__(self, uri, foldername, dl_dir=dl_dir)
15
16 def download_archive(self):
Brad Bishop19323692019-04-05 15:28:33 -040017 self.target.run("mkdir " + self.targetdir + " || true")
18
Brad Bishop6e60e8b2018-02-01 10:27:11 -050019 self._download_archive()
20
21 status, output = self.target.copyTo(self.localarchive, self.targetdir)
22 if status:
23 raise Exception('Failed to copy archive to target, '
24 'output: %s' % output)
25
26 cmd = 'tar xf %s%s -C %s' % (self.targetdir,
27 self.archive,
28 self.targetdir)
29 status, output = self.target.run(cmd)
30 if status:
31 raise Exception('Failed to extract archive, '
32 'output: %s' % output)
33
34 # Change targetdir to project folder
35 self.targetdir = self.targetdir + self.fname
36
37 # The timeout parameter of target.run is set to 0
38 # to make the ssh command run with no timeout.
39 def _run(self, cmd):
40 ret = self.target.run(cmd, 0)
41 msg = "Command %s failed with exit code %s: %s" % (cmd, ret[0], ret[1])
42 if ret[0] != 0:
43 raise Exception(msg)
44 return ret[0]