[OE-core] [PATCH v4] rpm: make rpm work in toolchain.

Richard Purdie richard.purdie at linuxfoundation.org
Wed Oct 2 08:48:30 UTC 2019


On Wed, 2019-09-25 at 07:45 +0800, Zheng Ruoqin wrote:
> We need to configure rpm to use package architecture from yocto build
> system.
> 
> Install rpmrc and rpm/platform to ${SDKTARGETSYSROOT} because config
> file in host-sysroot as /opt/poky/2.7+snapshot/sysroots/x86_64-
> pokysdk-linux will be covered by another ARCH which result in
> previous config settings inefficacy.
> 
> To resolve it, put config file in target-sysroot like
> /opt/poky/2.7+snapshot/sysroots/core2-64-poky-linux. As each ARCH has
> its own target-sysroot, config file will not be covered.
> 
> Signed-off-by: Zheng Ruoqin <zhengrq.fnst at cn.fujitsu.com>
> ---
>  meta/recipes-devtools/rpm/files/rpm-setup.py | 27
> ++++++++++++++++++++
>  meta/recipes-devtools/rpm/rpm_4.14.2.1.bb    | 19 ++++++++++++++
>  2 files changed, 46 insertions(+)
>  create mode 100644 meta/recipes-devtools/rpm/files/rpm-setup.py
> 
> diff --git a/meta/recipes-devtools/rpm/files/rpm-setup.py
> b/meta/recipes-devtools/rpm/files/rpm-setup.py
> new file mode 100644
> index 0000000000..b3e8a1198c
> --- /dev/null
> +++ b/meta/recipes-devtools/rpm/files/rpm-setup.py
> @@ -0,0 +1,27 @@
> +#!/usr/bin/env python3
> +
> +import os
> +import sys
> +import shutil
> +
> +try:
> +    native_sysroot = os.environ['OECORE_NATIVE_SYSROOT']
> +    sdktarget_sysroot = os.environ['SDKTARGETSYSROOT']
> +except KeyError:
> +    print("Not in environment setup, bailing")
> +    sys.exit(1)
> +
> +target_etc_dir = os.path.join(sdktarget_sysroot, 'etc/rpm')
> +
> +if not os.path.exists(target_etc_dir):
> +    os.makedirs(target_etc_dir)
> +
> +template_file = os.path.join(native_sysroot, 'usr/share/rpm/rpmrc')
> +cross_file = os.path.join(sdktarget_sysroot, 'etc/rpmrc')
> +shutil.copy(template_file, cross_file)
> +
> +template_file = os.path.join(native_sysroot,
> 'usr/share/rpm/platform')
> +cross_file = os.path.join(sdktarget_sysroot, 'etc/rpm/platform')
> +shutil.copy(template_file, cross_file)
> +
> +
> diff --git a/meta/recipes-devtools/rpm/rpm_4.14.2.1.bb
> b/meta/recipes-devtools/rpm/rpm_4.14.2.1.bb
> index c37330eb4c..e1d1951d74 100644
> --- a/meta/recipes-devtools/rpm/rpm_4.14.2.1.bb
> +++ b/meta/recipes-devtools/rpm/rpm_4.14.2.1.bb
> @@ -44,6 +44,9 @@ SRC_URI = "git://github.com/rpm-software-
> management/rpm;branch=rpm-4.14.x \
>             file://0001-mono-find-provides-requires-do-not-use-
> monodis-from-.patch \
>             "
>  
> +SRC_URI_append_class-nativesdk = "file://rpm-setup.py \
> +                                 "
> +
>  PE = "1"
>  SRCREV = "4a9440006398646583f0d9ae1837dad2875013aa"
>  
> @@ -113,6 +116,20 @@ do_install_append_class-nativesdk() {
>          done
>  
>          rm -rf ${D}/var
> +        install -d ${D}${datadir}/rpm
> +
> +        cat >${D}/${datadir}/rpm/rpmrc <<EOF
> +arch_compat: ${MACHINE_ARCH}: all any noarch ${PACKAGE_EXTRA_ARCHS}
> +EOF
> +
> +# Arch Info should be fixed as '-' is instead of '_'.
> +        sed -i 's/-/_/' ${D}${datadir}/rpm/rpmrc
> +        cat >${D}/${datadir}/rpm/platform <<EOF
> +${MACHINE_ARCH}-pc-linux
> +EOF

This is heading in the right direction but this patch still makes the
nativesdk-rpm recipe machine specific and we can't do that.

Cheers,

Richard





More information about the Openembedded-core mailing list