summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/svk.py
diff options
context:
space:
mode:
authorYu Ke <ke.yu@intel.com>2011-01-10 14:23:36 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-01-10 14:23:36 +0000
commit4dccd92439f3b21056c53f2317249228067defe6 (patch)
treeb5507598213381b870f53b3f816102b0b2899b86 /bitbake/lib/bb/fetch2/svk.py
parentf46cdcbbae0ac3cbce423d262358e670add6065e (diff)
downloadpoky-4dccd92439f3b21056c53f2317249228067defe6.tar.gz
bitbake: copy bb.fetch to bb.fetch2 as initial code base for fetcher overhaul
Signed-off-by: Yu Ke <ke.yu@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2/svk.py')
-rw-r--r--bitbake/lib/bb/fetch2/svk.py104
1 files changed, 104 insertions, 0 deletions
diff --git a/bitbake/lib/bb/fetch2/svk.py b/bitbake/lib/bb/fetch2/svk.py
new file mode 100644
index 0000000000..595a9da255
--- /dev/null
+++ b/bitbake/lib/bb/fetch2/svk.py
@@ -0,0 +1,104 @@
1# ex:ts=4:sw=4:sts=4:et
2# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
3"""
4BitBake 'Fetch' implementations
5
6This implementation is for svk. It is based on the svn implementation
7
8"""
9
10# Copyright (C) 2006 Holger Hans Peter Freyther
11# Copyright (C) 2003, 2004 Chris Larson
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# Based on functions from the base bb module, Copyright 2003 Holger Schurig
27
28import os
29import logging
30import bb
31from bb import data
32from bb.fetch import Fetch
33from bb.fetch import FetchError
34from bb.fetch import MissingParameterError
35from bb.fetch import logger
36
37class Svk(Fetch):
38 """Class to fetch a module or modules from svk repositories"""
39 def supports(self, url, ud, d):
40 """
41 Check to see if a given url can be fetched with svk.
42 """
43 return ud.type in ['svk']
44
45 def localpath(self, url, ud, d):
46 if not "module" in ud.parm:
47 raise MissingParameterError("svk method needs a 'module' parameter")
48 else:
49 ud.module = ud.parm["module"]
50
51 ud.revision = ud.parm.get('rev', "")
52
53 ud.localfile = data.expand('%s_%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), ud.revision, ud.date), d)
54
55 return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
56
57 def forcefetch(self, url, ud, d):
58 return ud.date == "now"
59
60 def go(self, loc, ud, d):
61 """Fetch urls"""
62
63 svkroot = ud.host + ud.path
64
65 svkcmd = "svk co -r {%s} %s/%s" % (ud.date, svkroot, ud.module)
66
67 if ud.revision:
68 svkcmd = "svk co -r %s %s/%s" % (ud.revision, svkroot, ud.module)
69
70 # create temp directory
71 localdata = data.createCopy(d)
72 data.update_data(localdata)
73 logger.debug(2, "Fetch: creating temporary directory")
74 bb.mkdirhier(data.expand('${WORKDIR}', localdata))
75 data.setVar('TMPBASE', data.expand('${WORKDIR}/oesvk.XXXXXX', localdata), localdata)
76 tmppipe = os.popen(data.getVar('MKTEMPDIRCMD', localdata, 1) or "false")
77 tmpfile = tmppipe.readline().strip()
78 if not tmpfile:
79 logger.error("Fetch: unable to create temporary directory.. make sure 'mktemp' is in the PATH.")
80 raise FetchError(ud.module)
81
82 # check out sources there
83 os.chdir(tmpfile)
84 logger.info("Fetch " + loc)
85 logger.debug(1, "Running %s", svkcmd)
86 myret = os.system(svkcmd)
87 if myret != 0:
88 try:
89 os.rmdir(tmpfile)
90 except OSError:
91 pass
92 raise FetchError(ud.module)
93
94 os.chdir(os.path.join(tmpfile, os.path.dirname(ud.module)))
95 # tar them up to a defined filename
96 myret = os.system("tar -czf %s %s" % (ud.localpath, os.path.basename(ud.module)))
97 if myret != 0:
98 try:
99 os.unlink(ud.localpath)
100 except OSError:
101 pass
102 raise FetchError(ud.module)
103 # cleanup
104 bb.utils.prunedir(tmpfile)