diff options
author | Tudor Florea <tudor.florea@enea.com> | 2014-10-16 03:05:19 +0200 |
---|---|---|
committer | Tudor Florea <tudor.florea@enea.com> | 2014-10-16 03:05:19 +0200 |
commit | c527fd1f14c27855a37f2e8ac5346ce8d940ced2 (patch) | |
tree | bb002c1fdf011c41dbd2f0927bed23ecb5f83c97 /meta/lib/oeqa/utils/targetbuild.py | |
download | poky-daisy-140929.tar.gz |
initial commit for Enea Linux 4.0-140929daisy-140929
Migrated from the internal git server on the daisy-enea-point-release branch
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'meta/lib/oeqa/utils/targetbuild.py')
-rw-r--r-- | meta/lib/oeqa/utils/targetbuild.py | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/meta/lib/oeqa/utils/targetbuild.py b/meta/lib/oeqa/utils/targetbuild.py new file mode 100644 index 0000000000..32296762c0 --- /dev/null +++ b/meta/lib/oeqa/utils/targetbuild.py | |||
@@ -0,0 +1,68 @@ | |||
1 | # Copyright (C) 2013 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 subprocess | ||
10 | |||
11 | |||
12 | class TargetBuildProject(): | ||
13 | |||
14 | def __init__(self, target, d, uri, foldername=None): | ||
15 | self.target = target | ||
16 | self.d = d | ||
17 | self.uri = uri | ||
18 | self.targetdir = "~/" | ||
19 | self.archive = os.path.basename(uri) | ||
20 | self.localarchive = "/tmp/" + self.archive | ||
21 | self.fname = re.sub(r'.tar.bz2|tar.gz$', '', self.archive) | ||
22 | if foldername: | ||
23 | self.fname = foldername | ||
24 | |||
25 | def download_archive(self): | ||
26 | |||
27 | exportvars = ['HTTP_PROXY', 'http_proxy', | ||
28 | 'HTTPS_PROXY', 'https_proxy', | ||
29 | 'FTP_PROXY', 'ftp_proxy', | ||
30 | 'FTPS_PROXY', 'ftps_proxy', | ||
31 | 'NO_PROXY', 'no_proxy', | ||
32 | 'ALL_PROXY', 'all_proxy', | ||
33 | 'SOCKS5_USER', 'SOCKS5_PASSWD'] | ||
34 | |||
35 | cmd = '' | ||
36 | for var in exportvars: | ||
37 | val = self.d.getVar(var, True) | ||
38 | if val: | ||
39 | cmd = 'export ' + var + '=\"%s\"; %s' % (val, cmd) | ||
40 | |||
41 | cmd = cmd + "wget -O %s %s" % (self.localarchive, self.uri) | ||
42 | subprocess.check_call(cmd, shell=True) | ||
43 | |||
44 | (status, output) = self.target.copy_to(self.localarchive, self.targetdir) | ||
45 | if status != 0: | ||
46 | raise Exception("Failed to copy archive to target, output: %s" % output) | ||
47 | |||
48 | (status, output) = self.target.run('tar xf %s%s -C %s' % (self.targetdir, self.archive, self.targetdir)) | ||
49 | if status != 0: | ||
50 | raise Exception("Failed to extract archive, output: %s" % output) | ||
51 | |||
52 | #Change targetdir to project folder | ||
53 | self.targetdir = self.targetdir + self.fname | ||
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): | ||
58 | return self.target.run('cd %s; ./configure' % self.targetdir, 0)[0] | ||
59 | |||
60 | def run_make(self): | ||
61 | return self.target.run('cd %s; make' % self.targetdir, 0)[0] | ||
62 | |||
63 | def run_install(self): | ||
64 | return self.target.run('cd %s; make install' % self.targetdir, 0)[0] | ||
65 | |||
66 | def clean(self): | ||
67 | self.target.run('rm -rf %s' % self.targetdir) | ||
68 | subprocess.call('rm -f %s' % self.localarchive, shell=True) | ||