Reproduce process: 1) Build one poky image from scratch. 2) Remove all the tmp files and retain the sstate-cache prebuilt results. 3) Build another poky image from sstate. With the above process, an rpm "unknown option" error will occur while executing do_rootfs. Note that, to trigger the bug, we must remove/rename the tmp file of the original build. Some phenomenon will be like: | rpm: --dbpath: unknown option | Function 'do_rootfs' failed (see /home/dongxiao/poky.git/build-atom-pc/tmp/work/atom-pc-poky-linux/poky-image-sdk-1.0-r0/temp/log.do_rootfs.12907 for further information) NOTE: package poky-image-sdk-1.0-r0: task do_rootfs: Failed ERROR: Task 9 (/home/dongxiao/poky.git/meta/recipes-sato/images/poky-image-sdk.bb, do_rootfs) failed with exit code '1' or | rpmbuild: --buildroot: unknown option | Function 'BUILDSPEC' failed (see /distro/dongxiao/build-qemux86-sstate/tmp/work/qemux86-poky-linux/task-poky-boot-1.0-r7/temp/log.do_package_write_rpm.14059 for further information) | ERROR: Function 'BUILDSPEC' failed (see /distro/dongxiao/build-qemux86-sstate/tmp/work/qemux86-poky-linux/task-poky-boot-1.0-r7/temp/log.do_package_write_rpm.14059 for further information) If running "rpm --dbpath" in do_rootfs, rpm will search rpmpopt file to get the meaning of this additional options. However the rpm binary from sstate still tries to find the rpmpopt file from its original build dir, which is already removed. Since the rpmpopt path is assigned when configuration, thus we need to rebuild rpm-native to make sstate build correct.
I just found that there is a runtime option "--rpmpopt" that can change the rpmpopt path, I will commit a patch to create a wrapper for rpm native binary.
The version of RPM we built can be overridden in an easy way. We need to set the environment values of: RPM_USRLIBRPM RPM_ETCRPM RPM_LOCALEDIR There is an example runtime relocation wrapper included in the RPM sources: scripts/rt-reloc-wrapper.sh: #! /bin/sh # Identify run path, and forward to ../lib_or_lib64/$0 PROGNAME=$(basename $0) DIR=$(cd $(dirname $0) ; pwd) export LD_LIBRARY_PATH=$DIR/../libMark64:$DIR/../lib:$DIR/../lib64 export RPM_USRLIBRPM=$DIR/../libMark64/rpm export RPM_ETCRPM=$DIR/../etc/rpm export RPM_LOCALEDIR=$DIR/../share/locale exec $DIR/../libMark64/rpm/$PROGNAME "$@" where you see "libMark64" is replaced by either "lib" or "lib64"...
Fixed in http://git.pokylinux.org/cgit/cgit.cgi/poky/commit/?id=d71f6fff17e7a2bd5acd4339b26a2d3b28c76814
*** Bug 731 has been marked as a duplicate of this bug. ***