Handle tmp directories correctly.

Make sure we delete tmp directories on failure. Do not delete them when looking
for obsolete packages.