From patchwork Sat Jan 22 00:02:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Kjellerstedt X-Patchwork-Id: 2815 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CD3CC433F5 for ; Sat, 22 Jan 2022 00:02:59 +0000 (UTC) Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by mx.groups.io with SMTP id smtpd.web10.2318.1642809776637592860 for ; Fri, 21 Jan 2022 16:02:58 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="signature has expired" header.i=@axis.com header.s=axis-central1 header.b=EAZBR/U/; spf=pass (domain: axis.com, ip: 195.60.68.18, mailfrom: peter.kjellerstedt@axis.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1642809777; x=1674345777; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=dGGmgbocLuVAzrz8vekZROJxkKOtoHU8umRDFuLENiw=; b=EAZBR/U/RUPFfsU6jiJ5U8TsiD0mijMk12MI37LEF/mkYxTH8QnGWxwA 1G9HM7+fR7Ovd1Kd8NABXjS+JE01O+BtGmfuXfHip7PHMZu3xVL713ePT oRCctzS3l3VO3j8neQwvKuMACZT6PjWwLdp5/fxSBI7Kj1bsb+oXbLb1Z +7W+yTBU9o1W+G7cyLLhzKyMneN8VORQFI3ZH1tImxII5/QBsTp4Facxh SELBfODZF2jsi3Z2UvjkKjOW/VRDStIIx/2CK6vjx5Z5hbD+Hn7zvHavh FYAWHRkbMSWBdaUEoFF10/ZCFZvx33/CqWbeKCZKW2iky26iEQWbV33dX g==; From: Peter Kjellerstedt To: Subject: [PATCH] sstate: A third fix for for touching files inside pseudo Date: Sat, 22 Jan 2022 01:02:51 +0100 Message-ID: <20220122000251.19250-1-pkj@axis.com> X-Mailer: git-send-email 2.21.3 MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sat, 22 Jan 2022 00:02:59 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/160852 This continues where commit676757f "sstate: fix touching files inside pseudo" and commit 29fc8599 "sstate: another fix for touching files inside pseudo" left off. The previous changes switched from trying to check if the sstate file is writable before touching it, to always touching the sstate file and ignoring any errors. However, if the sstate file is actually a symbolic link that links to nothing, this would actually result in an empty sstate file being created. And this in turn leads to that future setscene tasks will fail when they try to unpack the empty file. Change the code so that if an sstate file linking to nothing already exists, it is overwritten with the new sstate file. Also change it so that the temporary file that is used is always removed, even if ln fails to link the sstate file to it. Signed-off-by: Peter Kjellerstedt --- meta/classes/sstate.bbclass | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass index b45da4fb23..17dcf4cc17 100644 --- a/meta/classes/sstate.bbclass +++ b/meta/classes/sstate.bbclass @@ -862,14 +862,18 @@ sstate_create_package () { fi chmod 0664 $TFILE # Skip if it was already created by some other process - if [ ! -e ${SSTATE_PKG} ]; then + if [ -h ${SSTATE_PKG} ] && [ ! -e ${SSTATE_PKG} ]; then + # There is a symbolic link, but it links to nothing. + # Forcefully replace it with the new file. + ln -f $TFILE ${SSTATE_PKG} || true + elif [ ! -e ${SSTATE_PKG} ]; then # Move into place using ln to attempt an atomic op. # Abort if it already exists - ln $TFILE ${SSTATE_PKG} && rm $TFILE + ln $TFILE ${SSTATE_PKG} || true else - rm $TFILE + touch ${SSTATE_PKG} 2>/dev/null || true fi - touch ${SSTATE_PKG} 2>/dev/null || true + rm $TFILE } python sstate_sign_package () { @@ -905,7 +909,7 @@ sstate_unpack_package () { tar -I "$ZSTD" -xvpf ${SSTATE_PKG} # update .siginfo atime on local/NFS mirror if it is a symbolic link - [ ! -h ${SSTATE_PKG}.siginfo ] || touch -a ${SSTATE_PKG}.siginfo 2>/dev/null || true + [ ! -h ${SSTATE_PKG}.siginfo ] || [ ! -e ${SSTATE_PKG}.siginfo ] || touch -a ${SSTATE_PKG}.siginfo 2>/dev/null || true # update each symbolic link instead of any referenced file touch --no-dereference ${SSTATE_PKG} 2>/dev/null || true [ ! -e ${SSTATE_PKG}.sig ] || touch --no-dereference ${SSTATE_PKG}.sig 2>/dev/null || true