From 0dbf112cf5a61151c1e51d93d4b72622b5708d0a Mon Sep 17 00:00:00 2001 From: Jeremi Piotrowski Date: Thu, 21 Mar 2024 09:57:29 +0000 Subject: [PATCH 1/3] coreos-cargo.eclass: Introduce variable to skip inherit Gentoo's cargo based ebuilds don't cross-compile well, so we need a way to inject coreos-cargo.eclass into them. Otherwise we'd need to fork the ebuilds into coreos-overlay and maintain them ourselves. The way we can do this is by sourcing the eclass from cros hooks and overriding src_unpack to call the eclass implementation. Inheriting an eclass is not allowed from hooks. Since we can't call any of the inherits a variable is introduced to skip them and EXPORT_FUNCTIONS. Signed-off-by: Jeremi Piotrowski --- .../third_party/coreos-overlay/eclass/coreos-cargo.eclass | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sdk_container/src/third_party/coreos-overlay/eclass/coreos-cargo.eclass b/sdk_container/src/third_party/coreos-overlay/eclass/coreos-cargo.eclass index c7076edefb..405696dc22 100644 --- a/sdk_container/src/third_party/coreos-overlay/eclass/coreos-cargo.eclass +++ b/sdk_container/src/third_party/coreos-overlay/eclass/coreos-cargo.eclass @@ -12,10 +12,12 @@ if [[ -z ${_COREOS_CARGO_ECLASS} ]]; then _COREOS_CARGO_ECLASS=1 # XXX: Don't require host dependencies to also be in the sysroot. -CATEGORY=dev-util PN=cargo inherit cargo -inherit toolchain-funcs +if [[ -z ${_COREOS_CARGO_SKIP_INHERIT} ]]; then + CATEGORY=dev-util PN=cargo inherit cargo + inherit toolchain-funcs -EXPORT_FUNCTIONS src_unpack + EXPORT_FUNCTIONS src_unpack +fi # @FUNCTION: coreos-cargo_src_unpack # @DESCRIPTION: From 44bb4367b4c926c756676d66ef1283d85f7df1fb Mon Sep 17 00:00:00 2001 From: Jeremi Piotrowski Date: Thu, 21 Mar 2024 10:12:28 +0000 Subject: [PATCH 2/3] coreos: Add coreos-cargo hook for sys-apps/zram-generator The hook hijacks src_unpack and calls the cross-compilation friendly implementation. Signed-off-by: Jeremi Piotrowski --- .../coreos/config/env/sys-apps/zram-generator | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 sdk_container/src/third_party/coreos-overlay/coreos/config/env/sys-apps/zram-generator diff --git a/sdk_container/src/third_party/coreos-overlay/coreos/config/env/sys-apps/zram-generator b/sdk_container/src/third_party/coreos-overlay/coreos/config/env/sys-apps/zram-generator new file mode 100644 index 0000000000..2ca892c2bf --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/coreos/config/env/sys-apps/zram-generator @@ -0,0 +1,8 @@ +cros_pre_src_unpack_coreos_unpack() { + local _COREOS_CARGO_SKIP_INHERIT=1 + source "${CROS_ADDONS_TREE}"/../eclass/coreos-cargo.eclass + src_unpack() { + einfo "Running coreos-cargo_src_unpack" + coreos-cargo_src_unpack + } +} From b34894e37ee9fe9ee233ed7d990c13ce79244129 Mon Sep 17 00:00:00 2001 From: Jeremi Piotrowski Date: Thu, 21 Mar 2024 10:14:43 +0000 Subject: [PATCH 3/3] coreos: Add coreos-cargo hook for sys-block/thin-provisioning-tools We currently ship an amd64 binary of thin-provisioning-tools on arm64. To fix this add a hook that hijacks src_unpack and calls the cross-compilation friendly implementation. We also need to fixup the src_install implementation since it looks for the produced binary in the default cargo location. Signed-off-by: Jeremi Piotrowski --- .../config/env/sys-block/thin-provisioning-tools | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 sdk_container/src/third_party/coreos-overlay/coreos/config/env/sys-block/thin-provisioning-tools diff --git a/sdk_container/src/third_party/coreos-overlay/coreos/config/env/sys-block/thin-provisioning-tools b/sdk_container/src/third_party/coreos-overlay/coreos/config/env/sys-block/thin-provisioning-tools new file mode 100644 index 0000000000..e2b17a5677 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/coreos/config/env/sys-block/thin-provisioning-tools @@ -0,0 +1,16 @@ +cros_pre_src_unpack_coreos_unpack() { + local _COREOS_CARGO_SKIP_INHERIT=1 + source "${CROS_ADDONS_TREE}"/../eclass/coreos-cargo.eclass + src_unpack() { + einfo "Running coreos-cargo_src_unpack" + coreos-cargo_src_unpack + } +} + +cros_pre_src_install_rust_cross() { + pushd "${S}" + local rust_target="$(ls -d target/*-unknown-linux-gnu)" + rust_target="${rust_target#target/}" + ln -f target/{"${rust_target}",}/"$(usex debug debug release)/pdata_tools" || die + popd +}