diff options
| author | Richard Purdie <rpurdie@linux.intel.com> | 2010-01-19 14:48:19 +0000 |
|---|---|---|
| committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-01-19 14:48:19 +0000 |
| commit | 22a271aaa99daeb6b29c42c2c1dc670bf204310e (patch) | |
| tree | d2690b66e7a613820f34ceaecbce65809cbd22a3 /bitbake-dev/lib/bb/fetch/git.py | |
| parent | cefe87fc3c4202e942f34666813bc094df2ffb4b (diff) | |
| download | poky-22a271aaa99daeb6b29c42c2c1dc670bf204310e.tar.gz | |
bitbake-dev: Sync with upstream
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake-dev/lib/bb/fetch/git.py')
| -rw-r--r-- | bitbake-dev/lib/bb/fetch/git.py | 86 |
1 files changed, 60 insertions, 26 deletions
diff --git a/bitbake-dev/lib/bb/fetch/git.py b/bitbake-dev/lib/bb/fetch/git.py index 43053d6c46..0e68325db9 100644 --- a/bitbake-dev/lib/bb/fetch/git.py +++ b/bitbake-dev/lib/bb/fetch/git.py | |||
| @@ -51,6 +51,10 @@ class Git(Fetch): | |||
| 51 | 51 | ||
| 52 | ud.branch = ud.parm.get("branch", "master") | 52 | ud.branch = ud.parm.get("branch", "master") |
| 53 | 53 | ||
| 54 | gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.')) | ||
| 55 | ud.mirrortarball = 'git_%s.tar.gz' % (gitsrcname) | ||
| 56 | ud.clonedir = os.path.join(data.expand('${GITDIR}', d), gitsrcname) | ||
| 57 | |||
| 54 | tag = Fetch.srcrev_internal_helper(ud, d) | 58 | tag = Fetch.srcrev_internal_helper(ud, d) |
| 55 | if tag is True: | 59 | if tag is True: |
| 56 | ud.tag = self.latest_revision(url, ud, d) | 60 | ud.tag = self.latest_revision(url, ud, d) |
| @@ -60,7 +64,18 @@ class Git(Fetch): | |||
| 60 | if not ud.tag or ud.tag == "master": | 64 | if not ud.tag or ud.tag == "master": |
| 61 | ud.tag = self.latest_revision(url, ud, d) | 65 | ud.tag = self.latest_revision(url, ud, d) |
| 62 | 66 | ||
| 63 | ud.localfile = data.expand('git_%s%s_%s.tar.gz' % (ud.host, ud.path.replace('/', '.'), ud.tag), d) | 67 | subdir = ud.parm.get("subpath", "") |
| 68 | if subdir != "": | ||
| 69 | if subdir.endswith("/"): | ||
| 70 | subdir = subdir[:-1] | ||
| 71 | subdirpath = os.path.join(ud.path, subdir); | ||
| 72 | else: | ||
| 73 | subdirpath = ud.path; | ||
| 74 | |||
| 75 | if 'fullclone' in ud.parm: | ||
| 76 | ud.localfile = ud.mirrortarball | ||
| 77 | else: | ||
| 78 | ud.localfile = data.expand('git_%s%s_%s.tar.gz' % (ud.host, subdirpath.replace('/', '.'), ud.tag), d) | ||
| 64 | 79 | ||
| 65 | return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) | 80 | return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) |
| 66 | 81 | ||
| @@ -76,24 +91,20 @@ class Git(Fetch): | |||
| 76 | else: | 91 | else: |
| 77 | username = "" | 92 | username = "" |
| 78 | 93 | ||
| 79 | gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.')) | 94 | repofile = os.path.join(data.getVar("DL_DIR", d, 1), ud.mirrortarball) |
| 80 | |||
| 81 | repofilename = 'git_%s.tar.gz' % (gitsrcname) | ||
| 82 | repofile = os.path.join(data.getVar("DL_DIR", d, 1), repofilename) | ||
| 83 | repodir = os.path.join(data.expand('${GITDIR}', d), gitsrcname) | ||
| 84 | 95 | ||
| 85 | coname = '%s' % (ud.tag) | 96 | coname = '%s' % (ud.tag) |
| 86 | codir = os.path.join(repodir, coname) | 97 | codir = os.path.join(ud.clonedir, coname) |
| 87 | 98 | ||
| 88 | if not os.path.exists(repodir): | 99 | if not os.path.exists(ud.clonedir): |
| 89 | if Fetch.try_mirror(d, repofilename): | 100 | if Fetch.try_mirror(d, ud.mirrortarball): |
| 90 | bb.mkdirhier(repodir) | 101 | bb.mkdirhier(ud.clonedir) |
| 91 | os.chdir(repodir) | 102 | os.chdir(ud.clonedir) |
| 92 | runfetchcmd("tar -xzf %s" % (repofile), d) | 103 | runfetchcmd("tar -xzf %s" % (repofile), d) |
| 93 | else: | 104 | else: |
| 94 | runfetchcmd("git clone -n %s://%s%s%s %s" % (ud.proto, username, ud.host, ud.path, repodir), d) | 105 | runfetchcmd("git clone -n %s://%s%s%s %s" % (ud.proto, username, ud.host, ud.path, ud.clonedir), d) |
| 95 | 106 | ||
| 96 | os.chdir(repodir) | 107 | os.chdir(ud.clonedir) |
| 97 | # Remove all but the .git directory | 108 | # Remove all but the .git directory |
| 98 | if not self._contains_ref(ud.tag, d): | 109 | if not self._contains_ref(ud.tag, d): |
| 99 | runfetchcmd("rm * -Rf", d) | 110 | runfetchcmd("rm * -Rf", d) |
| @@ -102,25 +113,45 @@ class Git(Fetch): | |||
| 102 | runfetchcmd("git prune-packed", d) | 113 | runfetchcmd("git prune-packed", d) |
| 103 | runfetchcmd("git pack-redundant --all | xargs -r rm", d) | 114 | runfetchcmd("git pack-redundant --all | xargs -r rm", d) |
| 104 | 115 | ||
| 105 | os.chdir(repodir) | 116 | os.chdir(ud.clonedir) |
| 106 | mirror_tarballs = data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) | 117 | mirror_tarballs = data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) |
| 107 | if mirror_tarballs != "0": | 118 | if mirror_tarballs != "0" or 'fullclone' in ud.parm: |
| 108 | bb.msg.note(1, bb.msg.domain.Fetcher, "Creating tarball of git repository") | 119 | bb.msg.note(1, bb.msg.domain.Fetcher, "Creating tarball of git repository") |
| 109 | runfetchcmd("tar -czf %s %s" % (repofile, os.path.join(".", ".git", "*") ), d) | 120 | runfetchcmd("tar -czf %s %s" % (repofile, os.path.join(".", ".git", "*") ), d) |
| 110 | 121 | ||
| 122 | if 'fullclone' in ud.parm: | ||
| 123 | return | ||
| 124 | |||
| 111 | if os.path.exists(codir): | 125 | if os.path.exists(codir): |
| 112 | bb.utils.prunedir(codir) | 126 | bb.utils.prunedir(codir) |
| 113 | 127 | ||
| 128 | subdir = ud.parm.get("subpath", "") | ||
| 129 | if subdir != "": | ||
| 130 | if subdir.endswith("/"): | ||
| 131 | subdirbase = os.path.basename(subdir[:-1]) | ||
| 132 | else: | ||
| 133 | subdirbase = os.path.basename(subdir) | ||
| 134 | else: | ||
| 135 | subdirbase = "" | ||
| 136 | |||
| 137 | if subdir != "": | ||
| 138 | readpathspec = ":%s" % (subdir) | ||
| 139 | codir = os.path.join(codir, "git") | ||
| 140 | coprefix = os.path.join(codir, subdirbase, "") | ||
| 141 | else: | ||
| 142 | readpathspec = "" | ||
| 143 | coprefix = os.path.join(codir, "git", "") | ||
| 144 | |||
| 114 | bb.mkdirhier(codir) | 145 | bb.mkdirhier(codir) |
| 115 | os.chdir(repodir) | 146 | os.chdir(ud.clonedir) |
| 116 | runfetchcmd("git read-tree %s" % (ud.tag), d) | 147 | runfetchcmd("git read-tree %s%s" % (ud.tag, readpathspec), d) |
| 117 | runfetchcmd("git checkout-index -q -f --prefix=%s -a" % (os.path.join(codir, "git", "")), d) | 148 | runfetchcmd("git checkout-index -q -f --prefix=%s -a" % (coprefix), d) |
| 118 | 149 | ||
| 119 | os.chdir(codir) | 150 | os.chdir(codir) |
| 120 | bb.msg.note(1, bb.msg.domain.Fetcher, "Creating tarball of git checkout") | 151 | bb.msg.note(1, bb.msg.domain.Fetcher, "Creating tarball of git checkout") |
| 121 | runfetchcmd("tar -czf %s %s" % (ud.localpath, os.path.join(".", "*") ), d) | 152 | runfetchcmd("tar -czf %s %s" % (ud.localpath, os.path.join(".", "*") ), d) |
| 122 | 153 | ||
| 123 | os.chdir(repodir) | 154 | os.chdir(ud.clonedir) |
| 124 | bb.utils.prunedir(codir) | 155 | bb.utils.prunedir(codir) |
| 125 | 156 | ||
| 126 | def suppports_srcrev(self): | 157 | def suppports_srcrev(self): |
| @@ -145,7 +176,10 @@ class Git(Fetch): | |||
| 145 | else: | 176 | else: |
| 146 | username = "" | 177 | username = "" |
| 147 | 178 | ||
| 148 | output = runfetchcmd("git ls-remote %s://%s%s%s %s" % (ud.proto, username, ud.host, ud.path, ud.branch), d, True) | 179 | cmd = "git ls-remote %s://%s%s%s %s" % (ud.proto, username, ud.host, ud.path, ud.branch) |
| 180 | output = runfetchcmd(cmd, d, True) | ||
| 181 | if not output: | ||
| 182 | raise bb.fetch.FetchError("Fetch command %s gave empty output\n" % (cmd)) | ||
| 149 | return output.split()[0] | 183 | return output.split()[0] |
| 150 | 184 | ||
| 151 | def _build_revision(self, url, ud, d): | 185 | def _build_revision(self, url, ud, d): |
| @@ -156,20 +190,20 @@ class Git(Fetch): | |||
| 156 | Return a suitable buildindex for the revision specified. This is done by counting revisions | 190 | Return a suitable buildindex for the revision specified. This is done by counting revisions |
| 157 | using "git rev-list" which may or may not work in different circumstances. | 191 | using "git rev-list" which may or may not work in different circumstances. |
| 158 | """ | 192 | """ |
| 159 | gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.')) | ||
| 160 | repodir = os.path.join(data.expand('${GITDIR}', d), gitsrcname) | ||
| 161 | 193 | ||
| 162 | cwd = os.getcwd() | 194 | cwd = os.getcwd() |
| 163 | 195 | ||
| 164 | # Check if we have the rev already | 196 | # Check if we have the rev already |
| 165 | if not os.path.exists(repodir): | 197 | |
| 198 | if not os.path.exists(ud.clonedir): | ||
| 199 | print "no repo" | ||
| 166 | self.go(None, ud, d) | 200 | self.go(None, ud, d) |
| 167 | if not os.path.exists(repodir): | 201 | if not os.path.exists(ud.clonedir): |
| 168 | bb.msg.error(bb.msg.domain.Fetcher, "GIT repository for %s doesn't exist in %s, cannot get sortable buildnumber, using old value" % (url, repodir)) | 202 | bb.msg.error(bb.msg.domain.Fetcher, "GIT repository for %s doesn't exist in %s, cannot get sortable buildnumber, using old value" % (url, ud.clonedir)) |
| 169 | return None | 203 | return None |
| 170 | 204 | ||
| 171 | 205 | ||
| 172 | os.chdir(repodir) | 206 | os.chdir(ud.clonedir) |
| 173 | if not self._contains_ref(rev, d): | 207 | if not self._contains_ref(rev, d): |
| 174 | self.go(None, ud, d) | 208 | self.go(None, ud, d) |
| 175 | 209 | ||
