jblakeman / apt-select

Ubuntu Archive Mirror reporting tool for apt sources configuration.
MIT License
333 stars 44 forks source link

Fails to consider `mirror` scheme #72

Open solsticedhiver opened 6 years ago

solsticedhiver commented 6 years ago

With (newer ?) ubuntu release, one can use a mirror protocol that use directly the mirrors from mirrors.ubuntu.com

Tihs means lines in sources.list looks like this:

deb mirror://mirrors.ubuntu.com/mirrors.txt [...]

When this is set in sources.list, then apt-select bails out with the error:

Traceback (most recent call last):
  File "/home/solstice/.local/bin/apt-select", line 11, in <module>
    sys.exit(main())
  File "/home/solstice/.local/lib/python2.7/site-packages/apt_select/__main__.py", line 244, in main
    apt_select()
  File "/home/solstice/.local/lib/python2.7/site-packages/apt_select/__main__.py", line 175, in apt_select
    sources.set_current_archives()
  File "/home/solstice/.local/lib/python2.7/site-packages/apt_select/apt.py", line 164, in set_current_archives
    self.skip_gen_msg)
apt_select.apt.SourcesFileError: Error finding current main URI in /etc/apt/sources.list
Skipping file generation
jblakeman commented 6 years ago

@solsticedhiver Happy to hear you are using the script. However, if that is the only line in your file with a deb or deb-src definition, it will not work.

apt-select is meant to be a supplement to the mirror:// method in that it tests latency. It does not support generating a new sources.list from scratch. The file generation is meant to replace existing mirror definitions with better ones. mirror://mirrors.ubuntu.com/mirrors.txt is not actually a valid mirror because mirror is not a supported scheme (see man sources.list -> URI Specification, and the list of supported URI schemes in theREADME). Please try using the script with mirror definitions line like:

deb http://archive.ubuntu.com/ubuntu/ bionic main restricted

Thanks!

Close duplicate to #3.

solsticedhiver commented 6 years ago

the sources.list contained only lines with mirror://. It was generated by "Software and mirrors"

Look for yourself at the man page: The mirror protocol is a valid one in 'cosmic': http://manpages.ubuntu.com/manpages/cosmic/en/man5/sources.list.5.html#uri%20specification

It appaears to be a new thing because it does not show up in man page of previous release of ubuntu.

I don't see why you closed that bug without fixing it.

It is just a matter to adapt your script so that it takes into account the presence of mirror:// and replace with whatever you find as best.

jblakeman commented 6 years ago

@solsticedhiver ok so by “newer” you mean 18.10 cosmic. That is the only distribution that specifies mirror as a scheme.

According to the man page it represents the location of a mirror list so it wouldn’t make sense for apt-select to assume that it should be replaced by some single http mirror.

I’m not sure what “Software and mirrors” is, but that’s irrelevant because apt-select and mirror scheme now conflict. The thing is, we now have a --country argument that defaults to US. It was a result of a period where http://mirrors.ubuntu.com/mirrors.txt was not dynamically generating a list of mirrors based on the machine's location (see #62).

solsticedhiver commented 6 years ago

OK. I understand.

But I don't see the big deal given that you create a new sources.list and do not replace the exisitng one. And why not replace a mirror://something with a http:// if the mirror given is bad and you get a better one with apt-select test ?

jblakeman commented 6 years ago

Reopening, because the confusion around the mirror scheme is understandable, especially now that it's officially supported in 18.10. A section could probably be added to the README explaining the differences in approaches and perhaps that mirror://mirrors.ubuntu.com/mirrors.txt is not actually a mirror, which is one of the reasons why we ignore it.

Now that I think about it though, it might be a cool feature to detect mirror schemed URIs and use them if no --country definition were specified. But with that comes more scope and complexity like having to make decisions about:

All worth exploring, but not a tiny amount of work and I'm quite busy these days.