13

Let's say Ubuntu's repositories features a package.

I install that package using apt-get.

I then add an additional source (with add-apt-repository) that lists either a newer or older version of the package.

Will apt-get always upgrade to the latest version, regardless of which source offers the latest version?

1 Answer 1

15

APT will always install the latest version that isn't excluded by preferences. Preferences are indicated in the file /etc/apt/preferences (and in files under /etc/apt/preferences.d).

Some repositories have a configuration that prevents their packages from being installed automatically. For example, the Debian backports have release files (which you can see in /var/lib/apt/lists) that contain

NotAutomatic: yes
ButAutomaticUpgrades: yes

If you have multiple sources for the exact same package (i.e. same package name, same version number), then APT downloads from the first source found in /etc/apt/sources.list (or /etc/apt/sources.list.d/*; the files are searched in lexicographic order, and the sources are searched in order inside each file). So list local mirrors first. The order in sources.list is irrelevant for packages that have a different version number.

5
  • so for the exact same package (same name, same version number), apt will search in alphabetical order in sources.list.d (and it's sub directories)?
    – Sajuuk
    Oct 17, 2018 at 3:15
  • 1
    @Sajuuk In sources.list first, then in the files in sources.list.d in alphabetical order. Inside each file, it searches in the order the sources are listed in the file. Oct 17, 2018 at 6:22
  • I know, because sources can exist in multiple location, such as /etc/apt/sources.list, and ./etc/apt/sources.list.d/*.list I'm asking in what order would those sources be searched?
    – Sajuuk
    Oct 17, 2018 at 6:24
  • @Sajuuk See my edited comment (I'd pressed Enter before I'd finished typing it). Oct 17, 2018 at 6:26
  • 1
    super tangential, but people, please don't start your setting/variable/etc names with "not". that adds unnecessary logic for everyone.
    – Mike B
    Jan 2, 2022 at 18:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .