diff options
author | Matt Madison <matt@madison.systems> | 2016-08-10 10:08:16 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-08-20 16:08:59 +0100 |
commit | ab09541d5517da9b1a23923ea8f5c26ddf745084 (patch) | |
tree | b0b81a809ec783b7481c012b430b9f6618e87a73 /bitbake/lib/bb/fetch2/cvs.py | |
parent | eefb4b66c8628fbf366ebc5c23cfe013c8fa3756 (diff) | |
download | poky-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/cvs.py')
-rw-r--r-- | bitbake/lib/bb/fetch2/cvs.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/bitbake/lib/bb/fetch2/cvs.py b/bitbake/lib/bb/fetch2/cvs.py index 43a234f590..5ff70ba921 100644 --- a/bitbake/lib/bb/fetch2/cvs.py +++ b/bitbake/lib/bb/fetch2/cvs.py | |||
@@ -123,22 +123,23 @@ class Cvs(FetchMethod): | |||
123 | pkg = d.getVar('PN', True) | 123 | pkg = d.getVar('PN', True) |
124 | pkgdir = os.path.join(d.getVar('CVSDIR', True), pkg) | 124 | pkgdir = os.path.join(d.getVar('CVSDIR', True), pkg) |
125 | moddir = os.path.join(pkgdir, localdir) | 125 | moddir = os.path.join(pkgdir, localdir) |
126 | workdir = None | ||
126 | if os.access(os.path.join(moddir, 'CVS'), os.R_OK): | 127 | if os.access(os.path.join(moddir, 'CVS'), os.R_OK): |
127 | logger.info("Update " + ud.url) | 128 | logger.info("Update " + ud.url) |
128 | bb.fetch2.check_network_access(d, cvsupdatecmd, ud.url) | 129 | bb.fetch2.check_network_access(d, cvsupdatecmd, ud.url) |
129 | # update sources there | 130 | # update sources there |
130 | os.chdir(moddir) | 131 | workdir = moddir |
131 | cmd = cvsupdatecmd | 132 | cmd = cvsupdatecmd |
132 | else: | 133 | else: |
133 | logger.info("Fetch " + ud.url) | 134 | logger.info("Fetch " + ud.url) |
134 | # check out sources there | 135 | # check out sources there |
135 | bb.utils.mkdirhier(pkgdir) | 136 | bb.utils.mkdirhier(pkgdir) |
136 | os.chdir(pkgdir) | 137 | workdir = pkgdir |
137 | logger.debug(1, "Running %s", cvscmd) | 138 | logger.debug(1, "Running %s", cvscmd) |
138 | bb.fetch2.check_network_access(d, cvscmd, ud.url) | 139 | bb.fetch2.check_network_access(d, cvscmd, ud.url) |
139 | cmd = cvscmd | 140 | cmd = cvscmd |
140 | 141 | ||
141 | runfetchcmd(cmd, d, cleanup = [moddir]) | 142 | runfetchcmd(cmd, d, cleanup=[moddir], workdir=workdir) |
142 | 143 | ||
143 | if not os.access(moddir, os.R_OK): | 144 | if not os.access(moddir, os.R_OK): |
144 | raise FetchError("Directory %s was not readable despite sucessful fetch?!" % moddir, ud.url) | 145 | raise FetchError("Directory %s was not readable despite sucessful fetch?!" % moddir, ud.url) |
@@ -150,15 +151,15 @@ class Cvs(FetchMethod): | |||
150 | tar_flags = "--exclude='CVS'" | 151 | tar_flags = "--exclude='CVS'" |
151 | 152 | ||
152 | # tar them up to a defined filename | 153 | # tar them up to a defined filename |
154 | workdir = None | ||
153 | if 'fullpath' in ud.parm: | 155 | if 'fullpath' in ud.parm: |
154 | os.chdir(pkgdir) | 156 | workdir = pkgdir |
155 | cmd = "tar %s -czf %s %s" % (tar_flags, ud.localpath, localdir) | 157 | cmd = "tar %s -czf %s %s" % (tar_flags, ud.localpath, localdir) |
156 | else: | 158 | else: |
157 | os.chdir(moddir) | 159 | workdir = os.path.dirname(os.path.realpath(moddir)) |
158 | os.chdir('..') | ||
159 | cmd = "tar %s -czf %s %s" % (tar_flags, ud.localpath, os.path.basename(moddir)) | 160 | cmd = "tar %s -czf %s %s" % (tar_flags, ud.localpath, os.path.basename(moddir)) |
160 | 161 | ||
161 | runfetchcmd(cmd, d, cleanup = [ud.localpath]) | 162 | runfetchcmd(cmd, d, cleanup=[ud.localpath], workdir=workdir) |
162 | 163 | ||
163 | def clean(self, ud, d): | 164 | def clean(self, ud, d): |
164 | """ Clean CVS Files and tarballs """ | 165 | """ Clean CVS Files and tarballs """ |