Use version attribute directly in cache comparisons

The bug that prompted the two relevant commits has since been addressed.

Squashed commit of the following:

commit ecca17ede8324efd1175a42300ace8e1e2df30fa
Author: Jack Nagel <jacknagel@gmail.com>
Date:   Sat Dec 27 16:16:12 2014 -0500

    Revert "Don't use pkg_version when cleaning the cache"

    This reverts commit 4d511b5169d78a5d44bbf6c36c17f0c28014a614.

commit e8935de08f6440ae1874ce523f93b19da6b68df3
Author: Jack Nagel <jacknagel@gmail.com>
Date:   Sat Dec 27 16:16:12 2014 -0500

    Revert "Fix cleanup for head-only formulae"

    This reverts commit 510267ffd314c296c0b0969dd27d130a249f16e2.