當前位置: 首頁>>技術教程>>正文


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

, , , , ,

問題描述

/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/zh-tw/article/2258.html,未經允許,請勿轉載。