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

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

通过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
  1. 可以将 ppa 存储库添加到 /etc/apt/source.list 文件的末尾吗?

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

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

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

答案1

  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
    

    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 总是会被添加到文件夹中ppa:<user>/<ppa-name>

    参考: 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.
    
  4. 嗯,似乎只有 PPA 作为快捷方式进入/etc/apt/sources.list.d/.add-apt-repositoryapt-add-repository是 Ubuntu 特定工具。我能想到的只是 Ubuntu 决定将个人 PPA 排除在外。

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

    shortcut = shortcut_handler(line)
    

    将其替换为下面的内容,以将 ppa 快捷方式形式解析为 deb 行形式:

    shortcut = shortcut_handler(shortcut_handler(line).expand(sp.distro.codename)[0])
    

相关内容