diff options
author | Richard Purdie <richard@openedhand.com> | 2006-11-16 15:02:15 +0000 |
---|---|---|
committer | Richard Purdie <richard@openedhand.com> | 2006-11-16 15:02:15 +0000 |
commit | 306b7c7a9757ead077363074e7bbac2e5c03e7c5 (patch) | |
tree | 6935017a9af749c46816881c86258f514384ba1c /bitbake/lib/bb/fetch/svk.py | |
parent | 65930a38e415ae4a0182e1cea1be838e0ada50ee (diff) | |
download | poky-306b7c7a9757ead077363074e7bbac2e5c03e7c5.tar.gz |
bitbake: Upgrade from 1.4 -> 1.7.4ish
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@863 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'bitbake/lib/bb/fetch/svk.py')
-rw-r--r-- | bitbake/lib/bb/fetch/svk.py | 160 |
1 files changed, 62 insertions, 98 deletions
diff --git a/bitbake/lib/bb/fetch/svk.py b/bitbake/lib/bb/fetch/svk.py index 19103213cd..29270ab3d8 100644 --- a/bitbake/lib/bb/fetch/svk.py +++ b/bitbake/lib/bb/fetch/svk.py | |||
@@ -42,112 +42,76 @@ from bb.fetch import MissingParameterError | |||
42 | 42 | ||
43 | class Svk(Fetch): | 43 | class Svk(Fetch): |
44 | """Class to fetch a module or modules from svk repositories""" | 44 | """Class to fetch a module or modules from svk repositories""" |
45 | def supports(url, d): | 45 | def supports(self, url, ud, 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 | """ | 46 | """ |
49 | (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(url, d)) | 47 | Check to see if a given url can be fetched with cvs. |
50 | return type in ['svk'] | 48 | """ |
51 | supports = staticmethod(supports) | 49 | return ud.type in ['svk'] |
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 | 50 | ||
59 | if not "module" in parm: | 51 | def localpath(self, url, ud, d): |
52 | if not "module" in ud.parm: | ||
60 | raise MissingParameterError("svk method needs a 'module' parameter") | 53 | raise MissingParameterError("svk method needs a 'module' parameter") |
61 | else: | 54 | else: |
62 | module = parm["module"] | 55 | ud.module = ud.parm["module"] |
63 | if 'rev' in parm: | 56 | |
64 | revision = parm['rev'] | 57 | ud.revision = "" |
65 | else: | 58 | if 'rev' in ud.parm: |
66 | revision = "" | 59 | ud.revision = ud.parm['rev'] |
60 | |||
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) | ||
67 | 62 | ||
68 | date = Fetch.getSRCDate(d) | 63 | return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) |
69 | 64 | ||
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)) | 65 | def forcefetch(self, url, ud, d): |
71 | localpath = staticmethod(localpath) | 66 | if (ud.date == "now"): |
67 | return True | ||
68 | return False | ||
72 | 69 | ||
73 | def go(self, d, urls = []): | 70 | def go(self, loc, ud, d): |
74 | """Fetch urls""" | 71 | """Fetch urls""" |
75 | if not urls: | ||
76 | urls = self.urls | ||
77 | 72 | ||
73 | if not self.forcefetch(loc, ud, d) and Fetch.try_mirror(d, ud.localfile): | ||
74 | return | ||
75 | |||
76 | svkroot = ud.host + ud.path | ||
77 | |||
78 | svkcmd = "svk co -r {%s} %s/%s" % (date, svkroot, ud.module) | ||
79 | |||
80 | if ud.revision: | ||
81 | svkcmd = "svk co -r %s/%s" % (ud.revision, svkroot, ud.module) | ||
82 | |||
83 | # create temp directory | ||
78 | localdata = data.createCopy(d) | 84 | localdata = data.createCopy(d) |
79 | data.setVar('OVERRIDES', "svk:%s" % data.getVar('OVERRIDES', localdata), localdata) | ||
80 | data.update_data(localdata) | 85 | data.update_data(localdata) |
81 | 86 | bb.msg.debug(2, bb.msg.domain.Fetcher, "Fetch: creating temporary directory") | |
82 | for loc in urls: | 87 | bb.mkdirhier(data.expand('${WORKDIR}', localdata)) |
83 | (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(loc, localdata)) | 88 | data.setVar('TMPBASE', data.expand('${WORKDIR}/oesvk.XXXXXX', localdata), localdata) |
84 | if not "module" in parm: | 89 | tmppipe = os.popen(data.getVar('MKTEMPDIRCMD', localdata, 1) or "false") |
85 | raise MissingParameterError("svk method needs a 'module' parameter") | 90 | tmpfile = tmppipe.readline().strip() |
86 | else: | 91 | if not tmpfile: |
87 | module = parm["module"] | 92 | bb.msg.error(bb.msg.domain.Fetcher, "Fetch: unable to create temporary directory.. make sure 'mktemp' is in the PATH.") |
88 | 93 | raise FetchError(ud.module) | |
89 | dlfile = self.localpath(loc, localdata) | 94 | |
90 | dldir = data.getVar('DL_DIR', localdata, 1) | 95 | # check out sources there |
91 | 96 | os.chdir(tmpfile) | |
92 | # setup svk options | 97 | bb.msg.note(1, bb.msg.domain.Fetcher, "Fetch " + loc) |
93 | options = [] | 98 | bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % svkcmd) |
94 | if 'rev' in parm: | 99 | myret = os.system(svkcmd) |
95 | revision = parm['rev'] | 100 | if myret != 0: |
96 | else: | 101 | try: |
97 | revision = "" | 102 | os.rmdir(tmpfile) |
98 | 103 | except OSError: | |
99 | date = Fetch.getSRCDate(d) | 104 | pass |
100 | tarfn = data.expand('%s_%s_%s_%s_%s.tar.gz' % (module.replace('/', '.'), host, path.replace('/', '.'), revision, date), localdata) | 105 | raise FetchError(ud.module) |
101 | data.setVar('TARFILES', dlfile, localdata) | 106 | |
102 | data.setVar('TARFN', tarfn, localdata) | 107 | os.chdir(os.path.join(tmpfile, os.path.dirname(ud.module))) |
103 | 108 | # tar them up to a defined filename | |
104 | if Fetch.check_for_tarball(d, tarfn, dldir, date): | 109 | myret = os.system("tar -czf %s %s" % (ud.localpath, os.path.basename(ud.module))) |
105 | continue | 110 | if myret != 0: |
106 | 111 | try: | |
107 | olddir = os.path.abspath(os.getcwd()) | 112 | os.unlink(ud.localpath) |
108 | os.chdir(data.expand(dldir, localdata)) | 113 | except OSError: |
109 | 114 | pass | |
110 | svkroot = host + path | 115 | raise FetchError(ud.module) |
111 | 116 | # cleanup | |
112 | data.setVar('SVKROOT', svkroot, localdata) | 117 | os.system('rm -rf %s' % tmpfile) |
113 | data.setVar('SVKCOOPTS', " ".join(options), localdata) | ||
114 | data.setVar('SVKMODULE', module, localdata) | ||
115 | svkcmd = "svk co -r {%s} %s/%s" % (date, svkroot, module) | ||
116 | |||
117 | if revision: | ||
118 | svkcmd = "svk co -r %s/%s" % (revision, svkroot, module) | ||
119 | |||
120 | # create temp directory | ||
121 | bb.debug(2, "Fetch: creating temporary directory") | ||
122 | bb.mkdirhier(data.expand('${WORKDIR}', localdata)) | ||
123 | data.setVar('TMPBASE', data.expand('${WORKDIR}/oesvk.XXXXXX', localdata), localdata) | ||
124 | tmppipe = os.popen(data.getVar('MKTEMPDIRCMD', localdata, 1) or "false") | ||
125 | tmpfile = tmppipe.readline().strip() | ||
126 | if not tmpfile: | ||
127 | bb.error("Fetch: unable to create temporary directory.. make sure 'mktemp' is in the PATH.") | ||
128 | raise FetchError(module) | ||
129 | |||
130 | # check out sources there | ||
131 | os.chdir(tmpfile) | ||
132 | bb.note("Fetch " + loc) | ||
133 | bb.debug(1, "Running %s" % svkcmd) | ||
134 | myret = os.system(svkcmd) | ||
135 | if myret != 0: | ||
136 | try: | ||
137 | os.rmdir(tmpfile) | ||
138 | except OSError: | ||
139 | pass | ||
140 | raise FetchError(module) | ||
141 | |||
142 | os.chdir(os.path.join(tmpfile, os.path.dirname(module))) | ||
143 | # tar them up to a defined filename | ||
144 | myret = os.system("tar -czf %s %s" % (os.path.join(dldir,tarfn), os.path.basename(module))) | ||
145 | if myret != 0: | ||
146 | try: | ||
147 | os.unlink(tarfn) | ||
148 | except OSError: | ||
149 | pass | ||
150 | # cleanup | ||
151 | os.system('rm -rf %s' % tmpfile) | ||
152 | os.chdir(olddir) | ||
153 | del localdata | ||