aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2012-03-22 22:47:24 +0000
committerJoshua Lock <josh@linux.intel.com>2012-05-21 22:14:24 -0700
commitd527f68bdf167b4a3dcc035968da59677abb70bb (patch)
treeb53f506bbd99840ae03d8452b9c1867975989946
parent8ca7387ff2dd788221a16021ec98b4aee946a187 (diff)
downloadopenembedded-core-d527f68bdf167b4a3dcc035968da59677abb70bb.zip
openembedded-core-d527f68bdf167b4a3dcc035968da59677abb70bb.tar.gz
openembedded-core-d527f68bdf167b4a3dcc035968da59677abb70bb.tar.bz2
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> Signed-off-by: Joshua Lock <josh@linux.intel.com>
-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 e86085e..d2a45c3 100644
--- a/meta/classes/sstate.bbclass
+++ b/meta/classes/sstate.bbclass
@@ -453,12 +453,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}