pkg.removed and purged implements version comparison

One should be able to remove packages only if they match specified version.

It should implement the feature described in #15541 but need testing with other configurations and maybe some more documentation.