找回密码
 立即注册
首页 业界区 安全 在 Debian 中使用 APT 包管理工具通过 Ubuntu PPA 安装 ...

在 Debian 中使用 APT 包管理工具通过 Ubuntu PPA 安装最新软件包

裒噎 2025-6-9 13:48:19
在 Debian 中使用 APT 包管理工具通过 Ubuntu PPA 安装最新软件包

Neovim 0.10.0 在 24 年 5 月发布了. 考虑许久后笔者决定试着从 Vim 9 转向 Neovim. 其中遇到的第一个问题是, Debian 的默认源里只有 Neovim 0.7.7, 因此寻找下载最新软件包的方法, 并做下详细记录.
虽然本文初衷是笔者想要下载最新的 Neovim, 但其中步骤适合所有提供 PPA 的软件包.
警告

笔者的亲身经历: Neovim 的 PPA 虽然出现在了 Neovim 的 INSTALL.md 里, 可实际上并不由 Neovim 的开发团队维护, 从这个 PPA 上下载的 Neovim 并不能正常运作.
一个可行的办法是将源码下载到本地后, 在本地进行编译, 而不是尝试从 PPA 源进行下载.
以下是原文:


什么是 PPA?
PPA 是 Personal Package Archive 的缩写, 是一种开发者(团队)提供的发布软件版本的源. 通常 PPA 会提供比包管理器默认的源更新的版本, 而代价是丧失一部分系统稳定性.
PPA 与 Ubuntu 系统联系紧密,而 Debian 想要将 PPA 作为 APT 的源需要些许额外的步骤。


总体流程:

  • 检查并安装 APT 依赖
  • 添加 PPA 源
  • 导入 PPA Fingerprint(指纹)
  • 更新 APT 数据并安装最新的软件包
