当前位置: 首页>>技术问答>>正文


/etc/apt/sources.list.d上的文件是否需要扩展名为’.list’?

ubuntuer 技术问答 , , , , , 去评论

问题描述

/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文件是某种工作/备份文件:

链接:

  1. http://manpages.ubuntu.com/

次佳解决思路

作为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等文件。

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/2654.html,未经允许,请勿转载。