]> code.ossystems Code Review - openembedded-core.git/commitdiff
sstate: fix touching files inside pseudo
authorJose Quaresma <quaresma.jose@gmail.com>
Wed, 20 Oct 2021 17:25:46 +0000 (18:25 +0100)
committerAnuj Mittal <anuj.mittal@intel.com>
Tue, 26 Oct 2021 00:59:26 +0000 (08:59 +0800)
running the 'id' command inside the sstate_create_package
function shows that this funcion run inside the pseudo:

 uid=0(root) gid=0(root) groups=0(root)

The check for touch files [ ! -w ${SSTATE_PKG} ]
will always return true and the touch can fail
when the real user don't have permission or
in readonly filesystem.

As the documentation refers, the file test operator "-w"
check if the file has write permission (for the user running the test).

We can avoid this test running the touch and mask any return errors
that we have.

Signed-off-by: Jose Quaresma <quaresma.jose@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit f6e7445c94443544e92fda97a017ce93393c5f84)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
meta/classes/sstate.bbclass

index 701a19bc61254dedeab7177806f7b9403ffc23ce..240ae111eef69c4c01c80c41ea5c62c7e66836a8 100644 (file)
@@ -825,7 +825,7 @@ sstate_task_postfunc[dirs] = "${WORKDIR}"
 sstate_create_package () {
        # Exit early if it already exists
        if [ -e ${SSTATE_PKG} ]; then
-               [ ! -w ${SSTATE_PKG} ] || touch ${SSTATE_PKG}
+               touch ${SSTATE_PKG} 2>/dev/null || true
                return
        fi
 
@@ -859,7 +859,7 @@ sstate_create_package () {
        else
                rm $TFILE
        fi
-       [ ! -w ${SSTATE_PKG} ] || touch ${SSTATE_PKG}
+       touch ${SSTATE_PKG} 2>/dev/null || true
 }
 
 python sstate_sign_package () {