如何告诉 apt 使用 /etc/apt/sources.list.d 中的文件

如何告诉 apt 使用 /etc/apt/sources.list.d 中的文件

我通过将文件放入来添加 repo

 /etc/apt/sources.list.d 

然后我做了一个

 apt-get update.  

但是它没有对该 repo 做任何事情。然后我注意到它似乎没有包含该目录中的任何 repo。apt-get 似乎只注意到了 /etc/apt/sources.list 中的内容。目录中的所有文件都以 .list 结尾,并包含以下内容:

 virtualbox.list

      deb http://download.virtualbox.org/virtualbox/debian oneiric contrib

 pj-assis-ppa-oneiric.list

      deb http://ppa.launchpad.net/pj-assis/ppa/ubuntu oneiric main
      deb-src http://ppa.launchpad.net/pj-assis/ppa/ubuntu oneiric main

我需要在 /etc/apt/sources.list 中放入某种包含语句吗?

我正在使用 kubuntu 11.10。

答案1

如果要将中的文件作为软件源包含在内,则其名称/etc/sources.list.d必须以 结尾。.list

作为sources.list 的手册页说:

描述

   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 #.

来源.列表.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.

举个例子这一页,假设你想安装chef(来自 opscode),你要做的是:

  • 创建并打开一个名为的文件opscode.list
    sudo vim /etc/apt/sources.list.d/opscode.list
  • 添加所需的行并保存文件:
    deb http://apt.opscode.com/ oneiric main

上述步骤可以组合成一个命令:

sudo /bin/sh -c 'echo "deb http://apt.opscode.com/ onereic main" > /etc/apt/sources.list.d/opscode.list'

笔记:该命令包含,onereic因为你使用的 Ubuntu 的代号是奥尼里克. 如果你一直在使用精确的(12.04),你就会有写手precise

答案2

所以问题似乎是我从一个正常的 apt 存储库安装了一个包,我想用一个新的存储库中的一个版本来更新它。显然这是不可能的。我不得不卸载有问题的包,然后在注释掉所有正常存储库的情况下进行安装。我仍然不确定为什么当你执行 apt-get update 时,这些新的存储库都没有显示它们的 URL。

相关内容