Package Installation Issues in Ubuntu 12.04

Even though Ubuntu 12.04 shipped with the LTS (long term support) label, looks like that long term is over. A lot of people have already run into problems installing packages. I was getting this message:

Err http://us.archive.ubuntu.com/ubuntu/ quantal-updates/main  
404 Not Found [IP: 91.189.91.13 80]  
Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/  
404 Not Found [IP: 91.189.91.13 80]  
E: Unable to fetch some archives, maybe run apt-get update or try with -fix-missing?

Turns out a lot of repositories were disabled in favor of the OS’s 14th version. If, like me, you don’t have time to upgrade to version 14, here’s a quick solution:

Go to the apt folder:

cd /etc/apt

Rename the file with the list of repositories:

sudo mv sources.list sources.list.old

Get the list of currently active software sources and build a new sources.list from it:

sudo cat sources.list.old |grep quantal |grep -v `#` |sed 's|**us.archive**.|**old-releases**.|g' >> sources.list

In our case we’re replacing us.archive with old-releases in the addresses of the active repositories.

At this point you can already run:

sudo apt-get update

And try installing the package you need. If your system still refuses to cooperate, run this sequence of commands:

cd /var/lib/apt  
sudo mv lists lists.old  
sudo mkdir -p lists/partial  
sudo apt-get clean  
sudo apt-get update