Remove broken apt-get repos

Date: 25 Aug, 2013
Posted by: admin
In: hints & tips|linux, open source & software

Bookmark and Share

Post about removing broken repo listings from apt-get sources. It seems that probably ppa-purge and ubuntu-tweak are the tools to use, but this may also help.

Broken apt repositories

Failed to fetch – remove flaky repos

If you’re like me then you pick up a few new apt repositories (“repos”) every now and then when you’re trying out software. A quick add-apt-repository command here, a sources.list entry there et voila! The problem comes when those repos are no longer maintained or drop out of existence and you start getting this sort of cruft in your sudo apt-get update output:


Ign http://gb.archive.ubuntu.com raring-security/main Translation-en_GB
Ign http://gb.archive.ubuntu.com raring-security/multiverse Translation-en_GB
Ign http://gb.archive.ubuntu.com raring-security/restricted Translation-en_GB
Ign http://gb.archive.ubuntu.com raring-security/universe Translation-en_GB
Err http://repo.steampowered.com raring/steam amd64 Packages
404  Not Found [IP: 141.101.116.236 80]
Err http://repo.steampowered.com raring/steam i386 Packages
404  Not Found [IP: 141.101.116.236 80]
Ign http://repo.steampowered.com raring/steam Translation-en_GB
Ign http://repo.steampowered.com raring/steam Translation-en
Ign http://archive.getdeb.net raring-getdeb/games Translation-en_GB
Ign http://archive.getdeb.net raring-getdeb/games Translation-en
Fetched 944 kB in 23s (40.3 kB/s)
W: Failed to fetch http://ppa.launchpad.net/timekpr-maintainers/ppa/ubuntu/dists/raring/main/binary-amd64/Packages  404  Not Found

W: Failed to fetch http://ppa.launchpad.net/timekpr-maintainers/ppa/ubuntu/dists/raring/main/binary-i386/Packages  404  Not Found

W: Failed to fetch http://ppa.launchpad.net/webcontentcontrol/webcontentcontrol/ubuntu/dists/raring/main/binary-amd64/Packages  404  Not Found

W: Failed to fetch http://ppa.launchpad.net/webcontentcontrol/webcontentcontrol/ubuntu/dists/raring/main/binary-i386/Packages  404  Not Found

W: Failed to fetch http://repo.steampowered.com/steam/dists/raring/steam/binary-amd64/Packages  404  Not Found [IP: 141.101.116.236 80]

W: Failed to fetch http://repo.steampowered.com/steam/dists/raring/steam/binary-i386/Packages  404  Not Found [IP: 141.101.116.236 80]

E: Some index files failed to download. They have been ignored, or old ones used instead.

It’s not pretty!

There should be a very simple way to clean up a repo list with failing repos but I’ve not come across it yet. Indeed I’m amazed this isn’t apparently a core feature in apt-get.

Finding broken repos

So first we need to find the repos, grep should help there. Then we’ll want to isolate the sources.list entries corresponding to those repos. Then remove the repos from the lists.

Grepping on apt-get’s output:

~$ sudo apt-get –simulate update | grep Failed
W: Failed to fetch http://ppa.launchpad.net/timekpr-maintainers/ppa/ubuntu/dists/raring/main/binary-amd64/Packages  404  Not Found

W: Failed to fetch http://ppa.launchpad.net/timekpr-maintainers/ppa/ubuntu/dists/raring/main/binary-i386/Packages  404  Not Found

W: Failed to fetch http://ppa.launchpad.net/webcontentcontrol/webcontentcontrol/ubuntu/dists/raring/main/binary-amd64/Packages  404  Not Found

W: Failed to fetch http://ppa.launchpad.net/webcontentcontrol/webcontentcontrol/ubuntu/dists/raring/main/binary-i386/Packages  404  Not Found

W: Failed to fetch http://repo.steampowered.com/steam/dists/raring/steam/binary-amd64/Packages  404  Not Found [IP: 141.101.117.236 80]

W: Failed to fetch http://repo.steampowered.com/steam/dists/raring/steam/binary-i386/Packages  404  Not Found [IP: 141.101.116.236 80]

E: Some index files failed to download. They have been ignored, or old ones used instead.

What does sources.list have to say

Now, one can add repos with the add-apt-repository command. There isn’t a corresponding remove-apt-repository but there is a switch that we can enable. All we need are the repos names. At this point I was expecting to do something like:

~$ grep -i -H timekpr -R /etc/apt/sources.list*
/etc/apt/sources.list.d/timekpr-maintainers-ppa-raring.list:deb http://ppa.launchpad.net/timekpr-maintainers/ppa/ubuntu raring main
/etc/apt/sources.list.d/timekpr-maintainers-ppa-raring.list:# deb-src http://ppa.launchpad.net/timekpr-maintainers/ppa/ubuntu raring main
/etc/apt/sources.list.d/timekpr-maintainers-ppa-raring.list.save:deb http://ppa.launchpad.net/timekpr-maintainers/ppa/ubuntu raring main
/etc/apt/sources.list.d/timekpr-maintainers-ppa-raring.list.save:# deb-src http://ppa.launchpad.net/timekpr-maintainers/ppa/ubuntu raring main

But it turns out that’s not really necessary. The apt repos names are in the simulated grep output above.

All we need then is

~$ sudo add-apt-repository –remove timekpr-maintainers

And we’re golden. That’s all there is to do (for ppa repos at least).

One may also need to do something like

~$ sudo mv $(grep -i –files-with-matches timekpr -R /etc/apt/sources.list*) ~/_backups/old-apt-repos/

and repeat for the different repos found in the simulate command above.

Homework – make a shell script

The last thing is to put all this together in a nice little script – post a link if you’d like to share your attempt, thanks. Something tells me I’m going to need to add in some perl to extract the substrings from the “Failed …” output lines.

One Responses to "Remove broken apt-get repos"

Marsha C. Gallegos says:

Ok well thats for another topic. I’ll tell you that you will always run into issues trying to use Cydia on edge, specially with the amount of repos you have installed, it’s gonna time out over and over.Try rebooting your device or create a topic under general suport forum.


About

Flapjacktastic is just a random collection of musings, hints&tips, notes, information ... a collection of stuff really that's overflowed from the brain of this husband, father, potter, business-man, geek ...

past posts