diff options
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r-- | bitbake/lib/bb/fetch2/git.py | 63 |
1 files changed, 5 insertions, 58 deletions
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py index 6e078a1f7f..07af02f061 100644 --- a/bitbake/lib/bb/fetch2/git.py +++ b/bitbake/lib/bb/fetch2/git.py | |||
@@ -70,18 +70,7 @@ class Git(Fetch): | |||
70 | if not ud.tag or ud.tag == "master": | 70 | if not ud.tag or ud.tag == "master": |
71 | ud.tag = self.latest_revision(url, ud, d) | 71 | ud.tag = self.latest_revision(url, ud, d) |
72 | 72 | ||
73 | subdir = ud.parm.get("subpath", "") | 73 | ud.localfile = ud.mirrortarball |
74 | if subdir != "": | ||
75 | if subdir.endswith("/"): | ||
76 | subdir = subdir[:-1] | ||
77 | subdirpath = os.path.join(ud.path, subdir); | ||
78 | else: | ||
79 | subdirpath = ud.path; | ||
80 | |||
81 | if 'fullclone' in ud.parm: | ||
82 | ud.localfile = ud.mirrortarball | ||
83 | else: | ||
84 | ud.localfile = data.expand('git_%s%s_%s.tar.gz' % (ud.host, subdirpath.replace('/', '.'), ud.tag), d) | ||
85 | 74 | ||
86 | if 'noclone' in ud.parm: | 75 | if 'noclone' in ud.parm: |
87 | ud.localfile = None | 76 | ud.localfile = None |
@@ -94,8 +83,6 @@ class Git(Fetch): | |||
94 | return True | 83 | return True |
95 | if 'noclone' in ud.parm: | 84 | if 'noclone' in ud.parm: |
96 | return False | 85 | return False |
97 | if os.path.exists(ud.localpath): | ||
98 | return False | ||
99 | if not self._contains_ref(ud.tag, d): | 86 | if not self._contains_ref(ud.tag, d): |
100 | return True | 87 | return True |
101 | return False | 88 | return False |
@@ -120,6 +107,8 @@ class Git(Fetch): | |||
120 | 107 | ||
121 | repofile = os.path.join(data.getVar("DL_DIR", d, 1), ud.mirrortarball) | 108 | repofile = os.path.join(data.getVar("DL_DIR", d, 1), ud.mirrortarball) |
122 | 109 | ||
110 | ud.repochanged = not os.path.exists(repofile) | ||
111 | |||
123 | # If the checkout doesn't exist and the mirror tarball does, extract it | 112 | # If the checkout doesn't exist and the mirror tarball does, extract it |
124 | if not os.path.exists(ud.clonedir) and os.path.exists(repofile): | 113 | if not os.path.exists(ud.clonedir) and os.path.exists(repofile): |
125 | bb.mkdirhier(ud.clonedir) | 114 | bb.mkdirhier(ud.clonedir) |
@@ -144,60 +133,18 @@ class Git(Fetch): | |||
144 | runfetchcmd("%s fetch --tags %s://%s%s%s" % (ud.basecmd, ud.proto, username, ud.host, ud.path), d) | 133 | runfetchcmd("%s fetch --tags %s://%s%s%s" % (ud.basecmd, ud.proto, username, ud.host, ud.path), d) |
145 | runfetchcmd("%s prune-packed" % ud.basecmd, d) | 134 | runfetchcmd("%s prune-packed" % ud.basecmd, d) |
146 | runfetchcmd("%s pack-redundant --all | xargs -r rm" % ud.basecmd, d) | 135 | runfetchcmd("%s pack-redundant --all | xargs -r rm" % ud.basecmd, d) |
136 | ud.repochanged = True | ||
147 | 137 | ||
148 | def build_mirror_data(self, url, ud, d): | 138 | def build_mirror_data(self, url, ud, d): |
149 | # Generate a mirror tarball if needed | 139 | # Generate a mirror tarball if needed |
150 | coname = '%s' % (ud.tag) | ||
151 | codir = os.path.join(ud.clonedir, coname) | ||
152 | repofile = os.path.join(data.getVar("DL_DIR", d, 1), ud.mirrortarball) | 140 | repofile = os.path.join(data.getVar("DL_DIR", d, 1), ud.mirrortarball) |
153 | 141 | ||
154 | os.chdir(ud.clonedir) | 142 | os.chdir(ud.clonedir) |
155 | mirror_tarballs = data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) | 143 | mirror_tarballs = data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) |
156 | if mirror_tarballs != "0" or 'fullclone' in ud.parm: | 144 | if (mirror_tarballs != "0" or 'fullclone' in ud.parm) and ud.repochanged: |
157 | logger.info("Creating tarball of git repository") | 145 | logger.info("Creating tarball of git repository") |
158 | runfetchcmd("tar -czf %s %s" % (repofile, os.path.join(".", ".git", "*") ), d) | 146 | runfetchcmd("tar -czf %s %s" % (repofile, os.path.join(".", ".git", "*") ), d) |
159 | 147 | ||
160 | if 'fullclone' in ud.parm: | ||
161 | return | ||
162 | |||
163 | if os.path.exists(codir): | ||
164 | bb.utils.prunedir(codir) | ||
165 | |||
166 | subdir = ud.parm.get("subpath", "") | ||
167 | if subdir != "": | ||
168 | if subdir.endswith("/"): | ||
169 | subdirbase = os.path.basename(subdir[:-1]) | ||
170 | else: | ||
171 | subdirbase = os.path.basename(subdir) | ||
172 | else: | ||
173 | subdirbase = "" | ||
174 | |||
175 | if subdir != "": | ||
176 | readpathspec = ":%s" % (subdir) | ||
177 | codir = os.path.join(codir, "git") | ||
178 | coprefix = os.path.join(codir, subdirbase, "") | ||
179 | else: | ||
180 | readpathspec = "" | ||
181 | coprefix = os.path.join(codir, "git", "") | ||
182 | |||
183 | scmdata = ud.parm.get("scmdata", "") | ||
184 | if scmdata == "keep": | ||
185 | runfetchcmd("%s clone -n %s %s" % (ud.basecmd, ud.clonedir, coprefix), d) | ||
186 | os.chdir(coprefix) | ||
187 | runfetchcmd("%s checkout -q -f %s%s" % (ud.basecmd, ud.tag, readpathspec), d) | ||
188 | else: | ||
189 | bb.mkdirhier(codir) | ||
190 | os.chdir(ud.clonedir) | ||
191 | runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.tag, readpathspec), d) | ||
192 | runfetchcmd("%s checkout-index -q -f --prefix=%s -a" % (ud.basecmd, coprefix), d) | ||
193 | |||
194 | os.chdir(codir) | ||
195 | logger.info("Creating tarball of git checkout") | ||
196 | runfetchcmd("tar -czf %s %s" % (ud.localpath, os.path.join(".", "*") ), d) | ||
197 | |||
198 | os.chdir(ud.clonedir) | ||
199 | bb.utils.prunedir(codir) | ||
200 | |||
201 | def unpack(self, ud, destdir, d): | 148 | def unpack(self, ud, destdir, d): |
202 | """ unpack the downloaded src to destdir""" | 149 | """ unpack the downloaded src to destdir""" |
203 | 150 | ||