summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/npm.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/npm.py
parenteefb4b66c8628fbf366ebc5c23cfe013c8fa3756 (diff)
downloadpoky-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/npm.py')
-rw-r--r--bitbake/lib/bb/fetch2/npm.py22
1 files changed, 7 insertions, 15 deletions
diff --git a/bitbake/lib/bb/fetch2/npm.py b/bitbake/lib/bb/fetch2/npm.py
index 2fd43034ba..b26ac22eff 100644
--- a/bitbake/lib/bb/fetch2/npm.py
+++ b/bitbake/lib/bb/fetch2/npm.py
@@ -113,16 +113,13 @@ class Npm(FetchMethod):
113 bb.fatal("NPM package %s downloaded not a tarball!" % file) 113 bb.fatal("NPM package %s downloaded not a tarball!" % file)
114 114
115 # Change to subdir before executing command 115 # Change to subdir before executing command
116 save_cwd = os.getcwd()
117 if not os.path.exists(destdir): 116 if not os.path.exists(destdir):
118 os.makedirs(destdir) 117 os.makedirs(destdir)
119 os.chdir(destdir)
120 path = d.getVar('PATH', True) 118 path = d.getVar('PATH', True)
121 if path: 119 if path:
122 cmd = "PATH=\"%s\" %s" % (path, cmd) 120 cmd = "PATH=\"%s\" %s" % (path, cmd)
123 bb.note("Unpacking %s to %s/" % (file, os.getcwd())) 121 bb.note("Unpacking %s to %s/" % (file, destdir))
124 ret = subprocess.call(cmd, preexec_fn=subprocess_setup, shell=True) 122 ret = subprocess.call(cmd, preexec_fn=subprocess_setup, shell=True, cwd=destdir)
125 os.chdir(save_cwd)
126 123
127 if ret != 0: 124 if ret != 0:
128 raise UnpackError("Unpack command %s failed with return value %s" % (cmd, ret), ud.url) 125 raise UnpackError("Unpack command %s failed with return value %s" % (cmd, ret), ud.url)
@@ -239,10 +236,7 @@ class Npm(FetchMethod):
239 if not os.listdir(ud.pkgdatadir) and os.path.exists(ud.fullmirror): 236 if not os.listdir(ud.pkgdatadir) and os.path.exists(ud.fullmirror):
240 dest = d.getVar("DL_DIR", True) 237 dest = d.getVar("DL_DIR", True)
241 bb.utils.mkdirhier(dest) 238 bb.utils.mkdirhier(dest)
242 save_cwd = os.getcwd() 239 runfetchcmd("tar -xJf %s" % (ud.fullmirror), d, workdir=dest)
243 os.chdir(dest)
244 runfetchcmd("tar -xJf %s" % (ud.fullmirror), d)
245 os.chdir(save_cwd)
246 return 240 return
247 241
248 shwrf = d.getVar('NPM_SHRINKWRAP', True) 242 shwrf = d.getVar('NPM_SHRINKWRAP', True)
@@ -275,10 +269,8 @@ class Npm(FetchMethod):
275 if os.path.islink(ud.fullmirror): 269 if os.path.islink(ud.fullmirror):
276 os.unlink(ud.fullmirror) 270 os.unlink(ud.fullmirror)
277 271
278 save_cwd = os.getcwd() 272 dldir = d.getVar("DL_DIR", True)
279 os.chdir(d.getVar("DL_DIR", True))
280 logger.info("Creating tarball of npm data") 273 logger.info("Creating tarball of npm data")
281 runfetchcmd("tar -cJf %s npm/%s npm/%s" % (ud.fullmirror, ud.bbnpmmanifest, ud.pkgname), d) 274 runfetchcmd("tar -cJf %s npm/%s npm/%s" % (ud.fullmirror, ud.bbnpmmanifest, ud.pkgname), d,
282 runfetchcmd("touch %s.done" % (ud.fullmirror), d) 275 workdir=dldir)
283 os.chdir(save_cwd) 276 runfetchcmd("touch %s.done" % (ud.fullmirror), d, workdir=dldir)
284