nativesdk-rpm: Add wrappers for nativesdk support

Submitted by Ovidiu Panait on Feb. 27, 2018, 1:45 p.m. | Patch ID: 148402

Details

Message ID 20180227134541.147175-1-ovidiu.panait@windriver.com
State New
Headers show

Commit Message

Ovidiu Panait Feb. 27, 2018, 1:45 p.m.
When installing the SDK to a non-default path, running "rpm --showrc" from the
sdk will produce the following error:
error: Unable to open /opt/poky/2.4+snapshot/sysroots/x86_64-pokysdk-linux/usr/lib/rpm/rpmrc for reading: No such file or directory. 

Fix this by adding wrappers that dynamically export the RPM_CONFIGDIR,
RPM_ETCCONFIGDIR and MAGIC environment variables, pointing to the proper
sdk locations.

Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
---
 meta/recipes-devtools/rpm/rpm_4.14.1.bb | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

Patch hide | download patch | download mbox

diff --git a/meta/recipes-devtools/rpm/rpm_4.14.1.bb b/meta/recipes-devtools/rpm/rpm_4.14.1.bb
index 7b8ea46a75..daaf4637a3 100644
--- a/meta/recipes-devtools/rpm/rpm_4.14.1.bb
+++ b/meta/recipes-devtools/rpm/rpm_4.14.1.bb
@@ -65,6 +65,7 @@  EXTRA_OECONF_append_libc-musl = " --disable-nls"
 #
 # Also disable plugins, so that rpm doesn't attempt to inhibit shutdown via session dbus
 EXTRA_OECONF_append_class-native = " --sysconfdir=/etc --localstatedir=/var --disable-plugins"
+EXTRA_OECONF_append_class-nativesdk = " --sysconfdir=/etc --localstatedir=/var --disable-plugins"
 
 BBCLASSEXTEND = "native nativesdk"
 
@@ -96,6 +97,31 @@  do_install_append_class-native() {
         done
 }
 
+do_install_append_class-nativesdk() {
+        tools="\
+                ${bindir}/rpm \
+                ${bindir}/rpm2archive \
+                ${bindir}/rpm2cpio \
+                ${bindir}/rpmbuild \
+                ${bindir}/rpmdb \
+                ${bindir}/rpmgraph \
+                ${bindir}/rpmkeys \
+                ${bindir}/rpmsign \
+                ${bindir}/rpmspec \
+                ${libdir}/rpm/rpmdeps \
+        "
+
+        for tool in $tools; do
+                create_wrapper ${D}$tool \
+                        RPM_CONFIGDIR='`dirname $''realpath`'/${@os.path.relpath(d.getVar('libdir', True), d.getVar('bindir', True))}/rpm \
+                        RPM_ETCCONFIGDIR='$'{RPM_ETCCONFIGDIR-'`dirname $''realpath`'/${@os.path.relpath(d.getVar('sysconfdir', True), d.getVar('bindir', True))}/..} \
+                        MAGIC='`dirname $''realpath`'/${@os.path.relpath(d.getVar('datadir', True), d.getVar('bindir', True))}/misc/magic.mgc \
+                        RPM_NO_CHROOT_FOR_SCRIPTS=1
+        done
+
+        rm -rf ${D}/var
+}
+
 # Rpm's make install creates var/tmp which clashes with base-files packaging
 do_install_append_class-target() {
     rm -rf ${D}/var

Comments

Alexander Kanavin Feb. 27, 2018, 2:09 p.m.
On 02/27/2018 03:45 PM, Ovidiu Panait wrote:
> +do_install_append_class-nativesdk() {
> +        tools="\
> +                ${bindir}/rpm \
> +                ${bindir}/rpm2archive \
> +                ${bindir}/rpm2cpio \
> +                ${bindir}/rpmbuild \
> +                ${bindir}/rpmdb \
> +                ${bindir}/rpmgraph \
> +                ${bindir}/rpmkeys \
> +                ${bindir}/rpmsign \
> +                ${bindir}/rpmspec \
> +                ${libdir}/rpm/rpmdeps \
> +        "
> +
> +        for tool in $tools; do
> +                create_wrapper ${D}$tool \
> +                        RPM_CONFIGDIR='`dirname $''realpath`'/${@os.path.relpath(d.getVar('libdir', True), d.getVar('bindir', True))}/rpm \
> +                        RPM_ETCCONFIGDIR='$'{RPM_ETCCONFIGDIR-'`dirname $''realpath`'/${@os.path.relpath(d.getVar('sysconfdir', True), d.getVar('bindir', True))}/..} \
> +                        MAGIC='`dirname $''realpath`'/${@os.path.relpath(d.getVar('datadir', True), d.getVar('bindir', True))}/misc/magic.mgc \
> +                        RPM_NO_CHROOT_FOR_SCRIPTS=1
> +        done
> +
> +        rm -rf ${D}/var
> +}

Can this be done without copy-pasting an existing function please?

Alex
Mark Hatle Feb. 27, 2018, 2:46 p.m.
On 2/27/18 8:09 AM, Alexander Kanavin wrote:
> On 02/27/2018 03:45 PM, Ovidiu Panait wrote:
>> +do_install_append_class-nativesdk() {
>> +        tools="\
>> +                ${bindir}/rpm \
>> +                ${bindir}/rpm2archive \
>> +                ${bindir}/rpm2cpio \
>> +                ${bindir}/rpmbuild \
>> +                ${bindir}/rpmdb \
>> +                ${bindir}/rpmgraph \
>> +                ${bindir}/rpmkeys \
>> +                ${bindir}/rpmsign \
>> +                ${bindir}/rpmspec \
>> +                ${libdir}/rpm/rpmdeps \
>> +        "
>> +
>> +        for tool in $tools; do
>> +                create_wrapper ${D}$tool \
>> +                        RPM_CONFIGDIR='`dirname $''realpath`'/${@os.path.relpath(d.getVar('libdir', True), d.getVar('bindir', True))}/rpm \
>> +                        RPM_ETCCONFIGDIR='$'{RPM_ETCCONFIGDIR-'`dirname $''realpath`'/${@os.path.relpath(d.getVar('sysconfdir', True), d.getVar('bindir', True))}/..} \
>> +                        MAGIC='`dirname $''realpath`'/${@os.path.relpath(d.getVar('datadir', True), d.getVar('bindir', True))}/misc/magic.mgc \
>> +                        RPM_NO_CHROOT_FOR_SCRIPTS=1
>> +        done
>> +
>> +        rm -rf ${D}/var
>> +}
> 
> Can this be done without copy-pasting an existing function please?

The code can't run in class-target, this would screw up the target.
The code in class-native has a different set of arguments to the create_wrapper.
The rm -rf ${D}/var is not done on class-native, but is done on class-target.

So no.  We need two copies, as they are different.

--Mark

> Alex
>