Fix early script abort

migrate/ is a directory, rm -f does not work on it unless
it would be empty (which it isn't)
Merge pull request #1970 from dirkmueller/master

Fix early script abort
Complete previous fix (7afd4aac)

There were other places where we had the bug.
Merge pull request #1971 from vuntz/master

Complete previous fix (7afd4aac)
we should use CACHE_DIR after resolve its defaults in build_lib.sh