All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/13] cargo-update-recipe-crates.bbclass: add a class to generate SRC_URI crate lists from Cargo.lock
@ 2022-10-31 11:47 Alexander Kanavin
  2022-10-31 11:47 ` [PATCH 02/13] python3-bcrypt: convert to use cargo-update-recipe-crates class Alexander Kanavin
                   ` (12 more replies)
  0 siblings, 13 replies; 28+ messages in thread
From: Alexander Kanavin @ 2022-10-31 11:47 UTC (permalink / raw)
  To: openembedded-core; +Cc: Alexander Kanavin

For better or worse, more and more rust components are appearing that do
not include their dependencies in tarballs (or git trees), and rely on cargo
to fetch them. On the other hand, bitbake does not use cargo (and quite possible
won't ever be able to), and relies on having each item explicitly listed in SRC_URI
with a crate:// prefix. This however creates a problem of both making such lists in
the first place and updating them when a recipe is updated to a newer version.

So this class can be used to perform such updates by implementing a task that does it;
the next commit shows the outcome for python3-bcrypt (which has been tested to work
and produce a successful build).

Note: the python script relies on tomllib library, which appears in Python 3.11 and
does not exist in earlier versions - I've tested this by first updating python to 3.11-rc2
in oe-core.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 .../cargo-update-recipe-crates.bbclass        | 41 +++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 meta/classes-recipe/cargo-update-recipe-crates.bbclass

diff --git a/meta/classes-recipe/cargo-update-recipe-crates.bbclass b/meta/classes-recipe/cargo-update-recipe-crates.bbclass
new file mode 100644
index 0000000000..f90938c734
--- /dev/null
+++ b/meta/classes-recipe/cargo-update-recipe-crates.bbclass
@@ -0,0 +1,41 @@
+#
+# Copyright OpenEmbedded Contributors
+#
+# SPDX-License-Identifier: MIT
+#
+
+##
+## Purpose:
+## This class is used to update the list of crates in SRC_URI
+## by reading Cargo.lock in the source tree.
+##
+## See meta/recipes-devtools/python/python3-bcrypt_*.bb for an example
+##
+## To perform the update: bitbake -c update_crates recipe-name
+
+addtask do_update_crates after do_patch
+do_update_crates[depends] = "python3-native:do_populate_sysroot"
+
+do_update_crates() {
+    nativepython3 - <<EOF
+
+def get_crates(f):
+    import tomllib
+    c_list = 'SRC_URI += " \\ \n'
+    crates = tomllib.load(open(f, 'rb'))
+    for c in crates['package']:
+        if 'source' in c and 'crates.io' in c['source']:
+            c_list += "        crate://crates.io/{}/{} \\ \n".format(c['name'], c['version'])
+    c_list += '"\n'
+    return c_list
+
+import os
+crates = "# Autogenerated with 'bitbake -c update_crates ${PN}'\n\n"
+for root, dirs, files in os.walk('${S}'):
+    for file in files:
+        if file == 'Cargo.lock':
+            crates += get_crates(os.path.join(root, file))
+open(os.path.join('${THISDIR}', '${PN}'+"-crates.inc"), 'w').write(crates)
+
+EOF
+}
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2022-12-12 15:00 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-31 11:47 [PATCH 01/13] cargo-update-recipe-crates.bbclass: add a class to generate SRC_URI crate lists from Cargo.lock Alexander Kanavin
2022-10-31 11:47 ` [PATCH 02/13] python3-bcrypt: convert to use cargo-update-recipe-crates class Alexander Kanavin
2022-10-31 11:47 ` [PATCH 03/13] python3-cryptography: convert to " Alexander Kanavin
2022-10-31 11:47 ` [PATCH 04/13] groff: submit patches upstream Alexander Kanavin
2022-10-31 11:47 ` [PATCH 05/13] tcl: correct patch status Alexander Kanavin
2022-10-31 11:47 ` [PATCH 06/13] tcl: correct upstream version check Alexander Kanavin
2022-10-31 11:47 ` [PATCH 07/13] lttng-tools: submit determinism.patch upstream Alexander Kanavin
2022-10-31 11:47 ` [PATCH 08/13] cmake: drop qt4 patches Alexander Kanavin
2022-10-31 11:47 ` [PATCH 09/13] kea: submit patch upstream Alexander Kanavin
2022-10-31 11:47 ` [PATCH 10/13] argp-standalone: replace with a maintained fork Alexander Kanavin
2022-10-31 11:47 ` [PATCH 11/13] ovmf: correct patches status Alexander Kanavin
2022-10-31 11:47 ` [PATCH 12/13] go: submit patch upstream Alexander Kanavin
2022-10-31 21:55   ` [OE-core] " Richard Purdie
2022-10-31 22:17     ` Alexander Kanavin
2022-10-31 11:47 ` [PATCH 13/13] libffi: " Alexander Kanavin
2022-12-06 23:04 ` [OE-core] [PATCH 01/13] cargo-update-recipe-crates.bbclass: add a class to generate SRC_URI crate lists from Cargo.lock Randy MacLeod
2022-12-07  0:20   ` Sergey 'Jin' Bostandzhyan
2022-12-07  8:53     ` Alexander Kanavin
2022-12-07 15:28       ` Stefan Herbrechtsmeier
2022-12-07 16:21         ` Alexander Kanavin
2022-12-09 10:39           ` Stefan Herbrechtsmeier
2022-12-09 12:01             ` Richard Purdie
2022-12-09 14:43               ` Alexander Kanavin
2022-12-09 14:58                 ` Richard Purdie
2022-12-09 15:18               ` Stefan Herbrechtsmeier
2022-12-09 12:09             ` Alexander Kanavin
2022-12-12 14:18               ` Stefan Herbrechtsmeier
2022-12-12 15:00                 ` Alexander Kanavin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.