relocatable: add file existence checking in relocatable_native_pcfiles
Quoted 45 lines
-----Original Message-----
From: [email protected] <openembedded- [email protected]> On Behalf Of Jiang Lu
Sent: den 20 mars 2019 10:39
To: [email protected]; [email protected]; [email protected]
Subject: [OE-core] [PATCH 4/4] relocatable: add file existence checking inrelocatable_native_pcfilesSome 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 directoryTo avoid this, add a file existence checking in
relocatable_native_pcfiles()
before sed.Signed-off-by Jiang Lu <[email protected]>--- meta/classes/relocatable.bbclass | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)meta/classes/relocatable.bbclass +4
-3@@ -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 --
Quoted 1 line
2.17.1
May I suggest the following instead:
relocatable_native_pcfiles () {
files=$(find ${SYSROOT_DESTDIR}${libdir}/pkgconfig -name '*.pc' 2>/dev/null)
if [ "$files" ]; then
rel=${@os.path.relpath(d.getVar('base_prefix'), d.getVar('libdir') + "/pkgconfig")}
sed -i -e "s:${base_prefix}:\${pcfiledir}/$rel:g" $files
fi
files=$(find ${SYSROOT_DESTDIR}${datadir}/pkgconfig -name '*.pc' 2>/dev/null)
if [ "$files" ]; then
rel=${@os.path.relpath(d.getVar('base_prefix'), d.getVar('datadir') + "/pkgconfig")}
sed -i -e "s:${base_prefix}:\${pcfiledir}/$rel:g" $files
fi
}//Peter