10 February, 2015

Understanding APT

APT - Advanced Package Tool is a tool in Debian based distros to install applications by fixing missing dependencies and also helps removing them when not required. The command-line utility apt-get is frequently used, while Synaptic is the GUI for the same utility. 

Recently, I encountered an issue with APT. I was trying to install Postgresql by running - 

 sudo apt-get install postgresql 

when it threw a bunch of errors as shown below -
Postgresql Error
So I decided to download the package list from the repositories mentioned in  /etc/apt/sources.list  to obtain the newest version of the packages by running the command:


 sudo apt-get update 

To my surprise, the above command failed to obtain the list by throwing up the below error:
Update failed
I tried to fix the issue by running the command -

 sudo apt-get install apt-transport-https 

and yet another bunch of errors:
Missing Package
Seriously, not my day to install Postgresql. I look up the errors trying to figure out a solution, but unfortunately, I don't find a solution. Instead, I find lots of similar issues. I was told that my sources.list is trying to use https instead of http for obtaining the package list. When I cross checked my sources.list file, I found no reference to https. The bug report showed that the issue is still open. I was determined to give up, but wanted to try one last time to try and fix all the errors. 

I backtracked the errors. So I started with the https issue. I fetched a new sources.list file and still the same error. I realized that maybe I should read what APT is saying. It says - 
Err http://ftp.us.debian.org/debian/ testing/main apt-transport-https amd64 1.0.9.5 404 Not Found [IP: 64.50.236.52 80]

E: Failed to fetch http://ftp.us.debian.org/debian/pool/main/a/apt/apt-transport-https_1.0.9.5_amd64.deb 404 Not Found [IP: 64.50.236.52 80]
I first try to ping the IP but ping failed. So I open a browser and manually track http://ftp.us.debian.org/debian/pool/main/a/apt/. When I search for the package apt-transport-https_1.0.9.5_amd64.deb, it is missing. On close analysis, I find that apt-transport-https_1.0.9.6_amd64.deb is found instead. So I download the new version and manually install it by running the command:

 sudo dpkg -i apt-transport-https_1.0.9.6_amd64.deb 

It installs without a fuss. Finally! So time to update. Now I run, 

 sudo apt-get update 

and it works. I installed postgresql and everything is back to normal. 

Although, I am surprised why APT acted crazy with the update command and pointing to an obsolete package. I'm yet to find the reason and when I do, I might probably write another post.

Until then, it's Just another day in the GNU/Linux world :)

No comments:

Post a Comment