问题描述
在/etc/apt/sources.list.d
中,我有几个自定义存储库文件。这些文件的所有名称都以.list
结尾。
该文件夹中的文件是否必须以该扩展名结尾?如果是,那么该信息写在哪里?
最佳解决方案
是的,/etc/sources.list.d
中的文件名必须以.list
结尾,以便将文件中的行作为指定应使用的软件源。否则,文件可能被视为具有不同的含义。
的sources.list
来自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…
.list.save
文件是某种工作/备份文件:
链接:
次佳解决方案
作为user26687答案的补充:
是的,/etc/apt/sources.list.d
中的任何文件必须具有.list
扩展名,否则apt
将打印警告消息并忽略该文件,除非文件与apt的Dir::Ignore-Files-Silently
选项中的模式匹配。
Software Sources
GUI为其管理的每个.list
文件创建一个.list.save
,作为一种”backup”文件。提到的LP bug 611925是从2010年开始的,当时apt还没有默默地忽略.save
文件,因此产生了很多警告。
此行为已于2010年针对LP bug 631770的apt版本0.8.3ubuntu1
中修复:
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)
从那时起,默认情况下,apt
会默默忽略此类文件。你可以看到所有这些模式:
apt-config dump | grep Dir::Ignore-Files-Silently::
所以在/etc/apt/sources.list.d
中也接受(和忽略).save
,.bak
,.orig
等文件。