diff options
Diffstat (limited to 'bitbake/lib/bb/fetch/git.py')
-rw-r--r-- | bitbake/lib/bb/fetch/git.py | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/bitbake/lib/bb/fetch/git.py b/bitbake/lib/bb/fetch/git.py index 449f1e4dba..33e9a95baf 100644 --- a/bitbake/lib/bb/fetch/git.py +++ b/bitbake/lib/bb/fetch/git.py | |||
@@ -88,15 +88,21 @@ class Git(Fetch): | |||
88 | def forcefetch(self, url, ud, d): | 88 | def forcefetch(self, url, ud, d): |
89 | if 'fullclone' in ud.parm: | 89 | if 'fullclone' in ud.parm: |
90 | return True | 90 | return True |
91 | if os.path.exists(self.localpath(url, ud, d)): | 91 | if 'noclone' in ud.parm: |
92 | return False | ||
93 | if os.path.exists(ud.localpath): | ||
92 | return False | 94 | return False |
93 | if not self._contains_ref(ud.tag, d): | 95 | if not self._contains_ref(ud.tag, d): |
94 | return True | 96 | return True |
95 | return False | 97 | return False |
96 | 98 | ||
97 | def try_premirror(self, u, ud, d): | 99 | def try_premirror(self, u, ud, d): |
100 | if 'noclone' in ud.parm: | ||
101 | return False | ||
98 | if os.path.exists(ud.clonedir): | 102 | if os.path.exists(ud.clonedir): |
99 | return False | 103 | return False |
104 | if os.path.exists(ud.localpath): | ||
105 | return False | ||
100 | 106 | ||
101 | return True | 107 | return True |
102 | 108 | ||
@@ -113,16 +119,25 @@ class Git(Fetch): | |||
113 | coname = '%s' % (ud.tag) | 119 | coname = '%s' % (ud.tag) |
114 | codir = os.path.join(ud.clonedir, coname) | 120 | codir = os.path.join(ud.clonedir, coname) |
115 | 121 | ||
116 | if not os.path.exists(ud.clonedir): | 122 | # If we have no existing clone and no mirror tarball, try and obtain one |
123 | if not os.path.exists(ud.clonedir) and not os.path.exists(repofile): | ||
117 | try: | 124 | try: |
118 | Fetch.try_mirrors(ud.mirrortarball) | 125 | Fetch.try_mirrors(ud.mirrortarball) |
119 | bb.mkdirhier(ud.clonedir) | ||
120 | os.chdir(ud.clonedir) | ||
121 | runfetchcmd("tar -xzf %s" % (repofile), d) | ||
122 | except: | 126 | except: |
123 | runfetchcmd("%s clone -n %s://%s%s%s %s" % (ud.basecmd, ud.proto, username, ud.host, ud.path, ud.clonedir), d) | 127 | pass |
128 | |||
129 | # If the checkout doesn't exist and the mirror tarball does, extract it | ||
130 | if not os.path.exists(ud.clonedir) and os.path.exists(repofile): | ||
131 | bb.mkdirhier(ud.clonedir) | ||
132 | os.chdir(ud.clonedir) | ||
133 | runfetchcmd("tar -xzf %s" % (repofile), d) | ||
134 | |||
135 | # If the repo still doesn't exist, fallback to cloning it | ||
136 | if not os.path.exists(ud.clonedir): | ||
137 | runfetchcmd("%s clone -n %s://%s%s%s %s" % (ud.basecmd, ud.proto, username, ud.host, ud.path, ud.clonedir), d) | ||
124 | 138 | ||
125 | os.chdir(ud.clonedir) | 139 | os.chdir(ud.clonedir) |
140 | # Update the checkout if needed | ||
126 | if not self._contains_ref(ud.tag, d) or 'fullclone' in ud.parm: | 141 | if not self._contains_ref(ud.tag, d) or 'fullclone' in ud.parm: |
127 | # Remove all but the .git directory | 142 | # Remove all but the .git directory |
128 | runfetchcmd("rm * -Rf", d) | 143 | runfetchcmd("rm * -Rf", d) |
@@ -131,6 +146,7 @@ class Git(Fetch): | |||
131 | runfetchcmd("%s prune-packed" % ud.basecmd, d) | 146 | runfetchcmd("%s prune-packed" % ud.basecmd, d) |
132 | runfetchcmd("%s pack-redundant --all | xargs -r rm" % ud.basecmd, d) | 147 | runfetchcmd("%s pack-redundant --all | xargs -r rm" % ud.basecmd, d) |
133 | 148 | ||
149 | # Generate a mirror tarball if needed | ||
134 | os.chdir(ud.clonedir) | 150 | os.chdir(ud.clonedir) |
135 | mirror_tarballs = data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) | 151 | mirror_tarballs = data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) |
136 | if mirror_tarballs != "0" or 'fullclone' in ud.parm: | 152 | if mirror_tarballs != "0" or 'fullclone' in ud.parm: |