@@ -22,10 +22,25 @@ from bb.fetch2.wget import Wget
class Crate(Wget):
"""Class to fetch crates via wget"""
+ using_crates_io = False
def _cargo_bitbake_path(self, rootdir):
return os.path.join(rootdir, "cargo_home", "bitbake")
+ def identify_as_bitbake(self):
+ """
+ Should wget identify as bitbake?
+ """
+ # In order to comply with the data access policy of crates.io, a
+ # user-agent with application and contact information should be used:
+ #
+ # https://crates.io/data-access
+ if self.using_crates_io:
+ return True
+ else:
+ # Default to whatever Wget think is proper
+ return super(Crate, self).identify_as_bitbake()
+
def supports(self, ud, d):
"""
Check to see if a given url is for this fetcher
@@ -65,10 +80,11 @@ class Crate(Wget):
# host (this is to allow custom crate registries to be specified
host = '/'.join(parts[2:-2])
- # if using upstream just fix it up nicely
+ # if using upstream fix it up nicely and make sure user-agent is set
if host == 'crates.io':
host = 'crates.io/api/v1/crates'
cdn_host = 'static.crates.io/crates'
+ self.using_crates_io = True
else:
cdn_host = host
In order to adhere to the data access policy of crates.io, a user-agent header that identifies the application must be used. Reference: https://github.com/rust-lang/crates.io/issues/13482 Reference: https://crates.io/data-access Signed-off-by: Johan Anderholm <johanam@axis.com> --- lib/bb/fetch2/crate.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)