检查并安装 APT 依赖


  • 通过 APT 检查 build-essential 与 devscripts 包是否已安装
    使用下述命令检查 build-essential 是否安装
    1. apt list --installed | grep build-essential
    复制代码
    1. $ apt list --installed | grep build-essential
    2. WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
    3. build-essential/stable,now 12.9 amd64 [installed]
    复制代码
    使用下述命令检查 devscripts 是否安装
    1. apt list --installed | grep devscripts
    复制代码
    1. $ apt list --installed | grep devscripts
    2. WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
    3. devscripts/stable,now 2.23.4+deb12u2 amd64 [installed]
    复制代码
    根据系统反馈,笔者已安装相应程序。如果读者还未安装,请使用 APT 安装:
    1. sudo apt-get install build-essential devscripts
    复制代码
  • 为 APT 包管理工具添加 PPA 源

    • 首先找到相应软件的 PPA 源,通常这个网址由开发者提供。笔者在 Neovim/INSTALL.md 中找到了俩个 Neovim 开发者提供的 PPA 源:
      https://launchpad.net/~neovim-ppa/+archive/ubuntu/stable
      https://launchpad.net/~neovim-ppa/+archive/ubuntu/unstable
    • 确认基于当前 Debian 版本的 Ubuntu 版本:
      使用 lsb_release -a 来确认当前 Debian 版本
      1. $ lsb_release -a
      2. No LSB modules are available.
      3. Distributor ID: Debian
      4. Description:    Debian GNU/Linux 12 (bookworm)
      5. Release:        12
      6. Codename:       bookworm
      复制代码
      可见笔者使用的是 Debian 12 Bookworm。
    • 确认基于 Debian 版本的 Ubuntu LTS 版本:
      通过搜索,笔者确认到基于 Debian 12 的 Ubuntu LTS 版本是 22.04 LTS Jammy Jellyfish (见文末 ref 2)
    • 在 Ubuntu PPA 网址上确认对应版本的源,见下图:(以其中一个 PPA 源举例)
      1.png

      可见与 22.04 LTS Jammy Jellyfish 对应的 PPA 源为:
      1. deb https://ppa.launchpadcontent.net/neovim-ppa/unstable/ubuntu jammy main
      2. deb-src https://ppa.launchpadcontent.net/neovim-ppa/unstable/ubuntu jammy main
      复制代码
    • 在 /etc/apt/sources.list.d/ 文件夹下新建一个 neovim.list 文件,并将上述找到的 PPA 源放入其中,以下为笔者创建的文件内容:
      1. # The stable version of Neovimdeb https://ppa.launchpadcontent.net/neovim-ppa/stable/ubuntu jammy maindeb-src https://ppa.launchpadcontent.net/neovim-ppa/stable/ubuntu jammy main# The unstable(latext) version of Neovimdeb https://ppa.launchpadcontent.net/neovim-ppa/unstable/ubuntu jammy main
      2. deb-src https://ppa.launchpadcontent.net/neovim-ppa/unstable/ubuntu jammy main
      复制代码

  • 导入 PPA Fingerprint

    • 找到 PPA Fingerprint,通常由网址提供,见下图为例:
      2.png

    • 将提供的 Fingerprint 加入钥匙链
      sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys FINGERPRINT
      1. $ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 9DBB0BE9366964F134855E2255F96FCF8231B6DD
      2. Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
      3. Executing: /tmp/apt-key-gpghome.zlWaQV2Bs7/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 9DBB0BE9366964F134855E2255F96FCF8231B6DD
      4. gpg: key 55F96FCF8231B6DD: public key "Launchpad PPA for Neovim PPA Team" imported
      5. gpg: Total number processed: 1
      6. gpg:               imported: 1
      复制代码

  • 更新 APT 源,查看可下载的软件包,并指定最新版本下载

    • 使用 sudo apt-get update 进行更新
      1. $ sudo apt update
      2. Ign:1 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm InRelease
      3. Ign:2 https://ppa.launchpadcontent.net/neovim-ppa/stable/ubuntu jammy InRelease
      4. Hit:3 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm-updates InRelease
      5. Hit:4 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm-backports InRelease
      6. Hit:5 https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security InRelease
      7. Hit:1 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm InRelease
      8. Hit:2 https://ppa.launchpadcontent.net/neovim-ppa/stable/ubuntu jammy InRelease
      9. Reading package lists... Done
      10. Building dependency tree... Done
      11. Reading state information... Done
      12. All packages are up to date.
      13. W: https://ppa.launchpadcontent.net/neovim-ppa/stable/ubuntu/dists/jammy/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
      复制代码
      这里出现了一个 Warning, 笔者在文末会将其处理。
    • 使用 apt policy PACKAGE 来检查可安装的软件包
      1. $ apt policy neovim
      2. neovim:
      3.   Installed: (none)
      4.   Candidate: 0.10.0~ubuntu1+git202411301226-c33ec2d7ce-971e32c878-151a855c1b~ubuntu22.04.1
      5.   Version table:
      6.           0.10.0~ubuntu1+git202411301226-c33ec2d7ce-971e32c878-151a855c1b~ubuntu22.04.1 500
      7.                 500 https://ppa.launchpadcontent.net/neovim-ppa/unstable/ubuntu jammy/main amd64 Packages
      8.         0.7.2-7 500
      9.                 500 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm/main amd64 Packages
      10.         0.7.2-3~bpo22.04.1~ppa1 500
      11.                 500 https://ppa.launchpadcontent.net/neovim-ppa/stable/ubuntu jammy/main amd64 Packages
      复制代码
    可见上述在不同的源中,可以安装不同版本的 Neovim。
    当前 APT 会安装的版本会显示在 Candidate 那一行。
    因此,只需使用 sudo apt-get install neovim, 就会自动下载来自 Ubuntu PPA 的最新版本。
    如果想要安装其他版本,需要更改 APT 中源的优先级,请读者另行搜索。

  • 清除 apt-key deprecation 警告,请见 ref 3,答主给出了相当详细的步骤。
ref:

  • LinuxConfig.org: Install Packages From An Ubuntu PPA On Debian Linux
  • AskUbuntu.com: Debian version on which Ubuntu version is based on, by Jacob Vlijm
  • AskUbuntu.com: fix apt-key deprecation warning, by Heynnema

来源:程序园用户自行投稿发布,如果侵权,请联系站长删除
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
您需要登录后才可以回帖 登录 | 立即注册