diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-03-22 22:47:24 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-03-23 12:22:39 +0000 |
commit | 52bf113e786a57123a9da98f64442afbc2f1471e (patch) | |
tree | 8622fa162f8a0b12c2fcd98ee9c535879057a714 /meta/classes/sstate.bbclass | |
parent | a5e2277c53a8345a096eee8ccd9622838574a240 (diff) | |
download | openembedded-core-52bf113e786a57123a9da98f64442afbc2f1471e.tar.gz openembedded-core-52bf113e786a57123a9da98f64442afbc2f1471e.tar.bz2 openembedded-core-52bf113e786a57123a9da98f64442afbc2f1471e.tar.xz openembedded-core-52bf113e786a57123a9da98f64442afbc2f1471e.zip |
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.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/sstate.bbclass')
-rw-r--r-- | meta/classes/sstate.bbclass | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass index 15706541a..20e66e274 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} |