summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2016-11-02 13:42:01 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-23 12:05:19 +0000
commit51be1880631435627e8ff490d71b024c2683244a (patch)
treef3b07ba37b60db968b359ca3cdac2da8e37ffb74 /meta
parent72e9ae377d310282f1c8cc49d4806b26a0b41e79 (diff)
downloadpoky-51be1880631435627e8ff490d71b024c2683244a.tar.gz
oeqa/utils: {Target,SDK,}BuildProject remove dependency of bb
Don't use bitbake references inside utils modules, in order todo that changes getVar calls for arguments in the __init__ method like dl_dir for all the classes and testlogdir, builddatetime in SDKBUildProject. Also don't export proxies inside _download_archive method, a good practice is to setup the proxies at init of the process instead of do it in this helper module. [YOCTO #10231] [YOCTO #10599] (From OE-Core rev: 581c34d1efe9839f50ef322761269b4e4d8a56a6) Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/runtime/utils/targetbuildproject.py6
-rw-r--r--meta/lib/oeqa/sdk/utils/sdkbuildproject.py14
-rw-r--r--meta/lib/oeqa/utils/buildproject.py31
3 files changed, 17 insertions, 34 deletions
diff --git a/meta/lib/oeqa/runtime/utils/targetbuildproject.py b/meta/lib/oeqa/runtime/utils/targetbuildproject.py
index 138b5ef041..006d4d4a7b 100644
--- a/meta/lib/oeqa/runtime/utils/targetbuildproject.py
+++ b/meta/lib/oeqa/runtime/utils/targetbuildproject.py
@@ -5,13 +5,13 @@ from oeqa.utils.buildproject import BuildProject
5 5
6class TargetBuildProject(BuildProject): 6class TargetBuildProject(BuildProject):
7 7
8 def __init__(self, target, d, uri, foldername=None): 8 def __init__(self, target, uri, foldername=None, dl_dir=None):
9 self.target = target 9 self.target = target
10 self.targetdir = "~/" 10 self.targetdir = "~/"
11 BuildProject.__init__(self, d, uri, foldername, tmpdir="/tmp") 11 BuildProject.__init__(self, uri, foldername, tmpdir="/tmp",
12 dl_dir=dl_dir)
12 13
13 def download_archive(self): 14 def download_archive(self):
14
15 self._download_archive() 15 self._download_archive()
16 16
17 (status, output) = self.target.copy_to(self.localarchive, self.targetdir) 17 (status, output) = self.target.copy_to(self.localarchive, self.targetdir)
diff --git a/meta/lib/oeqa/sdk/utils/sdkbuildproject.py b/meta/lib/oeqa/sdk/utils/sdkbuildproject.py
index 1eebd3a5bc..cc34e0c9f5 100644
--- a/meta/lib/oeqa/sdk/utils/sdkbuildproject.py
+++ b/meta/lib/oeqa/sdk/utils/sdkbuildproject.py
@@ -7,17 +7,17 @@ import subprocess
7from oeqa.utils.buildproject import BuildProject 7from oeqa.utils.buildproject import BuildProject
8 8
9class SDKBuildProject(BuildProject): 9class SDKBuildProject(BuildProject):
10 10 def __init__(self, testpath, sdkenv, uri, testlogdir, builddatetime,
11 def __init__(self, testpath, sdkenv, d, uri, foldername=None): 11 foldername=None, dl_dir=None):
12 self.sdkenv = sdkenv 12 self.sdkenv = sdkenv
13 self.testdir = testpath 13 self.testdir = testpath
14 self.targetdir = testpath 14 self.targetdir = testpath
15 bb.utils.mkdirhier(testpath) 15 os.makedirs(testpath, exist_ok=True)
16 self.datetime = d.getVar('DATETIME') 16 self.datetime = builddatetime
17 self.testlogdir = d.getVar("TEST_LOG_DIR") 17 self.testlogdir = testlogdir
18 bb.utils.mkdirhier(self.testlogdir) 18 os.makedirs(self.testlogdir, exist_ok=True)
19 self.logfile = os.path.join(self.testlogdir, "sdk_target_log.%s" % self.datetime) 19 self.logfile = os.path.join(self.testlogdir, "sdk_target_log.%s" % self.datetime)
20 BuildProject.__init__(self, d, uri, foldername, tmpdir=testpath) 20 BuildProject.__init__(self, uri, foldername, tmpdir=testpath, dl_dir=dl_dir)
21 21
22 def download_archive(self): 22 def download_archive(self):
23 23
diff --git a/meta/lib/oeqa/utils/buildproject.py b/meta/lib/oeqa/utils/buildproject.py
index 1ed9624a76..386a927881 100644
--- a/meta/lib/oeqa/utils/buildproject.py
+++ b/meta/lib/oeqa/utils/buildproject.py
@@ -6,17 +6,17 @@
6 6
7import os 7import os
8import re 8import re
9import bb.utils
10import subprocess 9import subprocess
10import shutil
11
11from abc import ABCMeta, abstractmethod 12from abc import ABCMeta, abstractmethod
12 13
13class BuildProject(metaclass=ABCMeta): 14class BuildProject(metaclass=ABCMeta):
14 15 def __init__(self, uri, foldername=None, tmpdir="/tmp/", dl_dir=None):
15 def __init__(self, d, uri, foldername=None, tmpdir="/tmp/"):
16 self.d = d
17 self.uri = uri 16 self.uri = uri
18 self.archive = os.path.basename(uri) 17 self.archive = os.path.basename(uri)
19 self.localarchive = os.path.join(tmpdir,self.archive) 18 self.localarchive = os.path.join(tmpdir,self.archive)
19 self.dl_dir = dl_dir
20 if foldername: 20 if foldername:
21 self.fname = foldername 21 self.fname = foldername
22 else: 22 else:
@@ -24,27 +24,11 @@ class BuildProject(metaclass=ABCMeta):
24 24
25 # Download self.archive to self.localarchive 25 # Download self.archive to self.localarchive
26 def _download_archive(self): 26 def _download_archive(self):
27 27 if self.dl_dir and os.path.exists(os.path.join(self.dl_dir, self.archive)):
28 dl_dir = self.d.getVar("DL_DIR") 28 shutil.copyfile(os.path.join(self.dl_dir, self.archive), self.localarchive)
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 29 return
32 30
33 exportvars = ['HTTP_PROXY', 'http_proxy', 31 cmd = "wget -O %s %s" % (self.localarchive, self.uri)
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) 32 subprocess.check_call(cmd, shell=True)
49 33
50 # This method should provide a way to run a command in the desired environment. 34 # This method should provide a way to run a command in the desired environment.
@@ -66,4 +50,3 @@ class BuildProject(metaclass=ABCMeta):
66 def clean(self): 50 def clean(self):
67 self._run('rm -rf %s' % self.targetdir) 51 self._run('rm -rf %s' % self.targetdir)
68 subprocess.call('rm -f %s' % self.localarchive, shell=True) 52 subprocess.call('rm -f %s' % self.localarchive, shell=True)
69 pass