diff options
author | hongxu <hongxu.jia@eng.windriver.com> | 2025-06-05 19:14:58 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-06-09 17:43:41 +0100 |
commit | 57f4fad751d5a8d7cce8379a3b70e4e10c7e6ecf (patch) | |
tree | 2d299a8a7fa7835c0d37cc5995db7e99debee2f4 | |
parent | f98ab9c342a5b893611a877133bc05ec143519a0 (diff) | |
download | poky-57f4fad751d5a8d7cce8379a3b70e4e10c7e6ecf.tar.gz |
rpm: correct tool path in macros for no usrmerge
While no usrmerge in sysvinit, some tools defined in rpm macro have wrong path
$ echo 'INIT_MANAGER="sysvinit"' >> conf/local.conf
$ echo 'IMAGE_INSTALL:append = " rpm busybox"' >> conf/local.conf
$ bitbake core-image-minimal
$ runqemu tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs.qemuboot.conf
root@qemux86-64:~# which sed tar rm mkdir cp cat chown chmod gzip grep mv
/bin/sed
/bin/tar
/bin/rm
/bin/mkdir
/bin/cp
/bin/cat
/bin/chown
/bin/chmod
/bin/gzip
/bin/grep
/bin/mv
root@qemux86-64:~# rpm --eval "%{__sed} %{__tar} %{__rm} %{__mkdir} %{__cp} %{__cat} %{__chown} %{__chmod} %{__gzip} %{__grep} %{__mv}"
/usr/bin/sed /usr/bin/tar /usr/bin/rm /usr/bin/mkdir /usr/bin/cp /usr/bin/cat /usr/bin/chown /usr/bin/chmod /usr/bin/gzip /usr/bin/grep /usr/bin/mv
Here to explain how __rm was set in rpm during build. The build system
of rpm is cmake. Take rpm rpm-4.19.x for example:
The '__RM rm' is defected by findutil [1], and function findutil
calls find_program to search for tool, if not found on host, then
hardcode with "/usr/bin" prefix [2]
Yocto explicitly set OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM = "ONLY" [3][4]
to search tools from CMAKE_FIND_ROOT_PATH [5] which locates in recipe sysroot,
if not found in recipe sysroot, hardcode with "/usr/bin" prefix
If "${base_bindir}" != "${bindir}, explicitly correct tools in rpm
macros, use ${base_bindir} to instead original ${bindir}. Only do the
operation for target, it is not necessary for native and nativesdk,
because most host distribution supports usrmerge
After applying this commit, on target:
root@qemux86-64:~# rpm --eval "%{__sed} %{__tar} %{__rm} %{__mkdir} %{__cp} %{__cat} %{__chown} %{__chmod} %{__gzip} %{__grep} %{__mv}"
/bin/sed /bin/tar /bin/rm /bin/mkdir /bin/cp /bin/cat /bin/chown /bin/chmod /bin/gzip /bin/grep /bin/mv
root@qemux86-64:~# ls /bin/sed /bin/tar /bin/rm /bin/mkdir /bin/cp /bin/cat /bin/chown /bin/chmod /bin/gzip /bin/grep /bin/mv
/bin/cat /bin/chmod /bin/chown /bin/cp /bin/grep /bin/gzip /bin/mkdir /bin/mv /bin/rm /bin/sed /bin/tar
In order to save size, this commit does not add these tools to
runtime depends, user should explicitly add them if necessary
(such as use rpm to build packages)
[1] https://github.com/rpm-software-management/rpm/blob/rpm-4.19.x/CMakeLists.txt#L121
[2] https://github.com/rpm-software-management/rpm/blob/rpm-4.19.x/CMakeLists.txt#L59
[3] https://git.openembedded.org/openembedded-core/commit/?id=f4ea12f6635125ee793f4dd801c538c0186f9dc3
[4] https://cmake.org/cmake/help/latest/variable/CMAKE_FIND_ROOT_PATH_MODE_PROGRAM.html
[5] https://git.openembedded.org/openembedded-core/tree/meta/classes-recipe/cmake.bbclass?id=f4ea12f6635125ee793f4dd801c538c0186f9dc3#n123
(From OE-Core rev: c89c7177be2df5d2be44478a6ac43b35ad46db9e)
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/recipes-devtools/rpm/rpm_4.20.0.bb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/meta/recipes-devtools/rpm/rpm_4.20.0.bb b/meta/recipes-devtools/rpm/rpm_4.20.0.bb index bcc138dab0..33966b97b4 100644 --- a/meta/recipes-devtools/rpm/rpm_4.20.0.bb +++ b/meta/recipes-devtools/rpm/rpm_4.20.0.bb | |||
@@ -101,6 +101,8 @@ WRAPPER_TOOLS = " \ | |||
101 | ${libdir}/rpm/rpmdeps \ | 101 | ${libdir}/rpm/rpmdeps \ |
102 | " | 102 | " |
103 | 103 | ||
104 | base_bindir_progs = "sed tar rm mv mkdir cp cat chown chmod gzip grep" | ||
105 | |||
104 | do_install:append:class-native() { | 106 | do_install:append:class-native() { |
105 | for tool in ${WRAPPER_TOOLS}; do | 107 | for tool in ${WRAPPER_TOOLS}; do |
106 | test -x ${D}$tool && create_wrapper ${D}$tool \ | 108 | test -x ${D}$tool && create_wrapper ${D}$tool \ |
@@ -123,9 +125,15 @@ do_install:append:class-nativesdk() { | |||
123 | EOF | 125 | EOF |
124 | } | 126 | } |
125 | 127 | ||
126 | # Rpm's make install creates var/tmp which clashes with base-files packaging | ||
127 | do_install:append:class-target() { | 128 | do_install:append:class-target() { |
129 | # Rpm's make install creates var/tmp which clashes with base-files packaging | ||
128 | rm -rf ${D}/var | 130 | rm -rf ${D}/var |
131 | |||
132 | if [ "${base_bindir}" != "${bindir}" ]; then | ||
133 | for prog in ${base_bindir_progs}; do | ||
134 | sed -i "s|^%__${prog}.*|%__${prog} ${base_bindir}/${prog}|g" ${D}${libdir}/rpm/macros | ||
135 | done | ||
136 | fi | ||
129 | } | 137 | } |
130 | do_install:append:class-nativesdk() { | 138 | do_install:append:class-nativesdk() { |
131 | rm -rf ${D}${SDKPATHNATIVE}/var | 139 | rm -rf ${D}${SDKPATHNATIVE}/var |