[OE-core] [PATCH 4/4] relocatable: add file existence checking in relocatable_native_pcfiles

Jiang Lu lu.jiang at windriver.com
Wed Mar 20 09:39:29 UTC 2019


Some package may create a ${libdir}/pkgconfig directory in its sysroot
without .pc file. It leads following error:
sed: can't read ${sysroot}/${libdir}/pkgconfig/*.pc: No such file or directory

To avoid this, add a file existence checking in relocatable_native_pcfiles()
before sed.

Signed-off-by: Jiang Lu <lu.jiang at windriver.com>
---
 meta/classes/relocatable.bbclass | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/meta/classes/relocatable.bbclass b/meta/classes/relocatable.bbclass
index 582812c1cf..eb9989d18c 100644
--- a/meta/classes/relocatable.bbclass
+++ b/meta/classes/relocatable.bbclass
@@ -7,11 +7,13 @@ python relocatable_binaries_preprocess() {
 }
 
 relocatable_native_pcfiles () {
-	if [ -d ${SYSROOT_DESTDIR}${libdir}/pkgconfig ]; then
+	filecnt=`ls -l ${SYSROOT_DESTDIR}${libdir}/pkgconfig/*.pc 2>/dev/null | wc -l`
+	if [ $filecnt -gt 0 ]; then
 		rel=${@os.path.relpath(d.getVar('base_prefix'), d.getVar('libdir') + "/pkgconfig")}
 		sed -i -e "s:${base_prefix}:\${pcfiledir}/$rel:g" ${SYSROOT_DESTDIR}${libdir}/pkgconfig/*.pc
 	fi
-	if [ -d ${SYSROOT_DESTDIR}${datadir}/pkgconfig ]; then
+	filecnt=`ls -l ${SYSROOT_DESTDIR}${datadir}/pkgconfig/*.pc 2>/dev/null | wc -l`
+	if [ $filecnt -gt 0 ]; then
 		rel=${@os.path.relpath(d.getVar('base_prefix'), d.getVar('datadir') + "/pkgconfig")}
 		sed -i -e "s:${base_prefix}:\${pcfiledir}/$rel:g" ${SYSROOT_DESTDIR}${datadir}/pkgconfig/*.pc
 	fi
-- 
2.17.1



More information about the Openembedded-core mailing list