Can I add multiple alternative repositories to a *.list
file in /etc/apt/sources.list.d
, so that, for a specified package, if the first repository is unavailable, apt-get
will try to download the same package from the next repository in the list?
For example, could I create a file called /etc/apt/sources.list.d/games.list
with the following content?...
deb http://archive.getdeb.net/ubuntu trusty-getdeb apps
deb http://mirrors.dotsrc.org/getdeb/ubuntu trusty-getdeb games
...so that, if http://archive.getdeb.net/ubuntu
is down, will apt-get
automatically try http://mirrors.dotsrc.org/getdeb/ubuntu
?
I believe I have answered my own question:
The behavior of apt-get with sources.list.d is to retrieve packages from the first available repository listed in a given
*.list
file.The repository
archive.getdeb.net/ubuntu
was conveniently down today, so I was able to perform the following experiment to validate this:I created a file called
/etc/apt/sources.list.d/games.list
with the following content:Then I resynchronized the package index files from the sources:
I noticed that apt-get warned that it was ignoring (
Ign
) the repository. This is because apt-get got a 404 message that the URL was not available.Attempting to simulate installation of a package from this repository showed that the repository was indeed not available.
Then I edited
/etc/apt/sources.list.d/games.list
, adding a mirror repository that contains the same packages:As before, I resynchronized the package index files from the sources:
Surprisingly, apt-get warned that it was ignoring both of the repositories!
A little Internet research revealed that apt-get displays an
Ign
warning if a repository is not available or if a package translation is not available. In the case ofmirrors.dotsrc.org
, the repository was up, but apt-get was requesting a translation from English to English, which obviously does not exist. So theIgn
message for the new repository was not an error after all.When I attempted to simulate installation of the same package as before, with both repositories in
/etc/apt/sources.list.d/games.list
, apt-get did find the package.Therefore, the behavior of apt-get with sources.list.d is to retrieve packages from the first available repository listed in a given
*.list
file.