summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorChristophe Priouzeau <christophe.priouzeau@st.com>2021-01-20 11:13:06 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-08-22 15:42:30 +0100
commitfc24cd1948121033629fcbe60baf56ba9adb9c9c (patch)
treef9901e633f2f5f975d44a1aef3798fbccc63f792 /bitbake
parent1fc880e1658d43bf1310260762eea7018678d91d (diff)
downloadpoky-fc24cd1948121033629fcbe60baf56ba9adb9c9c.tar.gz
bitbake: fetch2/wget: Update user-agent
With the usage of enterprise proxy, the user-agent defined are too old and refused by proxy configuration. Updating to something more modern is desirable. (Bitbake rev: 17be38290d1e971cd89785e6bf44caef0a6416f8) Signed-off-by: Christophe Priouzeau <christophe.priouzeau@st.com> Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 7001fdd7c4dca372cbebd8fd2c0b03c5d43f9400) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/fetch2/wget.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/bitbake/lib/bb/fetch2/wget.py b/bitbake/lib/bb/fetch2/wget.py
index d208f5ee2f..368c644337 100644
--- a/bitbake/lib/bb/fetch2/wget.py
+++ b/bitbake/lib/bb/fetch2/wget.py
@@ -52,6 +52,12 @@ class WgetProgressHandler(bb.progress.LineFilterProgressHandler):
52 52
53 53
54class Wget(FetchMethod): 54class Wget(FetchMethod):
55
56 # CDNs like CloudFlare may do a 'browser integrity test' which can fail
57 # with the standard wget/urllib User-Agent, so pretend to be a modern
58 # browser.
59 user_agent = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0"
60
55 """Class to fetch urls via 'wget'""" 61 """Class to fetch urls via 'wget'"""
56 def supports(self, ud, d): 62 def supports(self, ud, d):
57 """ 63 """
@@ -303,7 +309,7 @@ class Wget(FetchMethod):
303 # Some servers (FusionForge, as used on Alioth) require that the 309 # Some servers (FusionForge, as used on Alioth) require that the
304 # optional Accept header is set. 310 # optional Accept header is set.
305 r.add_header("Accept", "*/*") 311 r.add_header("Accept", "*/*")
306 r.add_header("User-Agent", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.12) Gecko/20101027 Ubuntu/9.10 (karmic) Firefox/3.6.12") 312 r.add_header("User-Agent", self.user_agent)
307 def add_basic_auth(login_str, request): 313 def add_basic_auth(login_str, request):
308 '''Adds Basic auth to http request, pass in login:password as string''' 314 '''Adds Basic auth to http request, pass in login:password as string'''
309 import base64 315 import base64
@@ -407,9 +413,8 @@ class Wget(FetchMethod):
407 """ 413 """
408 f = tempfile.NamedTemporaryFile() 414 f = tempfile.NamedTemporaryFile()
409 with tempfile.TemporaryDirectory(prefix="wget-index-") as workdir, tempfile.NamedTemporaryFile(dir=workdir, prefix="wget-listing-") as f: 415 with tempfile.TemporaryDirectory(prefix="wget-index-") as workdir, tempfile.NamedTemporaryFile(dir=workdir, prefix="wget-listing-") as f:
410 agent = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.12) Gecko/20101027 Ubuntu/9.10 (karmic) Firefox/3.6.12"
411 fetchcmd = self.basecmd 416 fetchcmd = self.basecmd
412 fetchcmd += " -O " + f.name + " --user-agent='" + agent + "' '" + uri + "'" 417 fetchcmd += " -O " + f.name + " --user-agent='" + self.user_agent + "' '" + uri + "'"
413 try: 418 try:
414 self._runwget(ud, d, fetchcmd, True, workdir=workdir) 419 self._runwget(ud, d, fetchcmd, True, workdir=workdir)
415 fetchresult = f.read() 420 fetchresult = f.read()