可以将 ppa 存储库添加到 /etc/apt/source.list 吗?

Tim*_*Tim 13 package-management apt ppa

通过sudo add-apt-repository '<deb url codename component>',将存储库添加到 /etc/apt/source.list 文件中。

通过sudo add-apt-repository ppa:<user>/<ppa-name>,我看到所有 ppa 存储库都添加到 /etc/apt/source.list.d 目录中:

$ ls /etc/apt/sources.list.d/
ferramroberto-sopcast-precise.list
ferramroberto-sopcast-precise.list.save
google-talkplugin.list
google-talkplugin.list.save
kalakris-okular-precise.list
kalakris-okular-precise.list.save
linrunner-thinkpad-extras-precise.list
linrunner-thinkpad-extras-precise.list.save
precise-partner.list
precise-partner.list.save
staticfloat-julia-deps-precise.list
staticfloat-juliareleases-precise.list
staticfloat-juliareleases-precise.list.save
telepathy-ppa-precise.list
telepathy-ppa-precise.list.save
ubuntu-wine-ppa-precise.list
ubuntu-wine-ppa-precise.list.save
venerix-blug-precise.list
venerix-blug-precise.list.save
Run Code Online (Sandbox Code Playgroud)
  1. 可以将 ppa 存储库添加到 /etc/apt/source.list 文件的末尾吗?

  2. 为什么 ppa 存储库与非 ppa 存储库的处理方式不同?

  3. 是否有其他非 ppa 存储库与 ppa 存储库类似?

  4. 是否会 sudo add-apt-repository '<deb url codename component>'向 /etc/apt/source.list 或 /etc/apt/source.list.d 下的某些文件添加 ppa 存储库?

use*_*.dz 12

  1. 是的,PPA 可以添加到/etc/apt/source.list,类似于 debian (deb) 存储库。

    deb http://ppa.launchpad.net/<ppa-name>/ppa/ubuntu <release-code-name> main 
    deb-src http://ppa.launchpad.net/<ppa-name>/ppa/ubuntu <release-code-name> main
    
    Run Code Online (Sandbox Code Playgroud)

    WineHq 的示例: ppa debian 存储库链接

  2. 只想让事情以某种方式易于管理,只留下/etc/apt/source.list官方发布存储库。所有其他存储库都转到/etc/apt/source.list.d/. 易于:

    1. 添加(创建文件然后编辑现有文件,也是避免重复的部分解决方案)
    2. 删除(通过解析/etc/apt/source.list查找相关行)
    3. 备份/恢复(使用文件/etc/apt/source.list.d/夹的压缩存档)
    4. 避免破坏具有大量编辑目标的东西 /etc/apt/source.list
  3. /etc/apt/source.list.d/如果以ppa:<user>/<ppa-name>表格形式编写,PPA 总是添加到文件夹中。

    参考: man add-apt-repository

    REPOSITORY STRING
           REPOSITORY can  be  either  a  line  that  can  be  added  directly  to
           sources.list(5),  in the form ppa:<user>/<ppa-name> for adding Personal
           Package Archives, or a distribution component to enable.
    
           In  the   first   form,   REPOSITORY   will   just   be   appended   to
           /etc/apt/sources.list.
    
           In  the second form, ppa:<user>/<ppa-name> will be expanded to the full
           deb  line  of  the  PPA  and   added   into   a   new   file   in   the
           /etc/apt/sources.list.d/  directory.   The  GPG public key of the newly
           added PPA will also be downloaded and added to apt's keyring.
    
           In the third form, the given distribution component will be enabled for
           all sources.
    
    Run Code Online (Sandbox Code Playgroud)
  4. 好吧,似乎只有 PPA 作为快捷方式转到/etc/apt/sources.list.d/. add-apt-repository或者apt-add-repository是 Ubuntu 特定的工具。我能想到的只是 Ubuntu 决定将个人 PPA 排除在外。

    但是,您可以将其修改为仅使用/etc/apt/sources.list. 这是一个python3脚本。修改/usr/bin/add-apt-repository行:

    shortcut = shortcut_handler(line)
    
    Run Code Online (Sandbox Code Playgroud)

    用下面的替换它以将 ppa 快捷方式形式解析为 deb 行形式:

    shortcut = shortcut_handler(shortcut_handler(line).expand(sp.distro.codename)[0])
    
    Run Code Online (Sandbox Code Playgroud)