diff options
Diffstat (limited to 'bitbake/lib/bb/fetch/cvs.py')
| -rw-r--r-- | bitbake/lib/bb/fetch/cvs.py | 255 |
1 files changed, 105 insertions, 150 deletions
diff --git a/bitbake/lib/bb/fetch/cvs.py b/bitbake/lib/bb/fetch/cvs.py index 0b2477560a..3bdac177eb 100644 --- a/bitbake/lib/bb/fetch/cvs.py +++ b/bitbake/lib/bb/fetch/cvs.py | |||
| @@ -33,164 +33,119 @@ from bb.fetch import FetchError | |||
| 33 | from bb.fetch import MissingParameterError | 33 | from bb.fetch import MissingParameterError |
| 34 | 34 | ||
| 35 | class Cvs(Fetch): | 35 | class Cvs(Fetch): |
| 36 | """Class to fetch a module or modules from cvs repositories""" | 36 | """ |
| 37 | def supports(url, d): | 37 | Class to fetch a module or modules from cvs repositories |
| 38 | """Check to see if a given url can be fetched with cvs. | 38 | """ |
| 39 | Expects supplied url in list form, as outputted by bb.decodeurl(). | 39 | def supports(self, url, ud, d): |
| 40 | """ | 40 | """ |
| 41 | (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(url, d)) | 41 | Check to see if a given url can be fetched with cvs. |
| 42 | return type in ['cvs', 'pserver'] | 42 | """ |
| 43 | supports = staticmethod(supports) | 43 | return ud.type in ['cvs', 'pserver'] |
| 44 | |||
| 45 | def localpath(url, d): | ||
| 46 | (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(url, d)) | ||
| 47 | if "localpath" in parm: | ||
| 48 | # if user overrides local path, use it. | ||
| 49 | return parm["localpath"] | ||
| 50 | 44 | ||
| 51 | if not "module" in parm: | 45 | def localpath(self, url, ud, d): |
| 46 | if not "module" in ud.parm: | ||
| 52 | raise MissingParameterError("cvs method needs a 'module' parameter") | 47 | raise MissingParameterError("cvs method needs a 'module' parameter") |
| 53 | else: | 48 | ud.module = ud.parm["module"] |
| 54 | module = parm["module"] | 49 | |
| 55 | if 'tag' in parm: | 50 | ud.tag = "" |
| 56 | tag = parm['tag'] | 51 | if 'tag' in ud.parm: |
| 57 | else: | 52 | ud.tag = ud.parm['tag'] |
| 58 | tag = "" | 53 | |
| 59 | if 'date' in parm: | 54 | # Override the default date in certain cases |
| 60 | date = parm['date'] | 55 | if 'date' in ud.parm: |
| 61 | else: | 56 | ud.date = ud.parm['date'] |
| 62 | if not tag: | 57 | elif ud.tag: |
| 63 | date = Fetch.getSRCDate(d) | 58 | ud.date = "" |
| 64 | else: | 59 | |
| 65 | date = "" | 60 | ud.localfile = data.expand('%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.tag, ud.date), d) |
| 61 | |||
| 62 | return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) | ||
| 66 | 63 | ||
| 67 | return os.path.join(data.getVar("DL_DIR", d, 1),data.expand('%s_%s_%s_%s.tar.gz' % ( module.replace('/', '.'), host, tag, date), d)) | 64 | def forcefetch(self, url, ud, d): |
| 68 | localpath = staticmethod(localpath) | 65 | if (ud.date == "now"): |
| 66 | return True | ||
| 67 | return False | ||
| 69 | 68 | ||
| 70 | def go(self, d, urls = []): | 69 | def go(self, loc, ud, d): |
| 71 | """Fetch urls""" | 70 | |
| 72 | if not urls: | 71 | # try to use the tarball stash |
| 73 | urls = self.urls | 72 | if not self.forcefetch(loc, ud, d) and Fetch.try_mirror(d, ud.localfile): |
| 73 | bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists or was mirrored, skipping cvs checkout." % ud.localpath) | ||
| 74 | return | ||
| 75 | |||
| 76 | method = "pserver" | ||
| 77 | if "method" in ud.parm: | ||
| 78 | method = ud.parm["method"] | ||
| 79 | |||
| 80 | localdir = ud.module | ||
| 81 | if "localdir" in ud.parm: | ||
| 82 | localdir = ud.parm["localdir"] | ||
| 83 | |||
| 84 | cvs_rsh = None | ||
| 85 | if method == "ext": | ||
| 86 | if "rsh" in ud.parm: | ||
| 87 | cvs_rsh = ud.parm["rsh"] | ||
| 88 | |||
| 89 | if method == "dir": | ||
| 90 | cvsroot = ud.path | ||
| 91 | else: | ||
| 92 | cvsroot = ":" + method + ":" + ud.user | ||
| 93 | if ud.pswd: | ||
| 94 | cvsroot += ":" + ud.pswd | ||
| 95 | cvsroot += "@" + ud.host + ":" + ud.path | ||
| 96 | |||
| 97 | options = [] | ||
| 98 | if ud.date: | ||
| 99 | options.append("-D %s" % ud.date) | ||
| 100 | if ud.tag: | ||
| 101 | options.append("-r %s" % ud.tag) | ||
| 74 | 102 | ||
| 75 | localdata = data.createCopy(d) | 103 | localdata = data.createCopy(d) |
| 76 | data.setVar('OVERRIDES', "cvs:%s" % data.getVar('OVERRIDES', localdata), localdata) | 104 | data.setVar('OVERRIDES', "cvs:%s" % data.getVar('OVERRIDES', localdata), localdata) |
| 77 | data.update_data(localdata) | 105 | data.update_data(localdata) |
| 78 | 106 | ||
| 79 | for loc in urls: | 107 | data.setVar('CVSROOT', cvsroot, localdata) |
| 80 | (type, host, path, user, pswd, parm) = bb.decodeurl(data.expand(loc, localdata)) | 108 | data.setVar('CVSCOOPTS', " ".join(options), localdata) |
| 81 | if not "module" in parm: | 109 | data.setVar('CVSMODULE', ud.module, localdata) |
| 82 | raise MissingParameterError("cvs method needs a 'module' parameter") | 110 | cvscmd = data.getVar('FETCHCOMMAND', localdata, 1) |
| 83 | else: | 111 | cvsupdatecmd = data.getVar('UPDATECOMMAND', localdata, 1) |
| 84 | module = parm["module"] | 112 | |
| 85 | 113 | if cvs_rsh: | |
| 86 | dlfile = self.localpath(loc, localdata) | 114 | cvscmd = "CVS_RSH=\"%s\" %s" % (cvs_rsh, cvscmd) |
| 87 | dldir = data.getVar('DL_DIR', localdata, 1) | 115 | cvsupdatecmd = "CVS_RSH=\"%s\" %s" % (cvs_rsh, cvsupdatecmd) |
| 88 | # if local path contains the cvs | 116 | |
| 89 | # module, consider the dir above it to be the | 117 | # create module directory |
| 90 | # download directory | 118 | bb.msg.debug(2, bb.msg.domain.Fetcher, "Fetch: checking for module directory") |
| 91 | # pos = dlfile.find(module) | 119 | pkg = data.expand('${PN}', d) |
| 92 | # if pos: | 120 | pkgdir = os.path.join(data.expand('${CVSDIR}', localdata), pkg) |
| 93 | # dldir = dlfile[:pos] | 121 | moddir = os.path.join(pkgdir,localdir) |
| 94 | # else: | 122 | if os.access(os.path.join(moddir,'CVS'), os.R_OK): |
| 95 | # dldir = os.path.dirname(dlfile) | 123 | bb.msg.note(1, bb.msg.domain.Fetcher, "Update " + loc) |
| 96 | 124 | # update sources there | |
| 97 | # setup cvs options | ||
| 98 | options = [] | ||
| 99 | if 'tag' in parm: | ||
| 100 | tag = parm['tag'] | ||
| 101 | else: | ||
| 102 | tag = "" | ||
| 103 | |||
| 104 | if 'date' in parm: | ||
| 105 | date = parm['date'] | ||
| 106 | else: | ||
| 107 | if not tag: | ||
| 108 | date = Fetch.getSRCDate(d) | ||
| 109 | else: | ||
| 110 | date = "" | ||
| 111 | |||
| 112 | if "method" in parm: | ||
| 113 | method = parm["method"] | ||
| 114 | else: | ||
| 115 | method = "pserver" | ||
| 116 | |||
| 117 | if "localdir" in parm: | ||
| 118 | localdir = parm["localdir"] | ||
| 119 | else: | ||
| 120 | localdir = module | ||
| 121 | |||
| 122 | cvs_rsh = None | ||
| 123 | if method == "ext": | ||
| 124 | if "rsh" in parm: | ||
| 125 | cvs_rsh = parm["rsh"] | ||
| 126 | |||
| 127 | tarfn = data.expand('%s_%s_%s_%s.tar.gz' % (module.replace('/', '.'), host, tag, date), localdata) | ||
| 128 | data.setVar('TARFILES', dlfile, localdata) | ||
| 129 | data.setVar('TARFN', tarfn, localdata) | ||
| 130 | |||
| 131 | if Fetch.check_for_tarball(d, tarfn, dldir, date): | ||
| 132 | continue | ||
| 133 | |||
| 134 | if date: | ||
| 135 | options.append("-D %s" % date) | ||
| 136 | if tag: | ||
| 137 | options.append("-r %s" % tag) | ||
| 138 | |||
| 139 | olddir = os.path.abspath(os.getcwd()) | ||
| 140 | os.chdir(data.expand(dldir, localdata)) | ||
| 141 | |||
| 142 | # setup cvsroot | ||
| 143 | if method == "dir": | ||
| 144 | cvsroot = path | ||
| 145 | else: | ||
| 146 | cvsroot = ":" + method + ":" + user | ||
| 147 | if pswd: | ||
| 148 | cvsroot += ":" + pswd | ||
| 149 | cvsroot += "@" + host + ":" + path | ||
| 150 | |||
| 151 | data.setVar('CVSROOT', cvsroot, localdata) | ||
| 152 | data.setVar('CVSCOOPTS', " ".join(options), localdata) | ||
| 153 | data.setVar('CVSMODULE', module, localdata) | ||
| 154 | cvscmd = data.getVar('FETCHCOMMAND', localdata, 1) | ||
| 155 | cvsupdatecmd = data.getVar('UPDATECOMMAND', localdata, 1) | ||
| 156 | |||
| 157 | if cvs_rsh: | ||
| 158 | cvscmd = "CVS_RSH=\"%s\" %s" % (cvs_rsh, cvscmd) | ||
| 159 | cvsupdatecmd = "CVS_RSH=\"%s\" %s" % (cvs_rsh, cvsupdatecmd) | ||
| 160 | |||
| 161 | # create module directory | ||
| 162 | bb.debug(2, "Fetch: checking for module directory") | ||
| 163 | pkg=data.expand('${PN}', d) | ||
| 164 | pkgdir=os.path.join(data.expand('${CVSDIR}', localdata), pkg) | ||
| 165 | moddir=os.path.join(pkgdir,localdir) | ||
| 166 | if os.access(os.path.join(moddir,'CVS'), os.R_OK): | ||
| 167 | bb.note("Update " + loc) | ||
| 168 | # update sources there | ||
| 169 | os.chdir(moddir) | ||
| 170 | myret = os.system(cvsupdatecmd) | ||
| 171 | else: | ||
| 172 | bb.note("Fetch " + loc) | ||
| 173 | # check out sources there | ||
| 174 | bb.mkdirhier(pkgdir) | ||
| 175 | os.chdir(pkgdir) | ||
| 176 | bb.debug(1, "Running %s" % cvscmd) | ||
| 177 | myret = os.system(cvscmd) | ||
| 178 | |||
| 179 | if myret != 0 or not os.access(moddir, os.R_OK): | ||
| 180 | try: | ||
| 181 | os.rmdir(moddir) | ||
| 182 | except OSError: | ||
| 183 | pass | ||
| 184 | raise FetchError(module) | ||
| 185 | |||
| 186 | os.chdir(moddir) | 125 | os.chdir(moddir) |
| 187 | os.chdir('..') | 126 | myret = os.system(cvsupdatecmd) |
| 188 | # tar them up to a defined filename | 127 | else: |
| 189 | myret = os.system("tar -czf %s %s" % (os.path.join(dldir,tarfn), os.path.basename(moddir))) | 128 | bb.msg.note(1, bb.msg.domain.Fetcher, "Fetch " + loc) |
| 190 | if myret != 0: | 129 | # check out sources there |
| 191 | try: | 130 | bb.mkdirhier(pkgdir) |
| 192 | os.unlink(tarfn) | 131 | os.chdir(pkgdir) |
| 193 | except OSError: | 132 | bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % cvscmd) |
| 194 | pass | 133 | myret = os.system(cvscmd) |
| 195 | os.chdir(olddir) | 134 | |
| 196 | del localdata | 135 | if myret != 0 or not os.access(moddir, os.R_OK): |
| 136 | try: | ||
| 137 | os.rmdir(moddir) | ||
| 138 | except OSError: | ||
| 139 | pass | ||
| 140 | raise FetchError(ud.module) | ||
| 141 | |||
| 142 | os.chdir(moddir) | ||
| 143 | os.chdir('..') | ||
| 144 | # tar them up to a defined filename | ||
| 145 | myret = os.system("tar -czf %s %s" % (ud.localpath, os.path.basename(moddir))) | ||
| 146 | if myret != 0: | ||
| 147 | try: | ||
| 148 | os.unlink(ud.localpath) | ||
| 149 | except OSError: | ||
| 150 | pass | ||
| 151 | raise FetchError(ud.module) | ||
