2 # ex:ts=4:sw=4:sts=4:et
3 # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
5 BitBake 'Fetch' implementations
7 This implementation is for svk. It is based on the svn implementation
9 Copyright (C) 2006 Holger Hans Peter Freyther
15 Classes for obtaining upstream sources for the
18 Copyright (C) 2003, 2004 Chris Larson
20 This program is free software; you can redistribute it and/or modify it under
21 the terms of the GNU General Public License as published by the Free Software
22 Foundation; either version 2 of the License, or (at your option) any later
25 This program is distributed in the hope that it will be useful, but WITHOUT
26 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
27 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
29 You should have received a copy of the GNU General Public License along with
30 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
31 Place, Suite 330, Boston, MA 02111-1307 USA.
33 Based on functions from the base bb module, Copyright 2003 Holger Schurig
39 from bb.fetch import Fetch
40 from bb.fetch import FetchError
41 from bb.fetch import MissingParameterError
44 """Class to fetch a module or modules from svk repositories"""
45 def supports(self, url, ud, d):
47 Check to see if a given url can be fetched with cvs.
49 return ud.type in ['svk']
51 def localpath(self, url, ud, d):
52 if not "module" in ud.parm:
53 raise MissingParameterError("svk method needs a 'module' parameter")
55 ud.module = ud.parm["module"]
59 ud.revision = ud.parm['rev']
61 ud.localfile = data.expand('%s_%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), ud.revision, ud.date), d)
63 return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
65 def go(self, loc, ud, d):
68 localdata = data.createCopy(d)
69 data.setVar('OVERRIDES', "svk:%s" % data.getVar('OVERRIDES', localdata), localdata)
70 data.update_data(localdata)
75 if (date != "now") and Fetch.try_mirror(d, ud.localfile):
78 svkroot = ud.host + ud.path
80 data.setVar('SVKROOT', svkroot, localdata)
81 data.setVar('SVKCOOPTS', " ".join(options), localdata)
82 data.setVar('SVKMODULE', ud.module, localdata)
83 svkcmd = "svk co -r {%s} %s/%s" % (date, svkroot, ud.module)
86 svkcmd = "svk co -r %s/%s" % (ud.revision, svkroot, ud.module)
88 # create temp directory
89 bb.msg.debug(2, bb.msg.domain.Fetcher, "Fetch: creating temporary directory")
90 bb.mkdirhier(data.expand('${WORKDIR}', localdata))
91 data.setVar('TMPBASE', data.expand('${WORKDIR}/oesvk.XXXXXX', localdata), localdata)
92 tmppipe = os.popen(data.getVar('MKTEMPDIRCMD', localdata, 1) or "false")
93 tmpfile = tmppipe.readline().strip()
95 bb.msg.error(bb.msg.domain.Fetcher, "Fetch: unable to create temporary directory.. make sure 'mktemp' is in the PATH.")
96 raise FetchError(ud.module)
98 # check out sources there
100 bb.msg.note(1, bb.msg.domain.Fetcher, "Fetch " + loc)
101 bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % svkcmd)
102 myret = os.system(svkcmd)
108 raise FetchError(ud.module)
110 os.chdir(os.path.join(tmpfile, os.path.dirname(ud.module)))
111 # tar them up to a defined filename
112 myret = os.system("tar -czf %s %s" % (ud.localpath, os.path.basename(ud.module)))
115 os.unlink(ud.localpath)
119 os.system('rm -rf %s' % tmpfile)