Categories
Development Linux Ubuntu

How to check if a given PPA or repository is available

I am working on generating some auto install scripts that would work on different versions of Ubuntu. Therefore, I try to keep the add-apt-repository statements generic as seen below.

add-apt-repository -y "deb http://archive.canonical.com/ $(lsb_release -sc) partner"
add-apt-repository -y ppa:graphics-drivers

However, as some repos don’t exist for certain versions, auto generated urls might lead to errors like below.

Err:22 http://ppa.launchpad.net/wireshark-dev/stable/ubuntu disco Release
    404  Not Found [IP: 91.189.95.83 80]

E: The repository 'http://ppa.launchpad.net/wireshark-dev/stable/ubuntu disco Release' does not have a Release file.
N: Updating from such a repository can't be done securely, an is therefore disabled by default.

I know that this can’t be kept 100% flexible across all versions without keeping ubuntu version vs package repo lookup tables/if-else statements. However, for my simple purposes, it is enough to know if any given url/ppa is valid or not.

So, is there a way to test this without adding the url/ppa and seeing it to fail on next apt update?

Leave a Reply

Your email address will not be published. Required fields are marked *