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>
 #
 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}