50

In /etc/apt/sources.list.d I have several files for custom repositories. All the names of those files end with .list.

Is it obligatory that files in that folder should end with that extension? If yes, where is that information written?

Eliah Kagan
  • 116,445
  • 54
  • 318
  • 493
bessarabov
  • 1,982
  • 6
  • 23
  • 31

3 Answers3

61

Yes, names of files in /etc/sources.list.d must end in .list for lines in the files to be taken as specifying software sources that ought to be used. Otherwise, the files may be taken to have a different meaning.

sources.list

From man sources.list (1):

NAME sources.list - Package resource list for APT

DESCRIPTION

The package resource list is used to locate archives of the package distribution system in use on the system. At this time, this manual page documents only the packaging system used by the Debian GNU/Linux system. This control file is /etc/apt/sources.list.

The source list is designed to support any number of active sources and a variety of source media. The file lists one source per line, with the most preferred source listed first. The format of each line is: type uri args The first item, type determines the format for args. uri is a Universal Resource Identifier (URI), which is a superset of the more specific and well-known Universal Resource Locator, or URL. The rest of the line can be marked as a comment by using a #.

SOURCES.LIST.D

The /etc/apt/sources.list.d directory provides a way to add sources.list entries in separate files. The format is the same as for the regular sources.list file. File names need to end with .list and may only contain letters (a-z and A-Z), digits (0-9), underscore (_), hyphen (-) and period (.) characters. Otherwise APT will print a notice that it has ignored a file if the file doesn't match a pattern in the Dir::Ignore-Files-Silently configuration list - in this case it will be silently ignored...

sources.list.save

The .list.save files are some kind of work/backup files:

Links:

  1. http://manpages.ubuntu.com/
Eliah Kagan
  • 116,445
  • 54
  • 318
  • 493
user26687
  • 14,874
  • 1
  • 38
  • 43
11

As a complement to user26687's answer:

Yes, any file inside /etc/apt/sources.list.d must have a .list extension otherwise apt will print a warning message and ignore the file, except if file matches a pattern in apt's Dir::Ignore-Files-Silently option.

The Software Sources GUI creates a .list.save for each .list file it manages, as a kind of "backup" file. The LP bug 611925 mentioned is from 2010, when apt did not silently ignore .save files yet, and as such generated a lot of warnings.

This behavior was fixed in apt version 0.8.3ubuntu1 in 2010 for LP bug 631770:

apt (0.8.3ubuntu1) maverick; urgency=low

  * merged fixes from debian-sid
  * debian/rules:
    - put ubuntu-archive.gpg back into the package (LP: #620576)
  * apt-pkg/init.cc:
    - ignore ".distUpgrade" and ".save" files in sources.list.d
      (LP: #631770)

Since then such files are silently ignored by apt by default. You can see all such patterns with:

apt-config dump | grep Dir::Ignore-Files-Silently::

So files like .save, .bak, .orig, among others, are also accepted (and ignored) in /etc/apt/sources.list.d

MestreLion
  • 19,731
  • 12
  • 87
  • 108
  • Thanks for such a detailed add-on answer. Added a few tidbits I hadn't run across yet. – SRDC Nov 26 '16 at 00:56
0

You have not mentioned the problem you are having. But to answer your query there has to be one file at /etc/apt/sources.list.d/ for every repository, and there are often two. The required one will end with *.list and the optional one will end with *.list.save (this file is auto-generated by some GUI repository managers). The primary list, managed by the OS, is /etc/apt/sources.list and auxiliary lists can be added to /etc/apt/sources.list.d/your-custom-list-here.list.

SRDC
  • 190
  • 12
Atul Kakrana
  • 559
  • 7
  • 11
  • 1
    I'm not solving any particular problem, I'm just learning how repositories are working in ubuntu. I don't understand why there should 2 files (with the exact content) and why not to use them to add repos. – bessarabov Nov 26 '11 at 08:35
  • 3
    Somewhat misleading answer in several ways: First, `.list.save` files are *not* required, they are sort of backup files created by the `Software Sources` GUI, only the `.list` file is used by the `apt` system; Second, repositories *can* be added to `/etc/apt/sources.list`, but it's not recommended to do so (the OS handles it), so admins and packages are actually *encouraged* to play with `/etc/apt/sources.list.d` – MestreLion May 30 '14 at 09:35
  • For any reader ... the answer has been edited, reflecting the points that @MestreLion raised. – SRDC Nov 26 '16 at 04:54