Improve heuristic checking if patches should be re-applied
Improve heuristic checking if patches should be re-applied

The "applied" file indicating if a patch has been applied is now
written in the source directory. This allows to check if a source
tree was removed and re-downloaded.

To ensure existing build tree remains in a good state, we also check
if a legacy "applied" file exists.

python-cmake-buildsystem/python-cmake-buildsystem,adrianbroher/python-cmake-buildsystem,davidsansome/python-cmake-buildsystem