summaryrefslogtreecommitdiffstats
path: root/meta/classes/sstate.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2012-03-22 22:47:24 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-03-23 12:29:56 +0000
commit8dbbbffa11a4251f6868f85f308465670b9655dd (patch)
tree9a6bf622ead1690d8481c75739250c8a776c6781 /meta/classes/sstate.bbclass
parent8350c03eeca3f5d70984797ef784f29c71cbbb3b (diff)
downloadpoky-8dbbbffa11a4251f6868f85f308465670b9655dd.tar.gz
sstate.bbclass: Remove possibility of file corruption and make package writing atomic
There is currently a race window when creating sstate packages since we don't atomically write the files to SSTATE_DIR. This change ensures we do so by writing to a temporary file and then doing an atomic move. (From OE-Core rev: 52bf113e786a57123a9da98f64442afbc2f1471e) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/sstate.bbclass')
-rw-r--r--meta/classes/sstate.bbclass6
1 files changed, 4 insertions, 2 deletions
diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
index 15706541ae..20e66e2742 100644
--- a/meta/classes/sstate.bbclass
+++ b/meta/classes/sstate.bbclass
@@ -455,12 +455,14 @@ python sstate_task_postfunc () {
455# 455#
456sstate_create_package () { 456sstate_create_package () {
457 cd ${SSTATE_BUILDDIR} 457 cd ${SSTATE_BUILDDIR}
458 TFILE=`mktemp ${SSTATE_PKG}.XXXXXXXX`
458 # Need to handle empty directories 459 # Need to handle empty directories
459 if [ "$(ls -A)" ]; then 460 if [ "$(ls -A)" ]; then
460 tar -czf ${SSTATE_PKG} * 461 tar -czf $TFILE *
461 else 462 else
462 tar -cz --file=${SSTATE_PKG} --files-from=/dev/null 463 tar -cz --file=$TFILE --files-from=/dev/null
463 fi 464 fi
465 mv $TFILE ${SSTATE_PKG}
464 466
465 cd ${WORKDIR} 467 cd ${WORKDIR}
466 rm -rf ${SSTATE_BUILDDIR} 468 rm -rf ${SSTATE_BUILDDIR}