[cherry-pick from donut branch]
Instead of failing outright when yaffs lies about how much space is
free on the filesystem, delete the partially-written output file and
retry using the copy-source-to-cache method instead.
Change all the log statements to printf; mixing stdout and stderr
logging just makes the logs hard to read because they're buffered
differently.
Turn the bulk of applypatch into a static library so it can be used
from the updater. Also build it as a standalone executable for use by
the existing OTA mechanism.