summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch
diff options
context:
space:
mode:
authorRichard Purdie <richard@openedhand.com>2006-03-20 17:45:11 +0000
committerRichard Purdie <richard@openedhand.com>2006-03-20 17:45:11 +0000
commitb26a945734ce271aa7d443ff9e96fe2851b21138 (patch)
treef540b8d58a7411cf0cabe5c8f4ad40f9f597352a /bitbake/lib/bb/fetch
parent3cd47ad235d54a9c539ae6fe4a5a2b4b5f7e5621 (diff)
downloadpoky-b26a945734ce271aa7d443ff9e96fe2851b21138.tar.gz
Update to latest bitbake
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@309 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'bitbake/lib/bb/fetch')
-rw-r--r--bitbake/lib/bb/fetch/__init__.py35
-rw-r--r--bitbake/lib/bb/fetch/bk.py40
-rw-r--r--bitbake/lib/bb/fetch/cvs.py20
-rw-r--r--bitbake/lib/bb/fetch/git.py95
-rw-r--r--bitbake/lib/bb/fetch/svn.py27
5 files changed, 83 insertions, 134 deletions
diff --git a/bitbake/lib/bb/fetch/__init__.py b/bitbake/lib/bb/fetch/__init__.py
index da5b10c4b6..0515f2a5e9 100644
--- a/bitbake/lib/bb/fetch/__init__.py
+++ b/bitbake/lib/bb/fetch/__init__.py
@@ -158,18 +158,47 @@ class Fetch(object):
158 return data.getVar("SRCDATE", d, 1) or data.getVar("CVSDATE", d, 1) or data.getVar("DATE", d, 1 ) 158 return data.getVar("SRCDATE", d, 1) or data.getVar("CVSDATE", d, 1) or data.getVar("DATE", d, 1 )
159 getSRCDate = staticmethod(getSRCDate) 159 getSRCDate = staticmethod(getSRCDate)
160 160
161#if __name__ == "__main__": 161 def try_mirror(d, tarfn):
162 """
163 Try to use a mirrored version of the sources. We do this
164 to avoid massive loads on foreign cvs and svn servers.
165 This method will be used by the different fetcher
166 implementations.
167
168 d Is a bb.data instance
169 tarfn is the name of the tarball
170 """
171 tarpath = os.path.join(data.getVar("DL_DIR", d, 1), tarfn)
172 if os.access(tarpath, os.R_OK):
173 return True
174
175 pn = data.getVar('PN', d, True)
176 src_tarball_stash = None
177 if pn:
178 src_tarball_stash = (data.getVar('SRC_TARBALL_STASH_%s' % pn, d, True) or data.getVar('CVS_TARBALL_STASH_%s' % pn, d, True) or data.getVar('SRC_TARBALL_STASH', d, True) or data.getVar('CVS_TARBALL_STASH', d, True) or "").split()
179
180 for stash in src_tarball_stash:
181 fetchcmd = data.getVar("FETCHCOMMAND_mirror", d, True) or data.getVar("FETCHCOMMAND_wget", d, True)
182 uri = stash + tarfn
183 bb.note("fetch " + uri)
184 fetchcmd = fetchcmd.replace("${URI}", uri)
185 ret = os.system(fetchcmd)
186 if ret == 0:
187 bb.note("Fetched %s from tarball stash, skipping checkout" % tarfn)
188 return True
189 return False
190 try_mirror = staticmethod(try_mirror)
162 191
163import bk
164import cvs 192import cvs
165import git 193import git
166import local 194import local
167import svn 195import svn
168import wget 196import wget
197import svk
169 198
170methods.append(bk.Bk())
171methods.append(cvs.Cvs()) 199methods.append(cvs.Cvs())
172methods.append(git.Git()) 200methods.append(git.Git())
173methods.append(local.Local()) 201methods.append(local.Local())
174methods.append(svn.Svn()) 202methods.append(svn.Svn())
175methods.append(wget.Wget()) 203methods.append(wget.Wget())
204methods.append(svk.Svk())
diff --git a/bitbake/lib/bb/fetch/bk.py b/bitbake/lib/bb/fetch/bk.py
deleted file mode 100644
index 6bd6c018fb..0000000000
--- a/bitbake/lib/bb/fetch/bk.py
+++ /dev/null
@@ -1,40 +0,0 @@
1#!/usr/bin/env python
2# ex:ts=4:sw=4:sts=4:et
3# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
4"""
5BitBake 'Fetch' implementations
6
7Classes for obtaining upstream sources for the
8BitBake build tools.
9
10Copyright (C) 2003, 2004 Chris Larson
11
12This program is free software; you can redistribute it and/or modify it under
13the terms of the GNU General Public License as published by the Free Software
14Foundation; either version 2 of the License, or (at your option) any later
15version.
16
17This program is distributed in the hope that it will be useful, but WITHOUT
18ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20
21You should have received a copy of the GNU General Public License along with
22this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23Place, Suite 330, Boston, MA 02111-1307 USA.
24
25Based on functions from the base bb module, Copyright 2003 Holger Schurig
26"""
27
28import os, re
29import bb
30from bb import data
31from bb.fetch import Fetch
32
33class Bk(Fetch):
34 def supports(url, d):
35 """Check to see if a given url can be fetched via bitkeeper.
36 Expects supplied url in list form, as outputted by bb.decodeurl().
37 """
38 (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(url, d))
39 return type in ['bk']
40 supports = staticmethod(supports)
diff --git a/bitbake/lib/bb/fetch/cvs.py b/bitbake/lib/bb/fetch/cvs.py
index 461a2f50f9..10ec700dc9 100644
--- a/bitbake/lib/bb/fetch/cvs.py
+++ b/bitbake/lib/bb/fetch/cvs.py
@@ -133,21 +133,9 @@ class Cvs(Fetch):
133 bb.debug(1, "%s already exists, skipping cvs checkout." % tarfn) 133 bb.debug(1, "%s already exists, skipping cvs checkout." % tarfn)
134 continue 134 continue
135 135
136 pn = data.getVar('PN', d, 1) 136 # try to use the tarball stash
137 cvs_tarball_stash = None 137 if Fetch.try_mirror(d, tarfn):
138 if pn: 138 continue
139 cvs_tarball_stash = data.getVar('CVS_TARBALL_STASH_%s' % pn, d, 1)
140 if cvs_tarball_stash == None:
141 cvs_tarball_stash = data.getVar('CVS_TARBALL_STASH', d, 1)
142 if cvs_tarball_stash:
143 fetchcmd = data.getVar("FETCHCOMMAND_wget", d, 1)
144 uri = cvs_tarball_stash + tarfn
145 bb.note("fetch " + uri)
146 fetchcmd = fetchcmd.replace("${URI}", uri)
147 ret = os.system(fetchcmd)
148 if ret == 0:
149 bb.note("Fetched %s from tarball stash, skipping checkout" % tarfn)
150 continue
151 139
152 if date: 140 if date:
153 options.append("-D %s" % date) 141 options.append("-D %s" % date)
@@ -194,7 +182,7 @@ class Cvs(Fetch):
194 bb.debug(1, "Running %s" % cvscmd) 182 bb.debug(1, "Running %s" % cvscmd)
195 myret = os.system(cvscmd) 183 myret = os.system(cvscmd)
196 184
197 if myret != 0: 185 if myret != 0 or not os.access(moddir, os.R_OK):
198 try: 186 try:
199 os.rmdir(moddir) 187 os.rmdir(moddir)
200 except OSError: 188 except OSError:
diff --git a/bitbake/lib/bb/fetch/git.py b/bitbake/lib/bb/fetch/git.py
index 296b926392..439d522188 100644
--- a/bitbake/lib/bb/fetch/git.py
+++ b/bitbake/lib/bb/fetch/git.py
@@ -58,6 +58,28 @@ def gettag(parm):
58 58
59 return tag 59 return tag
60 60
61def getprotocol(parm):
62 if 'protocol' in parm:
63 proto = parm['protocol']
64 else:
65 proto = ""
66 if not proto:
67 proto = "rsync"
68
69 return proto
70
71def localfile(url, d):
72 """Return the filename to cache the checkout in"""
73 (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(url, d))
74
75 #if user sets localpath for file, use it instead.
76 if "localpath" in parm:
77 return parm["localpath"]
78
79 tag = gettag(parm)
80
81 return data.expand('git_%s%s_%s.tar.gz' % (host, path.replace('/', '.'), tag), d)
82
61class Git(Fetch): 83class Git(Fetch):
62 """Class to fetch a module or modules from git repositories""" 84 """Class to fetch a module or modules from git repositories"""
63 def supports(url, d): 85 def supports(url, d):
@@ -69,17 +91,8 @@ class Git(Fetch):
69 supports = staticmethod(supports) 91 supports = staticmethod(supports)
70 92
71 def localpath(url, d): 93 def localpath(url, d):
72 (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(url, d))
73
74 #if user sets localpath for file, use it instead.
75 if "localpath" in parm:
76 return parm["localpath"]
77 94
78 tag = gettag(parm) 95 return os.path.join(data.getVar("DL_DIR", d, 1), localfile(url, d))
79
80 localname = data.expand('git_%s%s_%s.tar.gz' % (host, path.replace('/', '.'), tag), d)
81
82 return os.path.join(data.getVar("DL_DIR", d, 1),data.expand('%s' % (localname), d))
83 96
84 localpath = staticmethod(localpath) 97 localpath = staticmethod(localpath)
85 98
@@ -92,10 +105,12 @@ class Git(Fetch):
92 (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(loc, d)) 105 (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(loc, d))
93 106
94 tag = gettag(parm) 107 tag = gettag(parm)
108 proto = getprotocol(parm)
95 109
96 gitsrcname = '%s%s' % (host, path.replace('/', '.')) 110 gitsrcname = '%s%s' % (host, path.replace('/', '.'))
97 111
98 repofile = os.path.join(data.getVar("DL_DIR", d, 1), 'git_%s.tar.gz' % (gitsrcname)) 112 repofilename = 'git_%s.tar.gz' % (gitsrcname)
113 repofile = os.path.join(data.getVar("DL_DIR", d, 1), repofilename)
99 repodir = os.path.join(data.expand('${GITDIR}', d), gitsrcname) 114 repodir = os.path.join(data.expand('${GITDIR}', d), gitsrcname)
100 115
101 coname = '%s' % (tag) 116 coname = '%s' % (tag)
@@ -103,63 +118,37 @@ class Git(Fetch):
103 118
104 cofile = self.localpath(loc, d) 119 cofile = self.localpath(loc, d)
105 120
106 # Always update to current if tag=="master" 121 # tag=="master" must always update
107 #if os.access(cofile, os.R_OK) and (tag != "master"): 122 if (tag != "master") and Fetch.try_mirror(d, localfile(loc, d)):
108 if os.access(cofile, os.R_OK): 123 bb.debug(1, "%s already exists (or was stashed). Skipping git checkout." % cofile)
109 bb.debug(1, "%s already exists, skipping git checkout." % cofile)
110 continue 124 continue
111 125
112# Still Need to add GIT_TARBALL_STASH Support... 126 if not os.path.exists(repodir):
113# pn = data.getVar('PN', d, 1) 127 if Fetch.try_mirror(d, repofilename):
114# cvs_tarball_stash = None 128 bb.mkdirhier(repodir)
115# if pn: 129 os.chdir(repodir)
116# cvs_tarball_stash = data.getVar('CVS_TARBALL_STASH_%s' % pn, d, 1) 130 rungitcmd("tar -xzf %s" % (repofile),d)
117# if cvs_tarball_stash == None: 131 else:
118# cvs_tarball_stash = data.getVar('CVS_TARBALL_STASH', d, 1) 132 rungitcmd("git clone %s://%s%s %s" % (proto, host, path, repodir),d)
119# if cvs_tarball_stash:
120# fetchcmd = data.getVar("FETCHCOMMAND_wget", d, 1)
121# uri = cvs_tarball_stash + tarfn
122# bb.note("fetch " + uri)
123# fetchcmd = fetchcmd.replace("${URI}", uri)
124# ret = os.system(fetchcmd)
125# if ret == 0:
126# bb.note("Fetched %s from tarball stash, skipping checkout" % tarfn)
127# continue
128
129 #if os.path.exists(repodir):
130 #prunedir(repodir)
131
132 bb.mkdirhier(repodir)
133 os.chdir(repodir)
134
135 #print("Changing to %s" % repodir)
136 133
137 if os.access(repofile, os.R_OK):
138 rungitcmd("tar -xzf %s" % (repofile),d)
139 else:
140 rungitcmd("git clone rsync://%s%s %s" % (host, path, repodir),d)
141
142 rungitcmd("rsync -a --verbose --stats --progress rsync://%s%s/ %s" % (host, path, os.path.join(repodir, ".git", "")),d)
143
144 #print("Changing to %s" % repodir)
145 os.chdir(repodir) 134 os.chdir(repodir)
146 rungitcmd("git pull rsync://%s%s" % (host, path),d) 135 rungitcmd("git pull %s://%s%s" % (proto, host, path),d)
136 rungitcmd("git pull --tags %s://%s%s" % (proto, host, path),d)
137 # old method of downloading tags
138 #rungitcmd("rsync -a --verbose --stats --progress rsync://%s%s/ %s" % (host, path, os.path.join(repodir, ".git", "")),d)
147 139
148 #print("Changing to %s" % repodir)
149 os.chdir(repodir) 140 os.chdir(repodir)
141 bb.note("Creating tarball of git repository")
150 rungitcmd("tar -czf %s %s" % (repofile, os.path.join(".", ".git", "*") ),d) 142 rungitcmd("tar -czf %s %s" % (repofile, os.path.join(".", ".git", "*") ),d)
151 143
152 if os.path.exists(codir): 144 if os.path.exists(codir):
153 prunedir(codir) 145 prunedir(codir)
154 146
155 #print("Changing to %s" % repodir)
156 bb.mkdirhier(codir) 147 bb.mkdirhier(codir)
157 os.chdir(repodir) 148 os.chdir(repodir)
158 rungitcmd("git read-tree %s" % (tag),d) 149 rungitcmd("git read-tree %s" % (tag),d)
159
160 rungitcmd("git checkout-index -q -f --prefix=%s -a" % (os.path.join(codir, "git", "")),d) 150 rungitcmd("git checkout-index -q -f --prefix=%s -a" % (os.path.join(codir, "git", "")),d)
161 151
162 #print("Changing to %s" % codir)
163 os.chdir(codir) 152 os.chdir(codir)
153 bb.note("Creating tarball of git checkout")
164 rungitcmd("tar -czf %s %s" % (cofile, os.path.join(".", "*") ),d) 154 rungitcmd("tar -czf %s %s" % (cofile, os.path.join(".", "*") ),d)
165
diff --git a/bitbake/lib/bb/fetch/svn.py b/bitbake/lib/bb/fetch/svn.py
index ac5eebf5c0..6e3a9277ab 100644
--- a/bitbake/lib/bb/fetch/svn.py
+++ b/bitbake/lib/bb/fetch/svn.py
@@ -98,20 +98,14 @@ class Svn(Fetch):
98 98
99 date = Fetch.getSRCDate(d) 99 date = Fetch.getSRCDate(d)
100 100
101 if "method" in parm:
102 method = parm["method"]
103 else:
104 method = "pserver"
105
106 if "proto" in parm: 101 if "proto" in parm:
107 proto = parm["proto"] 102 proto = parm["proto"]
108 else: 103 else:
109 proto = "svn" 104 proto = "svn"
110 105
111 svn_rsh = None 106 svn_rsh = None
112 if method == "ext": 107 if proto == "svn+ssh" and "rsh" in parm:
113 if "rsh" in parm: 108 svn_rsh = parm["rsh"]
114 svn_rsh = parm["rsh"]
115 109
116 tarfn = data.expand('%s_%s_%s_%s_%s.tar.gz' % (module.replace('/', '.'), host, path.replace('/', '.'), revision, date), localdata) 110 tarfn = data.expand('%s_%s_%s_%s_%s.tar.gz' % (module.replace('/', '.'), host, path.replace('/', '.'), revision, date), localdata)
117 data.setVar('TARFILES', dlfile, localdata) 111 data.setVar('TARFILES', dlfile, localdata)
@@ -122,24 +116,13 @@ class Svn(Fetch):
122 bb.debug(1, "%s already exists, skipping svn checkout." % tarfn) 116 bb.debug(1, "%s already exists, skipping svn checkout." % tarfn)
123 continue 117 continue
124 118
125 svn_tarball_stash = data.getVar('CVS_TARBALL_STASH', d, 1) 119 # try to use the tarball stash
126 if svn_tarball_stash: 120 if Fetch.try_mirror(d, tarfn):
127 fetchcmd = data.getVar("FETCHCOMMAND_wget", d, 1) 121 continue
128 uri = svn_tarball_stash + tarfn
129 bb.note("fetch " + uri)
130 fetchcmd = fetchcmd.replace("${URI}", uri)
131 ret = os.system(fetchcmd)
132 if ret == 0:
133 bb.note("Fetched %s from tarball stash, skipping checkout" % tarfn)
134 continue
135 122
136 olddir = os.path.abspath(os.getcwd()) 123 olddir = os.path.abspath(os.getcwd())
137 os.chdir(data.expand(dldir, localdata)) 124 os.chdir(data.expand(dldir, localdata))
138 125
139# setup svnroot
140# svnroot = ":" + method + ":" + user
141# if pswd:
142# svnroot += ":" + pswd
143 svnroot = host + path 126 svnroot = host + path
144 127
145 data.setVar('SVNROOT', svnroot, localdata) 128 data.setVar('SVNROOT', svnroot, localdata)