From d0034ab95e9ca7a7b52e91d0259e13dae4c82f5f Mon Sep 17 00:00:00 2001 From: MilhouseVH Date: Fri, 8 Feb 2019 17:17:43 +0000 Subject: [PATCH] scripts/build: use global lock as sed -i $SYSROOT_PREFIX/usr/lib/*.la is racy --- scripts/build | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/scripts/build b/scripts/build index 46a9e77b7c..8c7c5a473c 100755 --- a/scripts/build +++ b/scripts/build @@ -368,6 +368,14 @@ fi pkg_call_exists post_make_$TARGET && pkg_call post_make_$TARGET +# make install writes directly to sysroot which then needs fixing up - this is racy +if listcontains "configure:target cmake-make:target autotools:target make:target" "${PKG_TOOLCHAIN}:${TARGET}"; then + acquire_exclusive_lock "${PKG_NAME}:${TARGET}" "build" + PKG_NEED_UNLOCK=yes +else + PKG_NEED_UNLOCK=no +fi + # make install pkg_call_exists pre_makeinstall_$TARGET && pkg_call pre_makeinstall_$TARGET @@ -409,6 +417,15 @@ fi pkg_call_exists post_makeinstall_$TARGET && pkg_call post_makeinstall_$TARGET +# This is the racy part - one or more processes may be creating, modifying or deleting +# $SYSROOT_PREFIX/usr/lib/*.la files while another (eg. this) process is rewriting the same +# files as it fixes up the libdir prefix. Eugh. +for i in $(find $SYSROOT_PREFIX/usr/lib/ -name "*.la" 2>/dev/null); do + sed -e "s:\(['= ]\)/usr:\\1$SYSROOT_PREFIX/usr:g" -i $i +done + +[ "${PKG_NEED_UNLOCK}" = "yes" ] && release_exclusive_lock "${PKG_NAME}:${TARGET}" "build" || true + if [ "$TARGET" = "target" -o "$TARGET" = "init" ]; then if [ -d $INSTALL ]; then rm -rf $INSTALL/{usr/,}include @@ -454,10 +471,6 @@ fi cd $ROOT -for i in $(find $SYSROOT_PREFIX/usr/lib/ -name "*.la" 2>/dev/null); do - sed -e "s:\(['= ]\)/usr:\\1$SYSROOT_PREFIX/usr:g" -i $i -done - PKG_DEEPHASH=$(calculate_stamp) for i in PKG_NAME PKG_DEEPHASH BUILD_WITH_DEBUG; do echo "STAMP_$i=\"${!i}\"" >> $STAMP