Skip to contentSkip to conversation

sstate.bbclass: Do not fail if files cannot be touched

PATCH New Peter Kjellerstedt 1 participant 1 message Apr 30, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sstate.bbclass: Do not fail if files cannot be touched

It may be that a file is not allowed to be touched, e.g., if it is a symbolic link into a global sstate cache served over NFS.

---
 meta/classes/sstate.bbclass | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
meta/classes/sstate.bbclass +11 -4
index c73c3b42a7..aa9c30b4e1 100644
@@ -690,7 +690,10 @@ def sstate_package(ss, d):
     if not os.path.exists(siginfo):
         bb.siggen.dump_this_task(siginfo, d)
     else:
-        os.utime(siginfo, None)
+        try:
+            os.utime(siginfo, None)
+        except PermissionError:
+            pass
 
     return
 
@@ -776,7 +779,7 @@ sstate_task_postfunc[dirs] = "${WORKDIR}"
 sstate_create_package () {
 	# Exit early if it already exists
 	if [ -e ${SSTATE_PKG} ]; then
-		touch ${SSTATE_PKG}
+		[ ! -w ${SSTATE_PKG} ] || touch ${SSTATE_PKG}
 		return
 	fi
 
@@ -810,7 +813,7 @@ sstate_create_package () {
 	else
 		rm $TFILE
 	fi
-	touch ${SSTATE_PKG}
+	[ ! -w ${SSTATE_PKG} ] || touch ${SSTATE_PKG}
 }
 
 python sstate_sign_package () {
@@ -1122,7 +1125,11 @@ python sstate_eventhandler() {
         if not os.path.exists(siginfo):
             bb.siggen.dump_this_task(siginfo, d)
         else:
-            os.utime(siginfo, None)
+            try:
+                os.utime(siginfo, None)
+            except PermissionError:
+                pass
+
 }
 
 SSTATE_PRUNE_OBSOLETEWORKDIR ?= "1"
Signature · 1 line
2.21.1