diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-02-11 22:08:21 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-02-11 22:08:21 +0000 |
commit | 029f19bd3d4dc09fb48bf6e5322d48bb84c4eb34 (patch) | |
tree | c4738712f08cb91326bea57aff156c31c289e21e /bitbake/lib | |
parent | 4a226460d5e158e8adbf74a68717cb9a923e8009 (diff) | |
download | poky-029f19bd3d4dc09fb48bf6e5322d48bb84c4eb34.tar.gz |
bitbake/fetch2: Add explict network access exception and handling to give users usable error messages
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/fetch2/__init__.py | 20 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch2/bzr.py | 6 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch2/cvs.py | 4 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch2/git.py | 2 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch2/hg.py | 4 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch2/osc.py | 4 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch2/repo.py | 4 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch2/ssh.py | 2 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch2/svn.py | 4 |
9 files changed, 33 insertions, 17 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index bc1824b01b..d8bee063e7 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py | |||
@@ -117,6 +117,16 @@ class SHA256SumError(MD5SumError): | |||
117 | BBFetchException.__init__(self, msg) | 117 | BBFetchException.__init__(self, msg) |
118 | self.args = (path, wanted, got, url) | 118 | self.args = (path, wanted, got, url) |
119 | 119 | ||
120 | class NetworkAccess(BBFetchException): | ||
121 | """Exception raised when network access is disabled but it is required.""" | ||
122 | def __init__(self, url, cmd): | ||
123 | msg = "Network access disabled through BB_NO_NETWORK but access rquested with command %s (for url %s)" % (cmd, url) | ||
124 | self.url = url | ||
125 | self.cmd = cmd | ||
126 | BBFetchException.__init__(self, msg) | ||
127 | self.args = (url, cmd) | ||
128 | |||
129 | |||
120 | def decodeurl(url): | 130 | def decodeurl(url): |
121 | """Decodes an URL into the tokens (scheme, network location, path, | 131 | """Decodes an URL into the tokens (scheme, network location, path, |
122 | user, password, parameters). | 132 | user, password, parameters). |
@@ -398,12 +408,12 @@ def runfetchcmd(cmd, d, quiet = False, cleanup = []): | |||
398 | 408 | ||
399 | return output | 409 | return output |
400 | 410 | ||
401 | def check_network_access(d, info = ""): | 411 | def check_network_access(d, info = "", url = None): |
402 | """ | 412 | """ |
403 | log remote network access, and error if BB_NO_NETWORK is set | 413 | log remote network access, and error if BB_NO_NETWORK is set |
404 | """ | 414 | """ |
405 | if bb.data.getVar("BB_NO_NETWORK", d, True) == "1": | 415 | if bb.data.getVar("BB_NO_NETWORK", d, True) == "1": |
406 | raise FetchError("BB_NO_NETWORK is set, but the fetcher code attempted network access with the command %s" % info) | 416 | raise NetworkAccess(url, info) |
407 | else: | 417 | else: |
408 | logger.debug(1, "Fetcher accessed the network with the command %s" % info) | 418 | logger.debug(1, "Fetcher accessed the network with the command %s" % info) |
409 | 419 | ||
@@ -459,6 +469,9 @@ def try_mirrors(d, origud, mirrors, check = False): | |||
459 | os.symlink(ud.localpath, origud.localpath) | 469 | os.symlink(ud.localpath, origud.localpath) |
460 | return ud.localpath | 470 | return ud.localpath |
461 | 471 | ||
472 | except bb.fetch2.NetworkAccess: | ||
473 | raise | ||
474 | |||
462 | except bb.fetch2.BBFetchException as e: | 475 | except bb.fetch2.BBFetchException as e: |
463 | logger.debug(1, "Mirror fetch failure for url %s (original url: %s)" % (newuri, origud.url)) | 476 | logger.debug(1, "Mirror fetch failure for url %s (original url: %s)" % (newuri, origud.url)) |
464 | logger.debug(1, str(e)) | 477 | logger.debug(1, str(e)) |
@@ -909,6 +922,9 @@ class Fetch(object): | |||
909 | m.build_mirror_data(u, ud, self.d) | 922 | m.build_mirror_data(u, ud, self.d) |
910 | localpath = ud.localpath | 923 | localpath = ud.localpath |
911 | 924 | ||
925 | except bb.fetch2.NetworkAccess: | ||
926 | raise | ||
927 | |||
912 | except BBFetchException as e: | 928 | except BBFetchException as e: |
913 | logger.debug(1, str(e)) | 929 | logger.debug(1, str(e)) |
914 | # Remove any incomplete fetch | 930 | # Remove any incomplete fetch |
diff --git a/bitbake/lib/bb/fetch2/bzr.py b/bitbake/lib/bb/fetch2/bzr.py index bb175662b4..454961eff0 100644 --- a/bitbake/lib/bb/fetch2/bzr.py +++ b/bitbake/lib/bb/fetch2/bzr.py | |||
@@ -85,13 +85,13 @@ class Bzr(FetchMethod): | |||
85 | if os.access(os.path.join(ud.pkgdir, os.path.basename(ud.pkgdir), '.bzr'), os.R_OK): | 85 | if os.access(os.path.join(ud.pkgdir, os.path.basename(ud.pkgdir), '.bzr'), os.R_OK): |
86 | bzrcmd = self._buildbzrcommand(ud, d, "update") | 86 | bzrcmd = self._buildbzrcommand(ud, d, "update") |
87 | logger.debug(1, "BZR Update %s", loc) | 87 | logger.debug(1, "BZR Update %s", loc) |
88 | bb.fetch2.check_network_access(d, bzrcmd) | 88 | bb.fetch2.check_network_access(d, bzrcmd, ud.url) |
89 | os.chdir(os.path.join (ud.pkgdir, os.path.basename(ud.path))) | 89 | os.chdir(os.path.join (ud.pkgdir, os.path.basename(ud.path))) |
90 | runfetchcmd(bzrcmd, d) | 90 | runfetchcmd(bzrcmd, d) |
91 | else: | 91 | else: |
92 | bb.utils.remove(os.path.join(ud.pkgdir, os.path.basename(ud.pkgdir)), True) | 92 | bb.utils.remove(os.path.join(ud.pkgdir, os.path.basename(ud.pkgdir)), True) |
93 | bzrcmd = self._buildbzrcommand(ud, d, "fetch") | 93 | bzrcmd = self._buildbzrcommand(ud, d, "fetch") |
94 | bb.fetch2.check_network_access(d, bzrcmd) | 94 | bb.fetch2.check_network_access(d, bzrcmd, ud.url) |
95 | logger.debug(1, "BZR Checkout %s", loc) | 95 | logger.debug(1, "BZR Checkout %s", loc) |
96 | bb.mkdirhier(ud.pkgdir) | 96 | bb.mkdirhier(ud.pkgdir) |
97 | os.chdir(ud.pkgdir) | 97 | os.chdir(ud.pkgdir) |
@@ -124,7 +124,7 @@ class Bzr(FetchMethod): | |||
124 | """ | 124 | """ |
125 | logger.debug(2, "BZR fetcher hitting network for %s", url) | 125 | logger.debug(2, "BZR fetcher hitting network for %s", url) |
126 | 126 | ||
127 | bb.fetch2.check_network_access(d, self._buildbzrcommand(ud, d, "revno")) | 127 | bb.fetch2.check_network_access(d, self._buildbzrcommand(ud, d, "revno"), ud.url) |
128 | 128 | ||
129 | output = runfetchcmd(self._buildbzrcommand(ud, d, "revno"), d, True) | 129 | output = runfetchcmd(self._buildbzrcommand(ud, d, "revno"), d, True) |
130 | 130 | ||
diff --git a/bitbake/lib/bb/fetch2/cvs.py b/bitbake/lib/bb/fetch2/cvs.py index ae03daf236..12d11e0d5b 100644 --- a/bitbake/lib/bb/fetch2/cvs.py +++ b/bitbake/lib/bb/fetch2/cvs.py | |||
@@ -132,7 +132,7 @@ class Cvs(FetchMethod): | |||
132 | moddir = os.path.join(pkgdir, localdir) | 132 | moddir = os.path.join(pkgdir, localdir) |
133 | if os.access(os.path.join(moddir, 'CVS'), os.R_OK): | 133 | if os.access(os.path.join(moddir, 'CVS'), os.R_OK): |
134 | logger.info("Update " + loc) | 134 | logger.info("Update " + loc) |
135 | bb.fetch2.check_network_access(d, cvsupdatecmd) | 135 | bb.fetch2.check_network_access(d, cvsupdatecmd, ud.url) |
136 | # update sources there | 136 | # update sources there |
137 | os.chdir(moddir) | 137 | os.chdir(moddir) |
138 | cmd = cvsupdatecmd | 138 | cmd = cvsupdatecmd |
@@ -142,7 +142,7 @@ class Cvs(FetchMethod): | |||
142 | bb.mkdirhier(pkgdir) | 142 | bb.mkdirhier(pkgdir) |
143 | os.chdir(pkgdir) | 143 | os.chdir(pkgdir) |
144 | logger.debug(1, "Running %s", cvscmd) | 144 | logger.debug(1, "Running %s", cvscmd) |
145 | bb.fetch2.check_network_access(d, cvscmd) | 145 | bb.fetch2.check_network_access(d, cvscmd, ud.url) |
146 | cmd = cvscmd | 146 | cmd = cvscmd |
147 | 147 | ||
148 | runfetchcmd(cmd, d, cleanup = [moddir]) | 148 | runfetchcmd(cmd, d, cleanup = [moddir]) |
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py index 6d82bdc88b..f2c27e42a7 100644 --- a/bitbake/lib/bb/fetch2/git.py +++ b/bitbake/lib/bb/fetch2/git.py | |||
@@ -132,7 +132,7 @@ class Git(FetchMethod): | |||
132 | if not self._contains_ref(ud.revisions[name], d): | 132 | if not self._contains_ref(ud.revisions[name], d): |
133 | needupdate = True | 133 | needupdate = True |
134 | if needupdate: | 134 | if needupdate: |
135 | bb.fetch2.check_network_access(d, "git fetch %s%s" % (ud.host, ud.path)) | 135 | bb.fetch2.check_network_access(d, "git fetch %s%s" % (ud.host, ud.path), ud.url) |
136 | try: | 136 | try: |
137 | runfetchcmd("%s remote prune origin" % ud.basecmd, d) | 137 | runfetchcmd("%s remote prune origin" % ud.basecmd, d) |
138 | runfetchcmd("%s remote rm origin" % ud.basecmd, d) | 138 | runfetchcmd("%s remote rm origin" % ud.basecmd, d) |
diff --git a/bitbake/lib/bb/fetch2/hg.py b/bitbake/lib/bb/fetch2/hg.py index ac5825baa9..6a56f8d0cd 100644 --- a/bitbake/lib/bb/fetch2/hg.py +++ b/bitbake/lib/bb/fetch2/hg.py | |||
@@ -124,7 +124,7 @@ class Hg(FetchMethod): | |||
124 | # update sources there | 124 | # update sources there |
125 | os.chdir(ud.moddir) | 125 | os.chdir(ud.moddir) |
126 | logger.debug(1, "Running %s", updatecmd) | 126 | logger.debug(1, "Running %s", updatecmd) |
127 | bb.fetch2.check_network_access(d, updatecmd) | 127 | bb.fetch2.check_network_access(d, updatecmd, ud.url) |
128 | runfetchcmd(updatecmd, d) | 128 | runfetchcmd(updatecmd, d) |
129 | 129 | ||
130 | else: | 130 | else: |
@@ -134,7 +134,7 @@ class Hg(FetchMethod): | |||
134 | bb.mkdirhier(ud.pkgdir) | 134 | bb.mkdirhier(ud.pkgdir) |
135 | os.chdir(ud.pkgdir) | 135 | os.chdir(ud.pkgdir) |
136 | logger.debug(1, "Running %s", fetchcmd) | 136 | logger.debug(1, "Running %s", fetchcmd) |
137 | bb.fetch2.check_network_access(d, fetchcmd) | 137 | bb.fetch2.check_network_access(d, fetchcmd, ud.url) |
138 | runfetchcmd(fetchcmd, d) | 138 | runfetchcmd(fetchcmd, d) |
139 | 139 | ||
140 | # Even when we clone (fetch), we still need to update as hg's clone | 140 | # Even when we clone (fetch), we still need to update as hg's clone |
diff --git a/bitbake/lib/bb/fetch2/osc.py b/bitbake/lib/bb/fetch2/osc.py index f252b5e4a3..4bf411c24f 100644 --- a/bitbake/lib/bb/fetch2/osc.py +++ b/bitbake/lib/bb/fetch2/osc.py | |||
@@ -90,7 +90,7 @@ class Osc(FetchMethod): | |||
90 | # update sources there | 90 | # update sources there |
91 | os.chdir(ud.moddir) | 91 | os.chdir(ud.moddir) |
92 | logger.debug(1, "Running %s", oscupdatecmd) | 92 | logger.debug(1, "Running %s", oscupdatecmd) |
93 | bb.fetch2.check_network_access(d, oscupdatecmd) | 93 | bb.fetch2.check_network_access(d, oscupdatecmd, ud.url) |
94 | runfetchcmd(oscupdatecmd, d) | 94 | runfetchcmd(oscupdatecmd, d) |
95 | else: | 95 | else: |
96 | oscfetchcmd = self._buildosccommand(ud, d, "fetch") | 96 | oscfetchcmd = self._buildosccommand(ud, d, "fetch") |
@@ -99,7 +99,7 @@ class Osc(FetchMethod): | |||
99 | bb.mkdirhier(ud.pkgdir) | 99 | bb.mkdirhier(ud.pkgdir) |
100 | os.chdir(ud.pkgdir) | 100 | os.chdir(ud.pkgdir) |
101 | logger.debug(1, "Running %s", oscfetchcmd) | 101 | logger.debug(1, "Running %s", oscfetchcmd) |
102 | bb.fetch2.check_network_access(d, oscfetchcmd) | 102 | bb.fetch2.check_network_access(d, oscfetchcmd, ud.url) |
103 | runfetchcmd(oscfetchcmd, d) | 103 | runfetchcmd(oscfetchcmd, d) |
104 | 104 | ||
105 | os.chdir(os.path.join(ud.pkgdir + ud.path)) | 105 | os.chdir(os.path.join(ud.pkgdir + ud.path)) |
diff --git a/bitbake/lib/bb/fetch2/repo.py b/bitbake/lib/bb/fetch2/repo.py index 3b16fc0144..54130a8c3b 100644 --- a/bitbake/lib/bb/fetch2/repo.py +++ b/bitbake/lib/bb/fetch2/repo.py | |||
@@ -72,10 +72,10 @@ class Repo(FetchMethod): | |||
72 | bb.mkdirhier(os.path.join(codir, "repo")) | 72 | bb.mkdirhier(os.path.join(codir, "repo")) |
73 | os.chdir(os.path.join(codir, "repo")) | 73 | os.chdir(os.path.join(codir, "repo")) |
74 | if not os.path.exists(os.path.join(codir, "repo", ".repo")): | 74 | if not os.path.exists(os.path.join(codir, "repo", ".repo")): |
75 | bb.fetch2.check_network_access(d, "repo init -m %s -b %s -u %s://%s%s%s" % (ud.manifest, ud.branch, ud.proto, username, ud.host, ud.path)) | 75 | bb.fetch2.check_network_access(d, "repo init -m %s -b %s -u %s://%s%s%s" % (ud.manifest, ud.branch, ud.proto, username, ud.host, ud.path), ud.url) |
76 | runfetchcmd("repo init -m %s -b %s -u %s://%s%s%s" % (ud.manifest, ud.branch, ud.proto, username, ud.host, ud.path), d) | 76 | runfetchcmd("repo init -m %s -b %s -u %s://%s%s%s" % (ud.manifest, ud.branch, ud.proto, username, ud.host, ud.path), d) |
77 | 77 | ||
78 | bb.fetch2.check_network_access(d, "repo sync %s" % ud.url) | 78 | bb.fetch2.check_network_access(d, "repo sync %s" % ud.url, ud.url) |
79 | runfetchcmd("repo sync", d) | 79 | runfetchcmd("repo sync", d) |
80 | os.chdir(codir) | 80 | os.chdir(codir) |
81 | 81 | ||
diff --git a/bitbake/lib/bb/fetch2/ssh.py b/bitbake/lib/bb/fetch2/ssh.py index 2ee9ab093a..91ac15faae 100644 --- a/bitbake/lib/bb/fetch2/ssh.py +++ b/bitbake/lib/bb/fetch2/ssh.py | |||
@@ -114,7 +114,7 @@ class SSH(FetchMethod): | |||
114 | commands.mkarg(ldir) | 114 | commands.mkarg(ldir) |
115 | ) | 115 | ) |
116 | 116 | ||
117 | bb.fetch2.check_network_access(d, cmd) | 117 | bb.fetch2.check_network_access(d, cmd, urldata.url) |
118 | 118 | ||
119 | runfetchcmd(cmd, d) | 119 | runfetchcmd(cmd, d) |
120 | 120 | ||
diff --git a/bitbake/lib/bb/fetch2/svn.py b/bitbake/lib/bb/fetch2/svn.py index d05dc02765..ac4fd27e14 100644 --- a/bitbake/lib/bb/fetch2/svn.py +++ b/bitbake/lib/bb/fetch2/svn.py | |||
@@ -116,7 +116,7 @@ class Svn(FetchMethod): | |||
116 | # update sources there | 116 | # update sources there |
117 | os.chdir(ud.moddir) | 117 | os.chdir(ud.moddir) |
118 | logger.debug(1, "Running %s", svnupdatecmd) | 118 | logger.debug(1, "Running %s", svnupdatecmd) |
119 | bb.fetch2.check_network_access(d, svnupdatecmd) | 119 | bb.fetch2.check_network_access(d, svnupdatecmd, ud.url) |
120 | runfetchcmd(svnupdatecmd, d) | 120 | runfetchcmd(svnupdatecmd, d) |
121 | else: | 121 | else: |
122 | svnfetchcmd = self._buildsvncommand(ud, d, "fetch") | 122 | svnfetchcmd = self._buildsvncommand(ud, d, "fetch") |
@@ -125,7 +125,7 @@ class Svn(FetchMethod): | |||
125 | bb.mkdirhier(ud.pkgdir) | 125 | bb.mkdirhier(ud.pkgdir) |
126 | os.chdir(ud.pkgdir) | 126 | os.chdir(ud.pkgdir) |
127 | logger.debug(1, "Running %s", svnfetchcmd) | 127 | logger.debug(1, "Running %s", svnfetchcmd) |
128 | bb.fetch2.check_network_access(d, svnfetchcmd) | 128 | bb.fetch2.check_network_access(d, svnfetchcmd, ud.url) |
129 | runfetchcmd(svnfetchcmd, d) | 129 | runfetchcmd(svnfetchcmd, d) |
130 | 130 | ||
131 | scmdata = ud.parm.get("scmdata", "") | 131 | scmdata = ud.parm.get("scmdata", "") |