cargo-update-recipe-crates.bbclass: add a class to generate SRC_URI crate lists from Cargo.lock
PATCH 1/13 cargo-update-recipe-crates.bbclass: add a class to generate SRC_URI crate lists from Cargo.lock
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.
--- .../cargo-update-recipe-crates.bbclass | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 meta/classes-recipe/cargo-update-recipe-crates.bbclass
meta/classes-recipe/cargo-update-recipe-crates.bbclass new file +41 -0
@@ -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 +}
Signature · 1 line
2.30.2
PATCH 2/13 python3-bcrypt: convert to use cargo-update-recipe-crates class.
The component has been reimplemented in rust, and comes with a large list of dependencies in Cargo.toml/Cargo.lock.
Rather than list them by hand, use a file generated with cargo-update-recipe-crates class.
--- .../python/python3-bcrypt-crates.inc | 53 ++++++++++++++++++ .../python/python3-bcrypt_4.0.0.bb | 55 ++----------------- 2 files changed, 57 insertions(+), 51 deletions(-) create mode 100644 meta/recipes-devtools/python/python3-bcrypt-crates.inc
meta/recipes-devtools/python/python3-bcrypt-crates.inc new file +53 -0
@@ -0,0 +1,53 @@ +# Autogenerated with 'bitbake -c update_crates python3-bcrypt' + +SRC_URI += " \ + crate://crates.io/autocfg/1.1.0 \ + crate://crates.io/base64/0.13.0 \ + crate://crates.io/bcrypt/0.13.0 \ + crate://crates.io/bcrypt-pbkdf/0.8.1 \ + crate://crates.io/bitflags/1.3.2 \ + crate://crates.io/block-buffer/0.10.2 \ + crate://crates.io/blowfish/0.9.1 \ + crate://crates.io/byteorder/1.4.3 \ + crate://crates.io/cfg-if/1.0.0 \ + crate://crates.io/cipher/0.4.3 \ + crate://crates.io/cpufeatures/0.2.4 \ + crate://crates.io/crypto-common/0.1.6 \ + crate://crates.io/digest/0.10.3 \ + crate://crates.io/generic-array/0.14.6 \ + crate://crates.io/getrandom/0.2.7 \ + crate://crates.io/indoc/0.3.6 \ + crate://crates.io/indoc-impl/0.3.6 \ + crate://crates.io/inout/0.1.3 \ + crate://crates.io/instant/0.1.12 \ + crate://crates.io/libc/0.2.132 \ + crate://crates.io/lock_api/0.4.7 \ + crate://crates.io/once_cell/1.13.1 \ + crate://crates.io/parking_lot/0.11.2 \ + crate://crates.io/parking_lot_core/0.8.5 \ + crate://crates.io/paste/0.1.18 \ + crate://crates.io/paste-impl/0.1.18 \ + crate://crates.io/pbkdf2/0.10.1 \ + crate://crates.io/proc-macro-hack/0.5.19 \ + crate://crates.io/proc-macro2/1.0.43 \ + crate://crates.io/pyo3/0.15.2 \ + crate://crates.io/pyo3-build-config/0.15.2 \ + crate://crates.io/pyo3-macros/0.15.2 \ + crate://crates.io/pyo3-macros-backend/0.15.2 \ + crate://crates.io/quote/1.0.21 \ + crate://crates.io/redox_syscall/0.2.16 \ + crate://crates.io/scopeguard/1.1.0 \ + crate://crates.io/sha2/0.10.2 \ + crate://crates.io/smallvec/1.9.0 \ + crate://crates.io/subtle/2.4.1 \ + crate://crates.io/syn/1.0.99 \ + crate://crates.io/typenum/1.15.0 \ + crate://crates.io/unicode-ident/1.0.3 \ + crate://crates.io/unindent/0.1.10 \ + crate://crates.io/version_check/0.9.4 \ + crate://crates.io/wasi/0.11.0+wasi-snapshot-preview1 \ + crate://crates.io/winapi/0.3.9 \ + crate://crates.io/winapi-i686-pc-windows-gnu/0.4.0 \ + crate://crates.io/winapi-x86_64-pc-windows-gnu/0.4.0 \ + crate://crates.io/zeroize/1.5.7 \ +"
meta/recipes-devtools/python/python3-bcrypt_4.0.0.bb +4 -51
65 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH 3/13 python3-cryptography: convert to cargo-update-recipe-crates class
In reply to Alexander KanavinThis allows semi-automated updates to the list of crates, which is far too awkward to maintain by hand, particularly on version updates.
--- .../python/python3-cryptography-crates.inc | 58 +++++++++++++++++++ .../python/python3-cryptography_38.0.1.bb | 58 +------------------ 2 files changed, 61 insertions(+), 55 deletions(-) create mode 100644 meta/recipes-devtools/python/python3-cryptography-crates.inc
meta/recipes-devtools/python/python3-cryptography-crates.inc new file +58 -0
@@ -0,0 +1,58 @@ +# Autogenerated with 'bitbake -c update_crates python3-cryptography' + +SRC_URI += " \ + crate://crates.io/Inflector/0.11.4 \ + crate://crates.io/aliasable/0.1.3 \ + crate://crates.io/android_system_properties/0.1.5 \ + crate://crates.io/asn1/0.12.2 \ + crate://crates.io/asn1_derive/0.12.2 \ + crate://crates.io/autocfg/1.1.0 \ + crate://crates.io/base64/0.13.0 \ + crate://crates.io/bitflags/1.3.2 \ + crate://crates.io/bumpalo/3.10.0 \ + crate://crates.io/cfg-if/1.0.0 \ + crate://crates.io/chrono/0.4.22 \ + crate://crates.io/core-foundation-sys/0.8.3 \ + crate://crates.io/iana-time-zone/0.1.47 \ + crate://crates.io/indoc/0.3.6 \ + crate://crates.io/indoc-impl/0.3.6 \ + crate://crates.io/instant/0.1.12 \ + crate://crates.io/js-sys/0.3.59 \ + crate://crates.io/libc/0.2.132 \ + crate://crates.io/lock_api/0.4.8 \ + crate://crates.io/log/0.4.17 \ + crate://crates.io/num-integer/0.1.45 \ + crate://crates.io/num-traits/0.2.15 \ + crate://crates.io/once_cell/1.14.0 \ + crate://crates.io/ouroboros/0.15.4 \ + crate://crates.io/ouroboros_macro/0.15.4 \ + crate://crates.io/parking_lot/0.11.2 \ + crate://crates.io/parking_lot_core/0.8.5 \ + crate://crates.io/paste/0.1.18 \ + crate://crates.io/paste-impl/0.1.18 \ + crate://crates.io/pem/1.1.0 \ + crate://crates.io/proc-macro-error/1.0.4 \ + crate://crates.io/proc-macro-error-attr/1.0.4 \ + crate://crates.io/proc-macro-hack/0.5.19 \ + crate://crates.io/proc-macro2/1.0.43 \ + crate://crates.io/pyo3/0.15.2 \ + crate://crates.io/pyo3-build-config/0.15.2 \ + crate://crates.io/pyo3-macros/0.15.2 \ + crate://crates.io/pyo3-macros-backend/0.15.2 \ + crate://crates.io/quote/1.0.21 \ + crate://crates.io/redox_syscall/0.2.16 \ + crate://crates.io/scopeguard/1.1.0 \ + crate://crates.io/smallvec/1.9.0 \ + crate://crates.io/syn/1.0.99 \ + crate://crates.io/unicode-ident/1.0.3 \ + crate://crates.io/unindent/0.1.10 \ + crate://crates.io/version_check/0.9.4 \ + crate://crates.io/wasm-bindgen/0.2.82 \ + crate://crates.io/wasm-bindgen-backend/0.2.82 \ + crate://crates.io/wasm-bindgen-macro/0.2.82 \ + crate://crates.io/wasm-bindgen-macro-support/0.2.82 \ + crate://crates.io/wasm-bindgen-shared/0.2.82 \ + crate://crates.io/winapi/0.3.9 \ + crate://crates.io/winapi-i686-pc-windows-gnu/0.4.0 \ + crate://crates.io/winapi-x86_64-pc-windows-gnu/0.4.0 \ +"
meta/recipes-devtools/python/python3-cryptography_38.0.1.bb +3 -55
66 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH 4/13 groff: submit patches upstream
In reply to Alexander Kanavin--- .../groff/files/0001-Make-manpages-mulitlib-identical.patch | 2 +- .../groff/files/0001-replace-perl-w-with-use-warnings.patch | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
meta/recipes-extended/groff/files/0001-Make-manpages-mulitlib-identical.patch +1 -1
@@ -3,7 +3,7 @@ From: Jeremy Puhlman <[email protected]> Date: Sat, 7 Mar 2020 00:59:13 +0000 Subject: [PATCH] Make manpages mulitlib identical -Upstream-Status: Pending +Upstream-Status: Submitted [by email to [email protected]] Signed-off-by: Jeremy Puhlman <[email protected]> --- Makefile.am | 2 +-
meta/recipes-extended/groff/files/0001-replace-perl-w-with-use-warnings.patch +1 -1
@@ -15,7 +15,7 @@ doesn't work: So replace "perl -w" with "use warnings" to make it work. -Upstream-Status: Pending +Upstream-Status: Submitted [by email to [email protected]] Signed-off-by: Robert Yang <[email protected]>
Signature · 1 line
2.30.2
PATCH 5/13 tcl: correct patch status
In reply to Alexander Kanavin--- .../recipes-devtools/tcltk/tcl/fix_non_native_build_issue.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/tcltk/tcl/fix_non_native_build_issue.patch +1 -1
@@ -1,4 +1,4 @@ -Upstream-Status: Pending +Upstream-Status: Inappropriate [upstream does not support installed tests] Index: unix/Makefile.in ===================================================================
Signature · 1 line
2.30.2
PATCH 6/13 tcl: correct upstream version check
In reply to Alexander KanavinSourceforge does not report the latest version reliably.
--- meta/recipes-devtools/tcltk/tcl_8.6.11.bb | 1 + 1 file changed, 1 insertion(+)
meta/recipes-devtools/tcltk/tcl_8.6.11.bb +1 -0
@@ -33,6 +33,7 @@ SRC_URI:class-native = "${BASE_SRC_URI}" # https://core.tcl-lang.org/tcl/info/7079e4f91601e9c7 CVE_CHECK_IGNORE += "CVE-2021-35331" +UPSTREAM_CHECK_URI = "https://www.tcl.tk/software/tcltk/download.html" UPSTREAM_CHECK_REGEX = "tcl(?P<pver>\d+(\.\d+)+)-src" S = "${WORKDIR}/${BPN}${PV}"
Signature · 1 line
2.30.2
PATCH 7/13 lttng-tools: submit determinism.patch upstream
In reply to Alexander Kanavin--- meta/recipes-kernel/lttng/lttng-tools/determinism.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-kernel/lttng/lttng-tools/determinism.patch +1 -1
@@ -13,7 +13,7 @@ to me whether the tests need that or not. Fixes reproducibility issues for lttng-tools. -Upstream-Status: Pending [needs discussion with upstream about the correct solution] +Upstream-Status: Submitted [https://bugs.lttng.org/issues/1361 - needs discussion with upstream about the correct solution] RP 2021/3/1 Index: lttng-tools-2.12.2/tests/regression/ust/ust-dl/Makefile.am
Signature · 1 line
2.30.2
PATCH 8/13 cmake: drop qt4 patches
In reply to Alexander KanavinQt4 has been dead for a very long time now.
--- meta/recipes-devtools/cmake/cmake.inc | 2 - ...t-OpenEmbedded-Qt4-tool-binary-names.patch | 56 ------------- ...-if-system-Qt-installation-is-broken.patch | 79 ------------------- 3 files changed, 137 deletions(-) delete mode 100644 meta/recipes-devtools/cmake/cmake/0003-cmake-support-OpenEmbedded-Qt4-tool-binary-names.patch delete mode 100644 meta/recipes-devtools/cmake/cmake/0004-Fail-silently-if-system-Qt-installation-is-broken.patch
meta/recipes-devtools/cmake/cmake.inc +0 -2
@@ -17,8 +17,6 @@ LIC_FILES_CHKSUM = "file://Copyright.txt;md5=45025187a129339459b6f1a24f7fac6e \ CMAKE_MAJOR_VERSION = "${@'.'.join(d.getVar('PV').split('.')[0:2])}" SRC_URI = "https://cmake.org/files/v${CMAKE_MAJOR_VERSION}/cmake-${PV}.tar.gz \ - file://0003-cmake-support-OpenEmbedded-Qt4-tool-binary-names.patch \ - file://0004-Fail-silently-if-system-Qt-installation-is-broken.patch \ " SRC_URI[sha256sum] = "0d9020f06f3ddf17fb537dc228e1a56c927ee506b486f55fe2dc19f69bf0c8db"
meta/recipes-devtools/cmake/cmake/0003-cmake-support-OpenEmbedded-Qt4-tool-binary-names.patch deleted +0 -56
56 lines not on this page · raw message
meta/recipes-devtools/cmake/cmake/0004-Fail-silently-if-system-Qt-installation-is-broken.patch deleted +0 -79
79 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH 9/13 kea: submit patch upstream
In reply to Alexander Kanavin--- meta/recipes-connectivity/kea/files/fix-multilib-conflict.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-connectivity/kea/files/fix-multilib-conflict.patch +1 -1
@@ -12,7 +12,7 @@ Subject: [PATCH] There are conflict of config files between kea and lib32-kea: Because they are all commented out, replace the expanded libdir path with '$libdir' in the config files to avoid conflict. -Upstream-Status: Pending +Upstream-Status: Submitted [https://gitlab.isc.org/isc-projects/kea/-/issues/2602] Signed-off-by: Kai Kang <[email protected]> ---
Signature · 1 line
2.30.2
PATCH 10/13 argp-standalone: replace with a maintained fork
In reply to Alexander KanavinRemove two patches as issues fixed upstream,
submit the third one.
License-Update: argp.h is an import from glibc and has been refreshed to the latest version. It's still lgpl 2.1.
---
...dalone_1.3.bb => argp-standalone_1.4.1.bb} | 12 ++-
.../files/0001-throw-in-funcdef.patch | 84 -------------------
.../argp-standalone/files/0002-isprint.patch | 51 -----------
.../files/out_of_tree_build.patch | 2 +-
4 files changed, 6 insertions(+), 143 deletions(-)
rename meta/recipes-support/argp-standalone/{argp-standalone_1.3.bb => argp-standalone_1.4.1.bb} (59%)
delete mode 100644 meta/recipes-support/argp-standalone/files/0001-throw-in-funcdef.patch
delete mode 100644 meta/recipes-support/argp-standalone/files/0002-isprint.patchmeta/recipes-support/argp-standalone/argp-standalone_1.4.1.bb renamed from meta/recipes-support/argp-standalone/argp-standalone_1.3.bb +5 -7
@@ -3,18 +3,16 @@ SUMMARY = "Glibc hierarchical argument parsing standalone library" DESCRIPTION = "Standalone version of arguments parsing functions from GLIBC" -HOMEPAGE = "http://www.lysator.liu.se/~nisse/misc/" +HOMEPAGE = "https://github.com/ericonr/argp-standalone" LICENSE = "LGPL-2.1-only" -LIC_FILES_CHKSUM = "file://argp.h;beginline=1;endline=20;md5=008b7e53dea6f9e1d9fdef0d9cf3184a" +LIC_FILES_CHKSUM = "file://argp.h;beginline=1;endline=20;md5=464f2cfb1c35a5123f9e309d7afd79f8" SECTION = "libs" -SRC_URI = "http://www.lysator.liu.se/~nisse/misc/argp-standalone-${PV}.tar.gz \ - file://0001-throw-in-funcdef.patch \ - file://0002-isprint.patch \ +SRC_URI = "git://github.com/ericonr/argp-standalone;branch=master;protocol=https \ file://out_of_tree_build.patch \ " -SRC_URI[md5sum] = "720704bac078d067111b32444e24ba69" -SRC_URI[sha256sum] = "dec79694da1319acd2238ce95df57f3680fea2482096e483323fddf3d818d8be" +SRCREV = "e5fe9ad9e83e6765cf8fa787f903d4c6792338b5" +S = "${WORKDIR}/git" inherit autotools
meta/recipes-support/argp-standalone/files/0001-throw-in-funcdef.patch deleted +0 -84
84 lines not on this page · raw message
meta/recipes-support/argp-standalone/files/0002-isprint.patch deleted +0 -51
51 lines not on this page · raw message
meta/recipes-support/argp-standalone/files/out_of_tree_build.patch +1 -1
@@ -2,7 +2,7 @@ Fix the testsuite to built out of tree in OE S != B Signed-off-by: Khem Raj <[email protected]> -Upstream-Status: Pending +Upstream-Status: Submitted [https://github.com/ericonr/argp-standalone/pull/9] Index: argp-standalone-1.3/testsuite/Makefile.am =================================================================== --- argp-standalone-1.3.orig/testsuite/Makefile.am
Signature · 1 line
2.30.2
PATCH 11/13 ovmf: correct patches status
In reply to Alexander Kanavin--- .../ovmf/0001-ovmf-update-path-to-native-BaseTools.patch | 2 +- ...seTools-makefile-adjust-to-build-in-under-bitbake.patch | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-)
meta/recipes-core/ovmf/ovmf/0001-ovmf-update-path-to-native-BaseTools.patch +1 -1
@@ -10,7 +10,7 @@ tools. The BBAKE_EDK_TOOLS_PATH string is used as a pattern to be replaced with the appropriate location before building. Signed-off-by: Ricardo Neri <[email protected]> -Upstream-Status: Pending +Upstream-Status: Inappropriate [oe-core cross compile specific] --- OvmfPkg/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-core/ovmf/ovmf/0002-BaseTools-makefile-adjust-to-build-in-under-bitbake.patch +6 -1
@@ -6,8 +6,13 @@ Subject: [PATCH 2/6] BaseTools: makefile: adjust to build in under bitbake Prepend the build flags with those of bitbake. This is to build using the bitbake native sysroot include and library directories. +Note from Alex: this is not appropriate for upstream submission as +the recipe already does lots of similar in-place fixups elsewhere, so +this patch shold be converted to follow that pattern. We're not going +to fight against how upstream wants to configure the build. + Signed-off-by: Ricardo Neri <[email protected]> -Upstream-Status: Pending +Upstream-Status: Inappropriate [needs to be converted to in-recipe fixups] --- BaseTools/Source/C/Makefiles/header.makefile | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
Signature · 1 line
2.30.2
PATCH 12/13 go: submit patch upstream
In reply to Alexander KanavinNote: it will not be reviewed until RP signs the google CLA (link in the PR).
--- meta/recipes-devtools/go/go/filter-build-paths.patch | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
meta/recipes-devtools/go/go/filter-build-paths.patch +3 -1
@@ -8,7 +8,9 @@ embedded in the go binary so that builds are reproducible regardless of build location. This codepath is hit for statically linked go binaries such as those on mips/ppc. -Upstream-Status: Pending +Upstream-Status: Submitted [https://github.com/golang/go/pull/56410] +Note: RP needs to sign Google CLA for the PR to proceed. + Signed-off-by: Richard Purdie <[email protected]> ---
Signature · 1 line
2.30.2
Re: [OE-core] [PATCH 12/13] go: submit patch upstream
Quoted 13 lines · Alexander Kanavin
Note: it will not be reviewed until RP signs the google CLA (link in the PR).
Signed-off-by Alexander Kanavin <[email protected]>--- meta/recipes-devtools/go/go/filter-build-paths.patch | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)meta/recipes-devtools/go/go/filter-build-paths.patch +0
-0
meta/recipes-devtools/go/go/filter-build-paths.patch embedded in the go binary so that builds are reproducible regardless of build · line 13
Quoted 7 lines
meta/recipes-devtools/go/go/filter-build-paths.patch +3
-1@@ -8,7 +8,9 @@ embedded in the go binary so that builds are reproducible regardless of build location. This codepath is hit for statically linked go binaries such as those on mips/ppc. -Upstream-Status: Pending +Upstream-Status: Submitted [https://github.com/golang/go/pull/56410] +Note: RP needs to sign Google CLA for the PR to proceed. +
I did sort that, I'm not sure I quite wanted to get into a larger discussion on how to do it properly and to rewrite the patch and run more tests though...
Cheers,
Richard
Re: [OE-core] [PATCH 12/13] go: submit patch upstream
Quoted 3 lines · Richard Purdie
I did sort that, I'm not sure I quite wanted to get into a larger discussion on how to do it properly and to rewrite the patch and run more tests though...
I wasn't inspired by those review comments either, perhaps we can convince upstream to take the existing patch as a 'bug report' and leave the actual fix to them.
Alex
PATCH 13/13 libffi: submit patch upstream
In reply to Alexander Kanavin--- .../libffi/0001-arm-sysv-reverted-clang-VFP-mitigation.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-support/libffi/libffi/0001-arm-sysv-reverted-clang-VFP-mitigation.patch +1 -1
@@ -11,7 +11,7 @@ https://github.com/libffi/libffi/issues/607. Now that clang supports the LDC and SDC instructions, this mitigation has been reverted. -Upstream-Status: Pending +Upstream-Status: Submitted [https://github.com/libffi/libffi/pull/747] Signed-off-by: Brett Warren <[email protected]> --- src/arm/sysv.S | 33 ---------------------------------
Signature · 1 line
2.30.2
Quoted 7 lines · 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_URIwith 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.
Quoted 7 lines
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.
Thanks Alex, that's a nice approach.
I'm reply to the thread since Jin had some trouble getting started with this class. This pushed me to finally try it and I have some minor comments and suggestions.
First, it works for me for adding ripgrep (1) and for Jin for something he was working on. It wasn't a perfect experience for me since at first, I had omitted:
S = "${WORKDIR}/git"
and
$ bitbake -c update_crates ripgrep
would fail silently with nothing useful in the log.do_update_crates file.
I'll likely send a patch to make it more verbose on error.
It also wasn't clear how to get started but in hindsight, you need 'obviously' need a recipe that has SRC_URI and SRCREV and S and maybe a bit more to get started.
Michael,
Do you think we should a document this workflow in addition to the cargo bitbake approach?
../Randy
1) https://github.com/BurntSushi/ripgrep
Recipe will go to meta-oe.
Quoted 63 lines
Signed-off-by Alexander Kanavin <[email protected]>--- .../cargo-update-recipe-crates.bbclass | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+)create mode 100644 meta/classes-recipe/cargo-update-recipe-crates.bbclass
meta/classes-recipe/cargo-update-recipe-crates.bbclass new file +41
-1@@ -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 +} -=-=-=-=-=-=-=-=-=-=-=-Links: You receive all messages sent to this group.
View/Reply Online (#172303): https://lists.openembedded.org/g/openembedded-core/message/172303
Mute This Topic: https://lists.openembedded.org/mt/94683148/3616765
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Signature · 2 lines
# Randy MacLeod # Wind River Linux
Hi everyone,
I promised Randy to post my experience with Yocto and Rust, which was a first time attempt for me. Note, that when starting I had no knowledge about Rust whatsoever, so this is "clean start" observation.
Quoted 17 lines · Randy MacLeod
Quoted 7 lines · 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_URIwith 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.Quoted 7 lines
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.
Quoted 5 lines
Thanks Alex, that's a nice approach.
I'm reply to the thread since Jin had some trouble getting started with this class. This pushed me to finally try it and I have some minor comments and suggestions.
my first issue was to actually find out how to approach this, it seems most google hits point to meta-rust which has been around for a longer period and I was lucky to get some hints in #oe on IRC, where Randy pointed me to cargo-update-recipe-crates.bbclass which is already in Poky.
The comment in the header about running bitbake -c update_crates recipe-name allowed me to generate the .inc file, but it was not immediately clear to me what I should do next.
The pointer to python3-bcrypt_*.bb was a bit confusing in the sense, that from the rust perspective it only inherits cargo-update-recipe-crates, but trying to build my package after having genrated the SRC_URI entries did not produce any build output, I ended up with an empty -dev and an empty -dbg ipk.
By looking at the available classes I figured that I should probably also inherit cargo, which indeed started to compile the application I needed to package.
Next, I ran into some build issues for packages which I guess the application was depending upon. I got an error:
error: failed to run custom build command for libudev-sys v0.1.4
which luckily had enough google hits to understand that it expects a DEPENDS = "eudev"
It however still failed after that and it took me some time to realize that I should also inherit pkgconfig, which finally did the trick.
I copied the working recipe back to Kirkstone and was happy to see, that it builds there as well.
So overall, given that I had zero Rust knowledge, it wasn't a bad experience, Yocto took care of most things for me.
Quoted 21 lines
First, it works for me for adding ripgrep (1) and for Jin for something he was
working on. It wasn't a perfect experience for me since at first, I had omitted:S = "${WORKDIR}/git"
and
$ bitbake -c update_crates ripgrepwould fail silently with nothing useful in the log.do_update_crates file.
I'll likely send a patch to make it more verbose on error.
It also wasn't clear how to get started but in hindsight, you need 'obviously'
need a recipe that hasSRC_URIand SRCREV and S and maybe a bit more to get started.
Quoted 4 lines
Michael,
Do you think we should a document this workflow in addition to the cargo bitbake approach?
I think this should be documented more prominently, as missing information on how to get going was the biggest obstacle, at least for me. The benefit of this workflow is, that no additional layer is needed and that everything seems to more or less work out of the box within the usual checkout.
The downside is a two step approach and I wonder if it would be possible to append the SRC_URI crate entries on the fly, but in a way that still works with sstate so that regeneration happens only when something has changed.
Anyway, it seems to be a good start, thanks to everyone who made this possible!
Kind regards,
Jin
Quoted 71 lines
1) https://github.com/BurntSushi/ripgrep
Recipe will go to meta-oe.
Quoted 63 lines
Signed-off-by Alexander Kanavin <[email protected]>--- .../cargo-update-recipe-crates.bbclass | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 meta/classes-recipe/cargo-update-recipe-crates.bbclassmeta/classes-recipe/cargo-update-recipe-crates.bbclass new file +41
-1@@ -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 +} -=-=-=-=-=-=-=-=-=-=-=-Links: You receive all messages sent to this group.
View/Reply Online (#172303): https://lists.openembedded.org/g/openembedded-core/message/172303
Mute This Topic: https://lists.openembedded.org/mt/94683148/3616765
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-Signature · 2 lines
# Randy MacLeod # Wind River Linux
Quoted 4 lines · Sergey Bostandzhyan
I think this should be documented more prominently, as missing information on how to get going was the biggest obstacle, at least for me. The benefit of this workflow is, that no additional layer is needed and that everything seems to more or less work out of the box within the usual checkout.
Thanks for the report, I totally agree that the rust recipe workflow should be documented somewhere in the official manuals, I'm just not sure where. Perhaps the 'common tasks' in
https://docs.yoctoproject.org/dev-manual/index.html ?
Can you write and propose a patch to the documentation repository?
Quoted 3 lines
The downside is a two step approach and I wonder if it would be possible to append the
SRC_URIcrate entries on the fly, but in a way that still works with sstate so that regeneration happens only when something has changed.
You can't modify anything in the layers during bitbake tasks, only if the task is completely standalone and isolated. You also can't modify SRC_URI internally after fetching as SRC_URI needs to be fully formed before the fetch task runs. What we can do is provide better hints in case cargo fails because the list of crates mismatches the lockdown file in the source, and needs to be updated (or created). Can this be reliably detected?
Alex
Hi Alex,
Am 07.12.2022 um 09:53 schrieb Alexander Kanavin via lists.openembedded.org:
Quoted 11 lines · Sergey Bostandzhyan
Quoted 4 lines
I think this should be documented more prominently, as missing information on how to get going was the biggest obstacle, at least for me. The benefit of this workflow is, that no additional layer is needed and that everything seems to more or less work out of the box within the usual checkout.
Thanks for the report, I totally agree that the rust recipe workflow should be documented somewhere in the official manuals, I'm just not sure where. Perhaps the 'common tasks' in
https://docs.yoctoproject.org/dev-manual/index.html ?Can you write and propose a patch to the documentation repository?
Is the recipetool obsolete or why we have yust an other tool to create a recipe in oe-core?
Regards
Stefan
Quoted 18 lines · Stefan Herbrechtsmeier
Hi Alex,
Am 07.12.2022 um 09:53 schrieb Alexander Kanavin via lists.openembedded.org:
Quoted 1 line
On Wed, 7 Dec 2022 at 01:21, Sergey Bostandzhyan <[email protected]>
Quoted 1 line · wrote:
Quoted 1 line
I think this should be documented more prominently, as missing
information
Quoted 1 line
Quoted 1 line
on how to get going was the biggest obstacle, at least for me. The
benefit of
Quoted 1 line
Quoted 1 line
this workflow is, that no additional layer is needed and that
everything seems
Quoted 6 lines
Quoted 1 line
to more or less work out of the box within the usual checkout.
Thanks for the report, I totally agree that the rust recipe workflow should be documented somewhere in the official manuals, I'm just not sure where. Perhaps the 'common tasks' in
https://docs.yoctoproject.org/dev-manual/index.html ?
Quoted 4 lines
Quoted 1 line
Can you write and propose a patch to the documentation repository?
Is the recipetool obsolete or why we have yust an other tool to create a recipe in oe-core?
Which another tool are you referring to? Cargo bitbake is a 3rd party project, one that I am not recommending to anyone in any way. And having a class to update or create a list of crates does not preclude its use in recipetool. Patches welcome.
A bit of politeness would be welcome too, Stefan, seriously. Watch your tone.
Alex
Hi Alex,
Am 07.12.2022 um 17:21 schrieb Alexander Kanavin:
Quoted 22 lines · Stefan Herbrechtsmeier
Hi Alex,
Am 07.12.2022 um 09:53 schrieb Alexander Kanavin via lists.openembedded.org <http://lists.openembedded.org>:
> On Wed, 7 Dec 2022 at 01:21, Sergey Bostandzhyan <[email protected]> wrote:
>> I think this should be documented more prominently, as missing information
>> on how to get going was the biggest obstacle, at least for me. The benefit of
>> this workflow is, that no additional layer is needed and that everything seems
>> to more or less work out of the box within the usual checkout. > Thanks for the report, I totally agree that the rust recipe workflow > should be documented somewhere in the official manuals, I'm just not > sure where. Perhaps the 'common tasks' in
> https://docs.yoctoproject.org/dev-manual/index.html ?
>
> Can you write and propose a patch to the documentation repository?
Quoted 8 lines
Is the recipetool obsolete or why we have yust an other tool to create a
recipe in oe-core?Which another tool are you referring to? Cargo bitbake is a 3rd party project, one that I am not recommending to anyone in any way. And having a class to update or create a list of crates does not preclude its use in recipetool. Patches welcome.
A bit of politeness would be welcome too, Stefan, seriously. Watch your tone.
Sorry for the harsh tone but you ignore existing tools and add just another tool to oe-core without mention any reason or document it. Do you really expect that somebody will patch existing tools if main developers ignore existing tools and provide new tool for their use case? Why should somebody improve an existing tool, extend the documentation, add tests or even upstream its work if these same requirements don’t exist for the main developers. It looks like the requirements for foreign and main contributors are different and this doesn't encourage people to participant. Maybe this is only my personal feeling and I apologize my harsh tone, but the acceptance of patches should be comprehensible, and expectations should be the same for everyone. Should others answer to your comments that their solution doesn’t preclude your suggestion and that they welcome patches? For sure it takes more time to add rust support to recipetool but I think a second tool without a clear reason in oe-core hurts more in long term because its now unclear if new features (like checksums or licenses support) should be added to this tool or if this tool is only a temporary solution and should be replaced by recipetool in long term. Furthermore, this class is marked as a class for a recipe but shouldn’t be inherit by a recipe and manipulates a file inside the meta data.
Regards
Stefan
Quoted 5 lines · Stefan Herbrechtsmeier
Sorry for the harsh tone but you ignore existing tools and add just another tool to oe-core without mention any reason or document it. Do you really expect that somebody will patch existing tools if main developers ignore existing tools and provide new tool for their use case?
I'm not sure that is entirely fair criticism. We have some challenges with some of the new languages. Rust support was in a separate layer. We took some of those recipes into core, then ended up making significant changes to them. We never took the external tool.
The hope in doing that was that we'd find a better way to make things work. I think what Alex has done is an improvement over that external tool and it experiments with a different way of handling things. I've had generally quite positive feedback on the approach itself. Yes, there are some issues with documentation and some people using it have struggled with some usability issues. None of those look like they're unfixable.
Quoted 5 lines
Why should somebody improve an existing tool, extend the
documentation, add tests or even upstream its work if these same requirements don’t exist for the main developers. It looks like the requirements for foreign and main contributors are different and this doesn't encourage people to participant.
I don't see us treating developers differently and I am concerned you think we/I do. Any given solution that is proposed is evaluated on it's pros and cons. In this case the solution is quite self contained and allowed the approach to be experimented with whilst solving a real world issue. If it doesn't work out we can easily drop it. The risk from taking it is therefore low. Yes, I should probably insist on documentation. In this case it is relatively simple code which is relatively easily understood so I've been less worried about that up front.
If it worked out well, we can integrate it further and document it. If it doesn't it can be removed. FWIW I have heard people saying they like the approach and that we should use it for some of the other languages with challenges like this.
Quoted 3 lines
Maybe this is only my personal feeling and I apologize my harsh
tone, but the acceptance of patches should be comprehensible, and expectations should be the same for everyone.
I do try to ensure that. My "algorithm" for accepting patches is probably not easily documented but I think the factors here which are the standalone nature of the change and the easy with which we could drop it if needed. As such it is in my "low risk" category of patches.
I'd note Alex has another patch which has been sitting for months unmerged as it is in my "high risk" to the project category. I suspect that one will not actually merge but I need to find the time to explain why, right now it is more based on a feeling it is the wrong direction.
Quoted 10 lines
Should others answer to your comments that their solution doesn’t
preclude your suggestion and that they welcome patches? For sure it takes more time to add rust support to recipetool but I think a second tool without a clear reason in oe-core hurts more in long term because its now unclear if new features (like checksums or licenses support) should be added to this tool or if this tool is only a temporary solution and should be replaced by recipetool in long term. Furthermore, this class is marked as a class for a recipe but shouldn’t be inherit by a recipe and manipulates a file inside the meta data.
We do have precedence for classes that help updates like this. Both python and perl have code that adds tasks that function a bit like this, in those cases for the core recipe.
Personally, I would ultimately like to see these operations handled by recipetool and I suspect natural evolution of the code may head that way. Both devtool and recipetool have used classes as a way to help them perform operations so in that sense, this is actually a logical development path for those tools.
Cheers,
Richard
Quoted 4 lines · Richard Purdie
I'd note Alex has another patch which has been sitting for months unmerged as it is in my "high risk" to the project category. I suspect that one will not actually merge but I need to find the time to explain why, right now it is more based on a feeling it is the wrong direction.
I'd be happy to be 'course corrected' on oe-setup-build, I personally feel it does more 'guessing' than I'm comfortable with but I can't figure out a better way to handle things. The problems it's aiming to address are real, so it shouldn't be formally rejected without a plan.
Alex
Quoted 11 lines · Alexander Kanavin
Quoted 4 lines · Richard Purdie
I'd note Alex has another patch which has been sitting for months unmerged as it is in my "high risk" to the project category. I suspect that one will not actually merge but I need to find the time to explain why, right now it is more based on a feeling it is the wrong direction.
I'd be happy to be 'course corrected' on oe-setup-build, I personally feel it does more 'guessing' than I'm comfortable with but I can't figure out a better way to handle things. The problems it's aiming to address are real, so it shouldn't be formally rejected without a plan.
Right, I do need to explain why I'm reluctant about it and what the concerns are. Sadly doing that isn't straightforward, particularly if the bar is set to the height of "show how a better approach would work" since I then have to think through a new design before I can reply. The challenge with that patch is that it uses a very predominant namespace and can't easily change once we take that direction so that makes merging much harder.
My point here was that patches from everyone are treated fairly, some merge quickly, some don't, it really does depend.
There are also patches from some guy called Richard on the bitbake mailing list which Richard is refusing to merge due to performance concerns :)
Cheers,
Richard
Hi Richard,
Am 09.12.2022 um 13:01 schrieb Richard Purdie:
Quoted 66 lines · Stefan Herbrechtsmeier
Quoted 5 lines
Sorry for the harsh tone but you ignore existing tools and add just another tool to oe-core without mention any reason or document it. Do you really expect that somebody will patch existing tools if main developers ignore existing tools and provide new tool for their use case?
I'm not sure that is entirely fair criticism. We have some challenges with some of the new languages. Rust support was in a separate layer. We took some of those recipes into core, then ended up making significant changes to them. We never took the external tool.
The hope in doing that was that we'd find a better way to make things work. I think what Alex has done is an improvement over that external tool and it experiments with a different way of handling things. I've had generally quite positive feedback on the approach itself. Yes, there are some issues with documentation and some people using it have struggled with some usability issues. None of those look like they're unfixable.
Quoted 5 lines
Why should somebody improve an existing tool, extend the
documentation, add tests or even upstream its work if these same requirements don’t exist for the main developers. It looks like the requirements for foreign and main contributors are different and this doesn't encourage people to participant.I don't see us treating developers differently and I am concerned you think we/I do. Any given solution that is proposed is evaluated on it's pros and cons. In this case the solution is quite self contained and allowed the approach to be experimented with whilst solving a real world issue. If it doesn't work out we can easily drop it. The risk from taking it is therefore low. Yes, I should probably insist on documentation. In this case it is relatively simple code which is relatively easily understood so I've been less worried about that up front.
If it worked out well, we can integrate it further and document it. If it doesn't it can be removed. FWIW I have heard people saying they like the approach and that we should use it for some of the other languages with challenges like this.
Quoted 3 lines
Maybe this is only my personal feeling and I apologize my harsh
tone, but the acceptance of patches should be comprehensible, and expectations should be the same for everyone.I do try to ensure that. My "algorithm" for accepting patches is probably not easily documented but I think the factors here which are the standalone nature of the change and the easy with which we could drop it if needed. As such it is in my "low risk" category of patches.
I'd note Alex has another patch which has been sitting for months unmerged as it is in my "high risk" to the project category. I suspect that one will not actually merge but I need to find the time to explain why, right now it is more based on a feeling it is the wrong direction.
Quoted 10 lines
Should others answer to your comments that their solution doesn’t
preclude your suggestion and that they welcome patches? For sure it takes more time to add rust support to recipetool but I think a second tool without a clear reason in oe-core hurts more in long term because its now unclear if new features (like checksums or licenses support) should be added to this tool or if this tool is only a temporary solution and should be replaced by recipetool in long term. Furthermore, this class is marked as a class for a recipe but shouldn’t be inherit by a recipe and manipulates a file inside the meta data.We do have precedence for classes that help updates like this. Both python and perl have code that adds tasks that function a bit like this, in those cases for the core recipe.
Quoted 5 lines
Personally, I would ultimately like to see these operations handled by recipetool and I suspect natural evolution of the code may head that way. Both devtool and recipetool have used classes as a way to help them perform operations so in that sense, this is actually a logical development path for those tools.
Thanks for you feedback and the clarification. This helps me a lot.
Stefan
Quoted 1 line · Stefan Herbrechtsmeier
Sorry for the harsh tone but you ignore existing tools and add just another tool to oe-core without mention any reason or document it.
The reason to add the class was to be able to update existing rust-based recipes without having to manually update long lists of crates in those recipes, which is a rather urgent issue, more urgent than having rust support in recipetool. The class does not replace recipetool, in fact it can, and should be used by devtool/recipetool once someone finds time and motivation to sit down and add (currently missing) rust support to it (class functionality can be executed from those tools via tinfoil.build_targets()). I do not have that time, and I am not getting paid for doing that either. Oh, and we do not have a maintainer for those tools. Would you like to volunteer for that?
Documentation is handled in a separate repository, and is typically decoupled from actual code. I'll get to it, but you should know that some things are actually higher priority. Such as keeping core updated, so that you can have a secure stack in the products you sell, and doing paid customer work, so that I can pay my bills. I'd appreciate if you reflect on the fact that none of my upstream work is recognized, or supported by your company, even though without it you would not have a product to sell - which in turn pays your bills.
Alex
Hi Alex,
Am 09.12.2022 um 13:09 schrieb Alexander Kanavin:
Quoted 13 lines
Quoted 1 line · Stefan Herbrechtsmeier
Sorry for the harsh tone but you ignore existing tools and add just another tool to oe-core without mention any reason or document it.
The reason to add the class was to be able to update existing rust-based recipes without having to manually update long lists of crates in those recipes, which is a rather urgent issue, more urgent than having rust support in recipetool. The class does not replace recipetool, in fact it can, and should be used by devtool/recipetool once someone finds time and motivation to sit down and add (currently missing) rust support to it (class functionality can be executed from those tools via
tinfoil.build_targets()). I do not have that time, and I am not getting paid for doing that either. Oh, and we do not have a maintainer for those tools. Would you like to volunteer for that?
Yes, I'm happy to maintain recipetool. We need to go on with our npm und go support anyway.
Regards
Stefan
Quoted 12 lines · Stefan Herbrechtsmeier
Quoted 11 lines
Quoted 1 line
Sorry for the harsh tone but you ignore existing tools and add just another tool to oe-core without mention any reason or document it.
The reason to add the class was to be able to update existing rust-based recipes without having to manually update long lists of crates in those recipes, which is a rather urgent issue, more urgent than having rust support in recipetool. The class does not replace recipetool, in fact it can, and should be used by devtool/recipetool once someone finds time and motivation to sit down and add (currently missing) rust support to it (class functionality can be executed from those tools via
tinfoil.build_targets()). I do not have that time, and I am not getting paid for doing that either. Oh, and we do not have a maintainer for those tools. Would you like to volunteer for that?
Quoted 2 lines
Yes, I'm happy to maintain recipetool. We need to go on with our npm und go support anyway.
Thank you, that would be very much appreciated.
We're all stretched thin, and need to continuously advocate the importance of OSS maintenance as a job, as it's still not seen as such. The problem is endemic across the software industry.
Alex