Package is in a very bad inconsistent state [duplicate]
I tried many things and then this worked!
sudo dpkg --remove --force-all (packagename)
even after this if your problem is not solved then find all the files in /var/lib
named with your package name as a prefix and use
sudo chmod 777 filename
with all of them and then create a copy of them (in case if something goes wrong) and then use
sudo rm filename
to delete of them and then run this again
sudo dpkg --remove --force-all gcc-4.8-base:i386