diff options
author | Tom Rini <tom_rini@mentor.com> | 2010-02-24 07:19:24 -0700 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-03-22 14:58:15 +0000 |
commit | dea828c7445f97f3d8c856f12c945ca267713bcd (patch) | |
tree | 6d24c242ee3db66ae68dbfd225eb4cdc09a69da5 /bitbake/lib/bb/fetch | |
parent | d8b12d4eea4d03c2d8870be1a4abd9c8eaeb5b3d (diff) | |
download | poky-dea828c7445f97f3d8c856f12c945ca267713bcd.tar.gz |
Add initial 'repo' fetcher
(Bitbake rev: f68406e864c9837feb56cbec993b620481445cc2)
Signed-off-by: Tom Rini <tom_rini@mentor.com>
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb/fetch')
-rw-r--r-- | bitbake/lib/bb/fetch/__init__.py | 2 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch/repo.py | 106 |
2 files changed, 108 insertions, 0 deletions
diff --git a/bitbake/lib/bb/fetch/__init__.py b/bitbake/lib/bb/fetch/__init__.py index f40d7be334..435c02683c 100644 --- a/bitbake/lib/bb/fetch/__init__.py +++ b/bitbake/lib/bb/fetch/__init__.py | |||
@@ -766,6 +766,7 @@ import perforce | |||
766 | import bzr | 766 | import bzr |
767 | import hg | 767 | import hg |
768 | import osc | 768 | import osc |
769 | import repo | ||
769 | 770 | ||
770 | methods.append(local.Local()) | 771 | methods.append(local.Local()) |
771 | methods.append(wget.Wget()) | 772 | methods.append(wget.Wget()) |
@@ -778,3 +779,4 @@ methods.append(perforce.Perforce()) | |||
778 | methods.append(bzr.Bzr()) | 779 | methods.append(bzr.Bzr()) |
779 | methods.append(hg.Hg()) | 780 | methods.append(hg.Hg()) |
780 | methods.append(osc.Osc()) | 781 | methods.append(osc.Osc()) |
782 | methods.append(repo.Repo()) | ||
diff --git a/bitbake/lib/bb/fetch/repo.py b/bitbake/lib/bb/fetch/repo.py new file mode 100644 index 0000000000..34c32fe0bb --- /dev/null +++ b/bitbake/lib/bb/fetch/repo.py | |||
@@ -0,0 +1,106 @@ | |||
1 | # ex:ts=4:sw=4:sts=4:et | ||
2 | # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- | ||
3 | """ | ||
4 | BitBake "Fetch" repo (git) implementation | ||
5 | |||
6 | """ | ||
7 | |||
8 | # Copyright (C) 2009 Tom Rini <trini@embeddedalley.com> | ||
9 | # | ||
10 | # Based on git.py which is: | ||
11 | #Copyright (C) 2005 Richard Purdie | ||
12 | # | ||
13 | # This program is free software; you can redistribute it and/or modify | ||
14 | # it under the terms of the GNU General Public License version 2 as | ||
15 | # published by the Free Software Foundation. | ||
16 | # | ||
17 | # This program is distributed in the hope that it will be useful, | ||
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | # GNU General Public License for more details. | ||
21 | # | ||
22 | # You should have received a copy of the GNU General Public License along | ||
23 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
24 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
25 | |||
26 | import os, re | ||
27 | import bb | ||
28 | from bb import data | ||
29 | from bb.fetch import Fetch | ||
30 | from bb.fetch import FetchError | ||
31 | from bb.fetch import runfetchcmd | ||
32 | |||
33 | class Repo(Fetch): | ||
34 | """Class to fetch a module or modules from repo (git) repositories""" | ||
35 | def supports(self, url, ud, d): | ||
36 | """ | ||
37 | Check to see if a given url can be fetched with repo. | ||
38 | """ | ||
39 | return ud.type in ["repo"] | ||
40 | |||
41 | def localpath(self, url, ud, d): | ||
42 | """ | ||
43 | We don"t care about the git rev of the manifests repository, but | ||
44 | we do care about the manifest to use. The default is "default". | ||
45 | We also care about the branch or tag to be used. The default is | ||
46 | "master". | ||
47 | """ | ||
48 | |||
49 | if "protocol" in ud.parm: | ||
50 | ud.proto = ud.parm["protocol"] | ||
51 | else: | ||
52 | ud.proto = "git" | ||
53 | |||
54 | if "branch" in ud.parm: | ||
55 | ud.branch = ud.parm["branch"] | ||
56 | else: | ||
57 | ud.branch = "master" | ||
58 | |||
59 | if "manifest" in ud.parm: | ||
60 | manifest = ud.parm["manifest"] | ||
61 | if manifest.endswith(".xml"): | ||
62 | ud.manifest = manifest | ||
63 | else: | ||
64 | ud.manifest = manifest + ".xml" | ||
65 | else: | ||
66 | ud.manifest = "default.xml" | ||
67 | |||
68 | ud.localfile = data.expand("repo_%s%s_%s_%s.tar.gz" % (ud.host, ud.path.replace("/", "."), ud.manifest, ud.branch), d) | ||
69 | |||
70 | return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) | ||
71 | |||
72 | def go(self, loc, ud, d): | ||
73 | """Fetch url""" | ||
74 | |||
75 | if os.access(os.path.join(data.getVar("DL_DIR", d, True), ud.localfile), os.R_OK): | ||
76 | bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists (or was stashed). Skipping repo init / sync." % ud.localpath) | ||
77 | return | ||
78 | |||
79 | gitsrcname = "%s%s" % (ud.host, ud.path.replace("/", ".")) | ||
80 | repodir = data.getVar("REPODIR", d, True) or os.path.join(data.getVar("DL_DIR", d, True), "repo") | ||
81 | codir = os.path.join(repodir, gitsrcname, ud.manifest) | ||
82 | |||
83 | if ud.user: | ||
84 | username = ud.user + "@" | ||
85 | else: | ||
86 | username = "" | ||
87 | |||
88 | bb.mkdirhier(os.path.join(codir, "repo")) | ||
89 | os.chdir(os.path.join(codir, "repo")) | ||
90 | if not os.path.exists(os.path.join(codir, "repo", ".repo")): | ||
91 | runfetchcmd("repo init -m %s -b %s -u %s://%s%s%s" % (ud.manifest, ud.branch, ud.proto, username, ud.host, ud.path), d) | ||
92 | |||
93 | runfetchcmd("repo sync", d) | ||
94 | os.chdir(codir) | ||
95 | |||
96 | # Create a cache | ||
97 | runfetchcmd("tar --exclude=.repo --exclude=.git -czf %s %s" % (ud.localpath, os.path.join(".", "*") ), d) | ||
98 | |||
99 | def suppports_srcrev(self): | ||
100 | return False | ||
101 | |||
102 | def _build_revision(self, url, ud, d): | ||
103 | return ud.manifest | ||
104 | |||
105 | def _want_sortable_revision(self, url, ud, d): | ||
106 | return False | ||