Skip to contentSkip to conversation

fetch2/crate: Unpack into CARGO_VENDORING_DIRECTORY

PATCH In review Alex Kiernan 2 participants 4 messages Dec 30, 2023 – Dec 31, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fetch2/crate: Unpack into CARGO_VENDORING_DIRECTORY

The vendor directory is set in cargo_common, to work with rust 1.75.0 we need to change the location, so use CARGO_VENDORING_DIRECTORY here.

---
Is this change allowed, or am I coupling repos in a bad way and should hardcode registry/src (which is what I need it to be) here instead?

 bitbake/lib/bb/fetch2/crate.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
bitbake/lib/bb/fetch2/crate.py +4 -4
index 01d49435c3e8..06963294ef35 100644
@@ -23,8 +23,8 @@ class Crate(Wget):
 
     """Class to fetch crates via wget"""
 
-    def _cargo_bitbake_path(self, rootdir):
-        return os.path.join(rootdir, "cargo_home", "bitbake")
+    def _cargo_bitbake_path(self, d):
+        return d.getVar('CARGO_VENDORING_DIRECTORY')
 
     def supports(self, ud, d):
         """
@@ -103,7 +103,7 @@ class Crate(Wget):
             cmd = "tar -xz --no-same-owner -f %s" % thefile
             ud.unpack_tracer.unpack("crate-extract", rootdir)
         else:
-            cargo_bitbake = self._cargo_bitbake_path(rootdir)
+            cargo_bitbake = self._cargo_bitbake_path(d)
             ud.unpack_tracer.unpack("cargo-extract", cargo_bitbake)
 
             cmd = "tar -xz --no-same-owner -f %s -C %s" % (thefile, cargo_bitbake)
@@ -134,7 +134,7 @@ class Crate(Wget):
         # if we have metadata to write out..
         if len(metadata) > 0:
             cratepath = os.path.splitext(os.path.basename(thefile))[0]
-            bbpath = self._cargo_bitbake_path(rootdir)
+            bbpath = self._cargo_bitbake_path(d)
             mdfile = '.cargo-checksum.json'
             mdpath = os.path.join(bbpath, cratepath, mdfile)
             with open(mdpath, "w") as f:
Signature · 1 line
2.39.0
#1 lore raw
Quoted 6 lines · Alex Kiernan

The vendor directory is set in cargo_common, to work with rust 1.75.0 we need to change the location, so use CARGO_VENDORING_DIRECTORY here.

---
Is this change allowed, or am I coupling repos in a bad way and should hardcode registry/src (which is what I need it to be) here instead?

We really need to find a better way. Bitbake isn't supposed to have "knowledge" of OE-Core outside the key variables it expects from bitbake.conf. CARGO* from class files aren't included in that.

What we probably should do is set this in bitbake in the fetcher and then read the value in OE-Core.

Cheers,

Richard

#2 lore raw
Quoted 9 lines · Richard Purdie
Quoted 6 lines · Alex Kiernan

The vendor directory is set in cargo_common, to work with rust 1.75.0 we need to change the location, so use CARGO_VENDORING_DIRECTORY here.

---
Is this change allowed, or am I coupling repos in a bad way and should hardcode registry/src (which is what I need it to be) here instead?

Quoted 7 lines

We really need to find a better way. Bitbake isn't supposed to have "knowledge" of OE-Core outside the key variables it expects from bitbake.conf. CARGO* from class files aren't included in that.

What we probably should do is set this in bitbake in the fetcher and then read the value in OE-Core.

Thanks, that makes sense. In fact if we can move the generation of the cargo vendor fragment into the fetcher then I think we isolate the details of our implementation in one place; I'll see if that works.

Signature · 1 line
Alex Kiernan
#3 lore raw
In reply to Alex Kiernan
Quoted 35 lines · Alex Kiernan

The vendor directory is set in cargo_common, to work with rust 1.75.0 we need to change the location, so use CARGO_VENDORING_DIRECTORY here.

---
Is this change allowed, or am I coupling repos in a bad way and should hardcode registry/src (which is what I need it to be) here instead?

 bitbake/lib/bb/fetch2/crate.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
bitbake/lib/bb/fetch2/crate.py +3 -3
index 01d49435c3e8..06963294ef35 100644
@@ -23,8 +23,8 @@ class Crate(Wget):
 
     """Class to fetch crates via wget"""
 
-    def _cargo_bitbake_path(self, rootdir):
-        return os.path.join(rootdir, "cargo_home", "bitbake")
+    def _cargo_bitbake_path(self, d):
+        return d.getVar('CARGO_VENDORING_DIRECTORY')
 
     def supports(self, ud, d):
         """
@@ -103,7 +103,7 @@ class Crate(Wget):
             cmd = "tar -xz --no-same-owner -f %s" % thefile
             ud.unpack_tracer.unpack("crate-extract", rootdir)
         else:
-            cargo_bitbake = self._cargo_bitbake_path(rootdir)
+            cargo_bitbake = self._cargo_bitbake_path(d)
             ud.unpack_tracer.unpack("cargo-extract", cargo_bitbake)
 
             cmd = "tar -xz --no-same-owner -f %s -C %s" % (thefile, cargo_bitbake)

bitbake/lib/bb/fetch2/crate.py class Crate(Wget): · line 140

Quoted 8 lines
bitbake/lib/bb/fetch2/crate.py +1 -1
@@ -134,7 +134,7 @@ class Crate(Wget):
         # if we have metadata to write out..
         if len(metadata) > 0:
             cratepath = os.path.splitext(os.path.basename(thefile))[0]
-            bbpath = self._cargo_bitbake_path(rootdir)
+            bbpath = self._cargo_bitbake_path(d)
             mdfile = '.cargo-checksum.json'
             mdpath = os.path.join(bbpath, cratepath, mdfile)
             with open(mdpath, "w") as f:

FWIW this also breaks bitbake-selftest:

https://autobuilder.yoctoproject.org/typhoon/#/builders/87/builds/6261/steps/11/logs/stdio

Cheers,

Richard