summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard@openedhand.com>2006-03-20 21:02:45 +0000
committerRichard Purdie <richard@openedhand.com>2006-03-20 21:02:45 +0000
commit14ed1250ccdce0ac65b8231ea232a316bb93b901 (patch)
tree56e428c3e4aeba0ae78abaa4e8e05c02c2b9beac /bitbake
parentb26a945734ce271aa7d443ff9e96fe2851b21138 (diff)
downloadpoky-14ed1250ccdce0ac65b8231ea232a316bb93b901.tar.gz
Add missing file
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@310 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/fetch/svk.py155
1 files changed, 155 insertions, 0 deletions
diff --git a/bitbake/lib/bb/fetch/svk.py b/bitbake/lib/bb/fetch/svk.py
new file mode 100644
index 0000000000..c0819da3dc
--- /dev/null
+++ b/bitbake/lib/bb/fetch/svk.py
@@ -0,0 +1,155 @@
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
7This implementation is for svk. It is based on the svn implementation
8
9Copyright (C) 2006 Holger Hans Peter Freyther
10
11GPL and MIT licensed
12
13
14
15Classes for obtaining upstream sources for the
16BitBake build tools.
17
18Copyright (C) 2003, 2004 Chris Larson
19
20This program is free software; you can redistribute it and/or modify it under
21the terms of the GNU General Public License as published by the Free Software
22Foundation; either version 2 of the License, or (at your option) any later
23version.
24
25This program is distributed in the hope that it will be useful, but WITHOUT
26ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
27FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
28
29You should have received a copy of the GNU General Public License along with
30this program; if not, write to the Free Software Foundation, Inc., 59 Temple
31Place, Suite 330, Boston, MA 02111-1307 USA.
32
33Based on functions from the base bb module, Copyright 2003 Holger Schurig
34"""
35
36import os, re
37import bb
38from bb import data
39from bb.fetch import Fetch
40from bb.fetch import FetchError
41from bb.fetch import MissingParameterError
42
43class Svk(Fetch):
44 """Class to fetch a module or modules from svk repositories"""
45 def supports(url, d):
46 """Check to see if a given url can be fetched with svk.
47 Expects supplied url in list form, as outputted by bb.decodeurl().
48 """
49 (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(url, d))
50 return type in ['svk']
51 supports = staticmethod(supports)
52
53 def localpath(url, d):
54 (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(url, d))
55 if "localpath" in parm:
56# if user overrides local path, use it.
57 return parm["localpath"]
58
59 if not "module" in parm:
60 raise MissingParameterError("svk method needs a 'module' parameter")
61 else:
62 module = parm["module"]
63 if 'rev' in parm:
64 revision = parm['rev']
65 else:
66 revision = ""
67
68 date = Fetch.getSRCDate(d)
69
70 return os.path.join(data.getVar("DL_DIR", d, 1),data.expand('%s_%s_%s_%s_%s.tar.gz' % ( module.replace('/', '.'), host, path.replace('/', '.'), revision, date), d))
71 localpath = staticmethod(localpath)
72
73 def go(self, d, urls = []):
74 """Fetch urls"""
75 if not urls:
76 urls = self.urls
77
78 localdata = data.createCopy(d)
79 data.setVar('OVERRIDES', "svk:%s" % data.getVar('OVERRIDES', localdata), localdata)
80 data.update_data(localdata)
81
82 for loc in urls:
83 (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(loc, localdata))
84 if not "module" in parm:
85 raise MissingParameterError("svk method needs a 'module' parameter")
86 else:
87 module = parm["module"]
88
89 dlfile = self.localpath(loc, localdata)
90 dldir = data.getVar('DL_DIR', localdata, 1)
91
92# setup svk options
93 options = []
94 if 'rev' in parm:
95 revision = parm['rev']
96 else:
97 revision = ""
98
99 date = Fetch.getSRCDate(d)
100 tarfn = data.expand('%s_%s_%s_%s_%s.tar.gz' % (module.replace('/', '.'), host, path.replace('/', '.'), revision, date), localdata)
101 data.setVar('TARFILES', dlfile, localdata)
102 data.setVar('TARFN', tarfn, localdata)
103
104 dl = os.path.join(dldir, tarfn)
105 if os.access(dl, os.R_OK):
106 bb.debug(1, "%s already exists, skipping svk checkout." % tarfn)
107 continue
108
109 olddir = os.path.abspath(os.getcwd())
110 os.chdir(data.expand(dldir, localdata))
111
112 svkroot = host + path
113
114 data.setVar('SVKROOT', svkroot, localdata)
115 data.setVar('SVKCOOPTS', " ".join(options), localdata)
116 data.setVar('SVKMODULE', module, localdata)
117 svkcmd = "svk co -r {%s} %s/%s" % (date, svkroot, module)
118
119 if revision:
120 svkcmd = "svk co -r %s/%s" % (revision, svkroot, module)
121
122# create temp directory
123 bb.debug(2, "Fetch: creating temporary directory")
124 bb.mkdirhier(data.expand('${WORKDIR}', localdata))
125 data.setVar('TMPBASE', data.expand('${WORKDIR}/oesvk.XXXXXX', localdata), localdata)
126 tmppipe = os.popen(data.getVar('MKTEMPDIRCMD', localdata, 1) or "false")
127 tmpfile = tmppipe.readline().strip()
128 if not tmpfile:
129 bb.error("Fetch: unable to create temporary directory.. make sure 'mktemp' is in the PATH.")
130 raise FetchError(module)
131
132# check out sources there
133 os.chdir(tmpfile)
134 bb.note("Fetch " + loc)
135 bb.debug(1, "Running %s" % svkcmd)
136 myret = os.system(svkcmd)
137 if myret != 0:
138 try:
139 os.rmdir(tmpfile)
140 except OSError:
141 pass
142 raise FetchError(module)
143
144 os.chdir(os.path.join(tmpfile, os.path.dirname(module)))
145# tar them up to a defined filename
146 myret = os.system("tar -czf %s %s" % (os.path.join(dldir,tarfn), os.path.basename(module)))
147 if myret != 0:
148 try:
149 os.unlink(tarfn)
150 except OSError:
151 pass
152# cleanup
153 os.system('rm -rf %s' % tmpfile)
154 os.chdir(olddir)
155 del localdata