diff options
author | Aníbal Limón <anibal.limon@linux.intel.com> | 2016-11-02 13:04:28 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-01-23 12:05:19 +0000 |
commit | 72e9ae377d310282f1c8cc49d4806b26a0b41e79 (patch) | |
tree | 5aa0a7e6a380ea01bff7d32b04f152b81f72b5d8 /meta/lib | |
parent | 92c57a5db7848edc993b3d9450c473f6e8861224 (diff) | |
download | poky-72e9ae377d310282f1c8cc49d4806b26a0b41e79.tar.gz |
oeqa/utils: Move targetbuild to buildproject module
The new buildproject module will contain only BuildProject class
a helper class for build source code.
The remaining classes TargetBuildProject and SDKBuildProject was
move to runtime and sdk respectively.
[YOCTO #10599]
(From OE-Core rev: 525fd2a5cda00890e921b63f7f608a10bc024d73)
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oeqa/runtime/utils/__init__.py | 0 | ||||
-rw-r--r-- | meta/lib/oeqa/runtime/utils/targetbuildproject.py | 33 | ||||
-rw-r--r-- | meta/lib/oeqa/sdk/utils/__init__.py | 0 | ||||
-rw-r--r-- | meta/lib/oeqa/sdk/utils/sdkbuildproject.py | 45 | ||||
-rw-r--r-- | meta/lib/oeqa/utils/buildproject.py | 69 |
5 files changed, 147 insertions, 0 deletions
diff --git a/meta/lib/oeqa/runtime/utils/__init__.py b/meta/lib/oeqa/runtime/utils/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/meta/lib/oeqa/runtime/utils/__init__.py | |||
diff --git a/meta/lib/oeqa/runtime/utils/targetbuildproject.py b/meta/lib/oeqa/runtime/utils/targetbuildproject.py new file mode 100644 index 0000000000..138b5ef041 --- /dev/null +++ b/meta/lib/oeqa/runtime/utils/targetbuildproject.py | |||
@@ -0,0 +1,33 @@ | |||
1 | # Copyright (C) 2016 Intel Corporation | ||
2 | # Released under the MIT license (see COPYING.MIT) | ||
3 | |||
4 | from oeqa.utils.buildproject import BuildProject | ||
5 | |||
6 | class TargetBuildProject(BuildProject): | ||
7 | |||
8 | def __init__(self, target, d, uri, foldername=None): | ||
9 | self.target = target | ||
10 | self.targetdir = "~/" | ||
11 | BuildProject.__init__(self, d, uri, foldername, tmpdir="/tmp") | ||
12 | |||
13 | def download_archive(self): | ||
14 | |||
15 | self._download_archive() | ||
16 | |||
17 | (status, output) = self.target.copy_to(self.localarchive, self.targetdir) | ||
18 | if status != 0: | ||
19 | raise Exception("Failed to copy archive to target, output: %s" % output) | ||
20 | |||
21 | (status, output) = self.target.run('tar xf %s%s -C %s' % (self.targetdir, self.archive, self.targetdir)) | ||
22 | if status != 0: | ||
23 | raise Exception("Failed to extract archive, output: %s" % output) | ||
24 | |||
25 | #Change targetdir to project folder | ||
26 | self.targetdir = self.targetdir + self.fname | ||
27 | |||
28 | # The timeout parameter of target.run is set to 0 to make the ssh command | ||
29 | # run with no timeout. | ||
30 | def _run(self, cmd): | ||
31 | return self.target.run(cmd, 0)[0] | ||
32 | |||
33 | |||
diff --git a/meta/lib/oeqa/sdk/utils/__init__.py b/meta/lib/oeqa/sdk/utils/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/meta/lib/oeqa/sdk/utils/__init__.py | |||
diff --git a/meta/lib/oeqa/sdk/utils/sdkbuildproject.py b/meta/lib/oeqa/sdk/utils/sdkbuildproject.py new file mode 100644 index 0000000000..1eebd3a5bc --- /dev/null +++ b/meta/lib/oeqa/sdk/utils/sdkbuildproject.py | |||
@@ -0,0 +1,45 @@ | |||
1 | # Copyright (C) 2016 Intel Corporation | ||
2 | # Released under the MIT license (see COPYING.MIT) | ||
3 | |||
4 | import os | ||
5 | import subprocess | ||
6 | |||
7 | from oeqa.utils.buildproject import BuildProject | ||
8 | |||
9 | class SDKBuildProject(BuildProject): | ||
10 | |||
11 | def __init__(self, testpath, sdkenv, d, uri, foldername=None): | ||
12 | self.sdkenv = sdkenv | ||
13 | self.testdir = testpath | ||
14 | self.targetdir = testpath | ||
15 | bb.utils.mkdirhier(testpath) | ||
16 | self.datetime = d.getVar('DATETIME') | ||
17 | self.testlogdir = d.getVar("TEST_LOG_DIR") | ||
18 | bb.utils.mkdirhier(self.testlogdir) | ||
19 | self.logfile = os.path.join(self.testlogdir, "sdk_target_log.%s" % self.datetime) | ||
20 | BuildProject.__init__(self, d, uri, foldername, tmpdir=testpath) | ||
21 | |||
22 | def download_archive(self): | ||
23 | |||
24 | self._download_archive() | ||
25 | |||
26 | cmd = 'tar xf %s%s -C %s' % (self.targetdir, self.archive, self.targetdir) | ||
27 | subprocess.check_call(cmd, shell=True) | ||
28 | |||
29 | #Change targetdir to project folder | ||
30 | self.targetdir = os.path.join(self.targetdir, self.fname) | ||
31 | |||
32 | def run_configure(self, configure_args='', extra_cmds=' gnu-configize; '): | ||
33 | return super(SDKBuildProject, self).run_configure(configure_args=(configure_args or '$CONFIGURE_FLAGS'), extra_cmds=extra_cmds) | ||
34 | |||
35 | def run_install(self, install_args=''): | ||
36 | return super(SDKBuildProject, self).run_install(install_args=(install_args or "DESTDIR=%s/../install" % self.targetdir)) | ||
37 | |||
38 | def log(self, msg): | ||
39 | if self.logfile: | ||
40 | with open(self.logfile, "a") as f: | ||
41 | f.write("%s\n" % msg) | ||
42 | |||
43 | def _run(self, cmd): | ||
44 | self.log("Running . %s; " % self.sdkenv + cmd) | ||
45 | return subprocess.call(". %s; " % self.sdkenv + cmd, shell=True) | ||
diff --git a/meta/lib/oeqa/utils/buildproject.py b/meta/lib/oeqa/utils/buildproject.py new file mode 100644 index 0000000000..1ed9624a76 --- /dev/null +++ b/meta/lib/oeqa/utils/buildproject.py | |||
@@ -0,0 +1,69 @@ | |||
1 | # Copyright (C) 2013-2016 Intel Corporation | ||
2 | # | ||
3 | # Released under the MIT license (see COPYING.MIT) | ||
4 | |||
5 | # Provides a class for automating build tests for projects | ||
6 | |||
7 | import os | ||
8 | import re | ||
9 | import bb.utils | ||
10 | import subprocess | ||
11 | from abc import ABCMeta, abstractmethod | ||
12 | |||
13 | class BuildProject(metaclass=ABCMeta): | ||
14 | |||
15 | def __init__(self, d, uri, foldername=None, tmpdir="/tmp/"): | ||
16 | self.d = d | ||
17 | self.uri = uri | ||
18 | self.archive = os.path.basename(uri) | ||
19 | self.localarchive = os.path.join(tmpdir,self.archive) | ||
20 | if foldername: | ||
21 | self.fname = foldername | ||
22 | else: | ||
23 | self.fname = re.sub(r'\.tar\.bz2$|\.tar\.gz$|\.tar\.xz$', '', self.archive) | ||
24 | |||
25 | # Download self.archive to self.localarchive | ||
26 | def _download_archive(self): | ||
27 | |||
28 | dl_dir = self.d.getVar("DL_DIR") | ||
29 | if dl_dir and os.path.exists(os.path.join(dl_dir, self.archive)): | ||
30 | bb.utils.copyfile(os.path.join(dl_dir, self.archive), self.localarchive) | ||
31 | return | ||
32 | |||
33 | exportvars = ['HTTP_PROXY', 'http_proxy', | ||
34 | 'HTTPS_PROXY', 'https_proxy', | ||
35 | 'FTP_PROXY', 'ftp_proxy', | ||
36 | 'FTPS_PROXY', 'ftps_proxy', | ||
37 | 'NO_PROXY', 'no_proxy', | ||
38 | 'ALL_PROXY', 'all_proxy', | ||
39 | 'SOCKS5_USER', 'SOCKS5_PASSWD'] | ||
40 | |||
41 | cmd = '' | ||
42 | for var in exportvars: | ||
43 | val = self.d.getVar(var) | ||
44 | if val: | ||
45 | cmd = 'export ' + var + '=\"%s\"; %s' % (val, cmd) | ||
46 | |||
47 | cmd = cmd + "wget -O %s %s" % (self.localarchive, self.uri) | ||
48 | subprocess.check_call(cmd, shell=True) | ||
49 | |||
50 | # This method should provide a way to run a command in the desired environment. | ||
51 | @abstractmethod | ||
52 | def _run(self, cmd): | ||
53 | pass | ||
54 | |||
55 | # The timeout parameter of target.run is set to 0 to make the ssh command | ||
56 | # run with no timeout. | ||
57 | def run_configure(self, configure_args='', extra_cmds=''): | ||
58 | return self._run('cd %s; %s ./configure %s' % (self.targetdir, extra_cmds, configure_args)) | ||
59 | |||
60 | def run_make(self, make_args=''): | ||
61 | return self._run('cd %s; make %s' % (self.targetdir, make_args)) | ||
62 | |||
63 | def run_install(self, install_args=''): | ||
64 | return self._run('cd %s; make install %s' % (self.targetdir, install_args)) | ||
65 | |||
66 | def clean(self): | ||
67 | self._run('rm -rf %s' % self.targetdir) | ||
68 | subprocess.call('rm -f %s' % self.localarchive, shell=True) | ||
69 | pass | ||