ghc-pkg unregister should complain about breaking dependent packages
|Reported by:||duncan||Owned by:||simonmar|
|Type of failure:||Test Case:|
|Related Tickets:||Differential Revisions:|
Currently it is easy to silently break installed packages. This is particularly bad when users unregister things like 'old' versions of Cabal or bytestring (usually after having installed a new version) because this breaks packages like the ghc api package which cannot be re-installed.
So ghc-pkg unregister should report an error if there are packages that depend on the package being unregistered (at least within the same package db). The error message should report which packages still need the package that the user was trying to unregister and should mention that if they're really really sure that they want to break other said packages that they can run the command again with --force. With --force inplace it should probably still print the warning (for the benefit of log files in packaging systems that may need to use --force if they do not guarantee an order of unregistering).
Example user interaction:
$ ghc-pkg unregister bytestring-0.9.0.1 ghc-pkg: bytestring-0.9.0.1 should not be unregistered because the following registered packages depend on it: ghc-6.8.2. Use --force to unregister anyway and break these packages. You can use ghc-pkg check at any time to see what packages in the broken state due to missing dependencies. $ ghc-pkg unregister bytestring-0.9.0.1 --force ghc-pkg: Warning: due to the forced unregistering of the package bytestring-0.9.0.1, the following packages are now in the broken state: ghc-6.8.2
Incidentally, we should also install a package.conf.shipped to help people recover their ghc installations after they've unwisely and over-zealously gone round unregistering 'old' packages. Debian and Gentoo already do this and it's saved many users.