From: Peter Kjellerstedt <[email protected]>

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 <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
Signed-off-by: Anuj Mittal <[email protected]>
(cherry picked from commit b2a5d9bc61e0b2b7e0f187a262a514952ed30563)
Signed-off-by: Anuj Mittal <[email protected]>
---
 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 da29225983..caa25815e0 100644
--- a/meta/classes/sstate.bbclass
+++ b/meta/classes/sstate.bbclass
@@ -827,14 +827,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 () {
@@ -864,7 +868,7 @@ python sstate_report_unihash() {
 sstate_unpack_package () {
        tar -xvzf ${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
-- 
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#161447): 
https://lists.openembedded.org/g/openembedded-core/message/161447
Mute This Topic: https://lists.openembedded.org/mt/88967925/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to