summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/cvs.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2011-02-04 10:26:21 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-02-07 09:06:36 +0000
commitd08397ba4d1331993300eacbb2f78fcfef19c1cf (patch)
tree374d8aa46a69fbae08d2b3e8e7456a5c61005e4c /bitbake/lib/bb/fetch2/cvs.py
parentf6eefb3ca3bb2a5ea0ec1364bdb0bc41ae58c815 (diff)
downloadpoky-d08397ba4d1331993300eacbb2f78fcfef19c1cf.tar.gz
bitbake/fetch2: Rewrite and improve exception handling, reusing core functions for common operations where possible
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2/cvs.py')
-rw-r--r--bitbake/lib/bb/fetch2/cvs.py30
1 files changed, 12 insertions, 18 deletions
diff --git a/bitbake/lib/bb/fetch2/cvs.py b/bitbake/lib/bb/fetch2/cvs.py
index 907812d717..d792328c25 100644
--- a/bitbake/lib/bb/fetch2/cvs.py
+++ b/bitbake/lib/bb/fetch2/cvs.py
@@ -44,7 +44,7 @@ class Cvs(Fetch):
44 44
45 def urldata_init(self, ud, d): 45 def urldata_init(self, ud, d):
46 if not "module" in ud.parm: 46 if not "module" in ud.parm:
47 raise MissingParameterError("cvs method needs a 'module' parameter") 47 raise MissingParameterError("module", ud.url)
48 ud.module = ud.parm["module"] 48 ud.module = ud.parm["module"]
49 49
50 ud.tag = ud.parm.get('tag', "") 50 ud.tag = ud.parm.get('tag', "")
@@ -132,7 +132,7 @@ class Cvs(Fetch):
132 bb.fetch2.check_network_access(d, cvsupdatecmd) 132 bb.fetch2.check_network_access(d, cvsupdatecmd)
133 # update sources there 133 # update sources there
134 os.chdir(moddir) 134 os.chdir(moddir)
135 myret = os.system(cvsupdatecmd) 135 cmd = cvsupdatecmd
136 else: 136 else:
137 logger.info("Fetch " + loc) 137 logger.info("Fetch " + loc)
138 # check out sources there 138 # check out sources there
@@ -140,14 +140,12 @@ class Cvs(Fetch):
140 os.chdir(pkgdir) 140 os.chdir(pkgdir)
141 logger.debug(1, "Running %s", cvscmd) 141 logger.debug(1, "Running %s", cvscmd)
142 bb.fetch2.check_network_access(d, cvscmd) 142 bb.fetch2.check_network_access(d, cvscmd)
143 myret = os.system(cvscmd) 143 cmd = cvscmd
144 144
145 if myret != 0 or not os.access(moddir, os.R_OK): 145 runfetchcmd(cmd, d, cleanup = [moddir])
146 try: 146
147 os.rmdir(moddir) 147 if not os.access(moddir, os.R_OK):
148 except OSError: 148 raise FetchError("Directory %s was not readable despite sucessful fetch?!" % moddir, ud.url)
149 pass
150 raise FetchError(ud.module)
151 149
152 scmdata = ud.parm.get("scmdata", "") 150 scmdata = ud.parm.get("scmdata", "")
153 if scmdata == "keep": 151 if scmdata == "keep":
@@ -158,15 +156,11 @@ class Cvs(Fetch):
158 # tar them up to a defined filename 156 # tar them up to a defined filename
159 if 'fullpath' in ud.parm: 157 if 'fullpath' in ud.parm:
160 os.chdir(pkgdir) 158 os.chdir(pkgdir)
161 myret = os.system("tar %s -czf %s %s" % (tar_flags, ud.localpath, localdir)) 159 cmd = "tar %s -czf %s %s" % (tar_flags, ud.localpath, localdir)
162 else: 160 else:
163 os.chdir(moddir) 161 os.chdir(moddir)
164 os.chdir('..') 162 os.chdir('..')
165 myret = os.system("tar %s -czf %s %s" % (tar_flags, ud.localpath, os.path.basename(moddir))) 163 cmd = "tar %s -czf %s %s" % (tar_flags, ud.localpath, os.path.basename(moddir))
166 164
167 if myret != 0: 165 runfetchcmd(cmd, d, cleanup = [ud.localpath])
168 try: 166
169 os.unlink(ud.localpath)
170 except OSError:
171 pass
172 raise FetchError(ud.module)