Thanks to this post you can manually remove an ubuntu/debian package doing the following:
dpkg -P packagex
Likely this will still fail so do:
dpkg -L packagex
this will give you a list of files to delete when the next step is done.
Then go to the directory:
and delete the file:
apt-get remove --purge packagex
apt-get -f install
to finish up, remove all files you found in the 'dpkg -L' step, and directories specific to packagex.
Then run apt-get update