Switch build scripts to use ESR31 RC tarball instead of hg repository.

Also adds two patches for the tracelogger to fix the build with tracelogging enabled and to fix flushing of tracelogger data to the disk.