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/gitsm.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/gitsm.py')
-rw-r--r-- | bitbake/lib/bb/fetch2/gitsm.py | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/bitbake/lib/bb/fetch2/gitsm.py b/bitbake/lib/bb/fetch2/gitsm.py index 752f1d3c15..6613762048 100644 --- a/bitbake/lib/bb/fetch2/gitsm.py +++ b/bitbake/lib/bb/fetch2/gitsm.py | |||
@@ -43,10 +43,10 @@ class GitSM(Git): | |||
43 | """ | 43 | """ |
44 | return ud.type in ['gitsm'] | 44 | return ud.type in ['gitsm'] |
45 | 45 | ||
46 | def uses_submodules(self, ud, d): | 46 | def uses_submodules(self, ud, d, wd): |
47 | for name in ud.names: | 47 | for name in ud.names: |
48 | try: | 48 | try: |
49 | runfetchcmd("%s show %s:.gitmodules" % (ud.basecmd, ud.revisions[name]), d, quiet=True) | 49 | runfetchcmd("%s show %s:.gitmodules" % (ud.basecmd, ud.revisions[name]), d, quiet=True, workdir=wd) |
50 | return True | 50 | return True |
51 | except bb.fetch.FetchError: | 51 | except bb.fetch.FetchError: |
52 | pass | 52 | pass |
@@ -107,28 +107,25 @@ class GitSM(Git): | |||
107 | os.mkdir(tmpclonedir) | 107 | os.mkdir(tmpclonedir) |
108 | os.rename(ud.clonedir, gitdir) | 108 | os.rename(ud.clonedir, gitdir) |
109 | runfetchcmd("sed " + gitdir + "/config -i -e 's/bare.*=.*true/bare = false/'", d) | 109 | runfetchcmd("sed " + gitdir + "/config -i -e 's/bare.*=.*true/bare = false/'", d) |
110 | os.chdir(tmpclonedir) | 110 | runfetchcmd(ud.basecmd + " reset --hard", d, workdir=tmpclonedir) |
111 | runfetchcmd(ud.basecmd + " reset --hard", d) | 111 | runfetchcmd(ud.basecmd + " checkout " + ud.revisions[ud.names[0]], d, workdir=tmpclonedir) |
112 | runfetchcmd(ud.basecmd + " checkout " + ud.revisions[ud.names[0]], d) | 112 | runfetchcmd(ud.basecmd + " submodule update --init --recursive", d, workdir=tmpclonedir) |
113 | runfetchcmd(ud.basecmd + " submodule update --init --recursive", d) | ||
114 | self._set_relative_paths(tmpclonedir) | 113 | self._set_relative_paths(tmpclonedir) |
115 | runfetchcmd("sed " + gitdir + "/config -i -e 's/bare.*=.*false/bare = true/'", d) | 114 | runfetchcmd("sed " + gitdir + "/config -i -e 's/bare.*=.*false/bare = true/'", d, workdir=tmpclonedir) |
116 | os.rename(gitdir, ud.clonedir,) | 115 | os.rename(gitdir, ud.clonedir,) |
117 | bb.utils.remove(tmpclonedir, True) | 116 | bb.utils.remove(tmpclonedir, True) |
118 | 117 | ||
119 | def download(self, ud, d): | 118 | def download(self, ud, d): |
120 | Git.download(self, ud, d) | 119 | Git.download(self, ud, d) |
121 | 120 | ||
122 | os.chdir(ud.clonedir) | 121 | submodules = self.uses_submodules(ud, d, ud.clonedir) |
123 | submodules = self.uses_submodules(ud, d) | ||
124 | if submodules: | 122 | if submodules: |
125 | self.update_submodules(ud, d) | 123 | self.update_submodules(ud, d) |
126 | 124 | ||
127 | def unpack(self, ud, destdir, d): | 125 | def unpack(self, ud, destdir, d): |
128 | Git.unpack(self, ud, destdir, d) | 126 | Git.unpack(self, ud, destdir, d) |
129 | 127 | ||
130 | os.chdir(ud.destdir) | 128 | submodules = self.uses_submodules(ud, d, ud.destdir) |
131 | submodules = self.uses_submodules(ud, d) | ||
132 | if submodules: | 129 | if submodules: |
133 | runfetchcmd(ud.basecmd + " checkout " + ud.revisions[ud.names[0]], d) | 130 | runfetchcmd(ud.basecmd + " checkout " + ud.revisions[ud.names[0]], d, workdir=ud.destdir) |
134 | runfetchcmd(ud.basecmd + " submodule update --init --recursive", d) | 131 | runfetchcmd(ud.basecmd + " submodule update --init --recursive", d, workdir=ud.destdir) |