* [PATCH] sstate.bbclass: Remove possibility of file corruption and make package writing atomic
@ 2012-03-22 22:47 Richard Purdie
0 siblings, 0 replies; only message in thread
From: Richard Purdie @ 2012-03-22 22:47 UTC (permalink / raw)
To: openembedded-core; +Cc: Polk, Jeffrey
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.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
index 1570654..20e66e2 100644
--- a/meta/classes/sstate.bbclass
+++ b/meta/classes/sstate.bbclass
@@ -455,12 +455,14 @@ python sstate_task_postfunc () {
#
sstate_create_package () {
cd ${SSTATE_BUILDDIR}
+ TFILE=`mktemp ${SSTATE_PKG}.XXXXXXXX`
# Need to handle empty directories
if [ "$(ls -A)" ]; then
- tar -czf ${SSTATE_PKG} *
+ tar -czf $TFILE *
else
- tar -cz --file=${SSTATE_PKG} --files-from=/dev/null
+ tar -cz --file=$TFILE --files-from=/dev/null
fi
+ mv $TFILE ${SSTATE_PKG}
cd ${WORKDIR}
rm -rf ${SSTATE_BUILDDIR}
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2012-03-22 22:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-22 22:47 [PATCH] sstate.bbclass: Remove possibility of file corruption and make package writing atomic Richard Purdie
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.