diff options
author | Tudor Florea <tudor.florea@enea.com> | 2014-10-16 03:05:19 +0200 |
---|---|---|
committer | Tudor Florea <tudor.florea@enea.com> | 2014-10-16 03:05:19 +0200 |
commit | c527fd1f14c27855a37f2e8ac5346ce8d940ced2 (patch) | |
tree | bb002c1fdf011c41dbd2f0927bed23ecb5f83c97 /bitbake/lib/bb/fetch2/repo.py | |
download | poky-daisy-140929.tar.gz |
initial commit for Enea Linux 4.0-140929daisy-140929
Migrated from the internal git server on the daisy-enea-point-release branch
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'bitbake/lib/bb/fetch2/repo.py')
-rw-r--r-- | bitbake/lib/bb/fetch2/repo.py | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/bitbake/lib/bb/fetch2/repo.py b/bitbake/lib/bb/fetch2/repo.py new file mode 100644 index 0000000000..21678eb7d9 --- /dev/null +++ b/bitbake/lib/bb/fetch2/repo.py | |||
@@ -0,0 +1,98 @@ | |||
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 | ||
27 | import bb | ||
28 | from bb import data | ||
29 | from bb.fetch2 import FetchMethod | ||
30 | from bb.fetch2 import runfetchcmd | ||
31 | |||
32 | class Repo(FetchMethod): | ||
33 | """Class to fetch a module or modules from repo (git) repositories""" | ||
34 | def supports(self, ud, d): | ||
35 | """ | ||
36 | Check to see if a given url can be fetched with repo. | ||
37 | """ | ||
38 | return ud.type in ["repo"] | ||
39 | |||
40 | def urldata_init(self, ud, d): | ||
41 | """ | ||
42 | We don"t care about the git rev of the manifests repository, but | ||
43 | we do care about the manifest to use. The default is "default". | ||
44 | We also care about the branch or tag to be used. The default is | ||
45 | "master". | ||
46 | """ | ||
47 | |||
48 | ud.proto = ud.parm.get('protocol', 'git') | ||
49 | ud.branch = ud.parm.get('branch', 'master') | ||
50 | ud.manifest = ud.parm.get('manifest', 'default.xml') | ||
51 | if not ud.manifest.endswith('.xml'): | ||
52 | ud.manifest += '.xml' | ||
53 | |||
54 | ud.localfile = data.expand("repo_%s%s_%s_%s.tar.gz" % (ud.host, ud.path.replace("/", "."), ud.manifest, ud.branch), d) | ||
55 | |||
56 | def download(self, ud, d): | ||
57 | """Fetch url""" | ||
58 | |||
59 | if os.access(os.path.join(data.getVar("DL_DIR", d, True), ud.localfile), os.R_OK): | ||
60 | logger.debug(1, "%s already exists (or was stashed). Skipping repo init / sync.", ud.localpath) | ||
61 | return | ||
62 | |||
63 | gitsrcname = "%s%s" % (ud.host, ud.path.replace("/", ".")) | ||
64 | repodir = data.getVar("REPODIR", d, True) or os.path.join(data.getVar("DL_DIR", d, True), "repo") | ||
65 | codir = os.path.join(repodir, gitsrcname, ud.manifest) | ||
66 | |||
67 | if ud.user: | ||
68 | username = ud.user + "@" | ||
69 | else: | ||
70 | username = "" | ||
71 | |||
72 | bb.utils.mkdirhier(os.path.join(codir, "repo")) | ||
73 | os.chdir(os.path.join(codir, "repo")) | ||
74 | if not os.path.exists(os.path.join(codir, "repo", ".repo")): | ||
75 | bb.fetch2.check_network_access(d, "repo init -m %s -b %s -u %s://%s%s%s" % (ud.manifest, ud.branch, ud.proto, username, ud.host, ud.path), ud.url) | ||
76 | runfetchcmd("repo init -m %s -b %s -u %s://%s%s%s" % (ud.manifest, ud.branch, ud.proto, username, ud.host, ud.path), d) | ||
77 | |||
78 | bb.fetch2.check_network_access(d, "repo sync %s" % ud.url, ud.url) | ||
79 | runfetchcmd("repo sync", d) | ||
80 | os.chdir(codir) | ||
81 | |||
82 | scmdata = ud.parm.get("scmdata", "") | ||
83 | if scmdata == "keep": | ||
84 | tar_flags = "" | ||
85 | else: | ||
86 | tar_flags = "--exclude '.repo' --exclude '.git'" | ||
87 | |||
88 | # Create a cache | ||
89 | runfetchcmd("tar %s -czf %s %s" % (tar_flags, ud.localpath, os.path.join(".", "*") ), d) | ||
90 | |||
91 | def supports_srcrev(self): | ||
92 | return False | ||
93 | |||
94 | def _build_revision(self, ud, d): | ||
95 | return ud.manifest | ||
96 | |||
97 | def _want_sortable_revision(self, ud, d): | ||
98 | return False | ||