aboutsummaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/__init__.py
diff options
context:
space:
mode:
authorMatt Madison <matt@madison.systems>2016-08-10 10:08:16 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-08-20 16:08:59 +0100
commitab09541d5517da9b1a23923ea8f5c26ddf745084 (patch)
treeb0b81a809ec783b7481c012b430b9f6618e87a73 /bitbake/lib/bb/fetch2/__init__.py
parenteefb4b66c8628fbf366ebc5c23cfe013c8fa3756 (diff)
downloadopenembedded-core-contrib-ab09541d5517da9b1a23923ea8f5c26ddf745084.tar.gz
bitbake: fetch2: preserve current working directory
Fix the methods in all fetchers so they don't change the current working directory of the calling process, which could lead to "changed cwd" warnings from bitbake. (Bitbake rev: 6aa78bf3bd1f75728209e2d01faef31cb8887333) Signed-off-by: Matt Madison <matt@madison.systems> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2/__init__.py')
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 9054b2ec18..7a3eb3c5ab 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -779,7 +779,7 @@ def localpath(url, d):
fetcher = bb.fetch2.Fetch([url], d)
return fetcher.localpath(url)
-def runfetchcmd(cmd, d, quiet=False, cleanup=None, log=None):
+def runfetchcmd(cmd, d, quiet=False, cleanup=None, log=None, workdir=None):
"""
Run cmd returning the command output
Raise an error if interrupted or cmd fails
@@ -821,7 +821,7 @@ def runfetchcmd(cmd, d, quiet=False, cleanup=None, log=None):
error_message = ""
try:
- (output, errors) = bb.process.run(cmd, log=log, shell=True, stderr=subprocess.PIPE)
+ (output, errors) = bb.process.run(cmd, log=log, shell=True, stderr=subprocess.PIPE, cwd=workdir)
success = True
except bb.process.NotFoundError as e:
error_message = "Fetch command %s" % (e.command)
@@ -1436,17 +1436,11 @@ class FetchMethod(object):
if not cmd:
return
- # Change to unpackdir before executing command
- save_cwd = os.getcwd();
- os.chdir(unpackdir)
-
path = data.getVar('PATH', True)
if path:
cmd = "PATH=\"%s\" %s" % (path, cmd)
- bb.note("Unpacking %s to %s/" % (file, os.getcwd()))
- ret = subprocess.call(cmd, preexec_fn=subprocess_setup, shell=True)
-
- os.chdir(save_cwd)
+ bb.note("Unpacking %s to %s/" % (file, unpackdir))
+ ret = subprocess.call(cmd, preexec_fn=subprocess_setup, shell=True, cwd=unpackdir)
if ret != 0:
raise UnpackError("Unpack command %s failed with return value %s" % (cmd, ret), urldata.url)
@@ -1559,6 +1553,8 @@ class Fetch(object):
network = self.d.getVar("BB_NO_NETWORK", True)
premirroronly = (self.d.getVar("BB_FETCH_PREMIRRORONLY", True) == "1")
+ save_cwd = os.getcwd()
+
for u in urls:
ud = self.ud[u]
ud.setup_localpath(self.d)
@@ -1633,6 +1629,7 @@ class Fetch(object):
raise
finally:
+ os.chdir(save_cwd)
if ud.lockfile:
bb.utils.unlockfile(lf)
@@ -1641,6 +1638,8 @@ class Fetch(object):
Check all urls exist upstream
"""
+ save_cwd = os.getcwd()
+
if not urls:
urls = self.urls
@@ -1664,6 +1663,8 @@ class Fetch(object):
if not ret:
raise FetchError("URL %s doesn't work" % u, u)
+ os.chdir(save_cwd)
+
def unpack(self, root, urls=None):
"""
Check all urls exist upstream