列出添加到我的系统中的所有 ppa 存储库

Pra*_*een 23 apt ppa repository 14.04

如何列出添加到我的系统中的所有 ppa 存储库并将其保存到.txt文件中,这样我就不想花时间搜索 ppa 以进行全新安装,我只需在我的.txt文件中选择一个 ppa 行并附加命令 sudo add-apt-repository?还有没有其他方法可以做到这一点,我不想手动提供 gpg 密钥?

NGR*_*des 20

如何将所有存储库和 PPA 的列表从命令行获取到安装脚本中?

部分答案看起来有你要找的东西:

#! /bin/sh 
# listppa Script to get all the PPA installed on a system ready to share for reininstall
for APT in `find /etc/apt/ -name \*.list`; do
    grep -o "^deb http://ppa.launchpad.net/[a-z0-9\-]\+/[a-z0-9\-]\+" $APT | while read ENTRY ; do
        USER=`echo $ENTRY | cut -d/ -f4`
        PPA=`echo $ENTRY | cut -d/ -f5`
        echo sudo apt-add-repository ppa:$USER/$PPA
    done
done
Run Code Online (Sandbox Code Playgroud)

将此另存为 listppa.sh

listppa.sh > installppa.sh
Run Code Online (Sandbox Code Playgroud)

这将创建一个脚本,您可以将其备份到某处,然后通过简单地运行以下命令在全新安装中添加您的 PPA:

installppa.sh
Run Code Online (Sandbox Code Playgroud)


Rom*_*rio 20

对于那些只想检查他们安装的 PPA 而没有自动对它们进行任何操作的人,您可以执行以下操作:

$ apt-cache policy
Run Code Online (Sandbox Code Playgroud)

在我的系统中,这是它显示的一些内容:

% apt-cache policy
Package files:
 100 /var/lib/dpkg/status
     release a=now
 500 http: ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu/ precise/main Translation-en
 500 http: ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu/ precise/main i386 Packages
     release v=12.04,o=LP-PPA-ubuntu-toolchain-r-test,a=precise,n=precise,l=Toolchain test builds,c=main
     origin ppa.launchpad.net
 500 http: ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu/ precise/main amd64 Packages
     release v=12.04,o=LP-PPA-ubuntu-toolchain-r-test,a=precise,n=precise,l=Toolchain test builds,c=main
     origin ppa.launchpad.net
 500 http: ppa.launchpad.net/rael-gc/scudcloud/ubuntu/ precise/main Translation-en
 500 http: ppa.launchpad.net/rael-gc/scudcloud/ubuntu/ precise/main i386 Packages
     release v=12.04,o=LP-PPA-rael-gc-scudcloud,a=precise,n=precise,l=ScudCloud - Linux client for Slack,c=main
     origin ppa.launchpad.net
...
Run Code Online (Sandbox Code Playgroud)

这里引用:

[ apt-cache policy] 检索与每个存储库资源关联的优先级。从它的输出中,您可以推断出所有可用存储库和 PPA 的列表。

来源:http : //ask.xmodulo.com/list-installed-repositories-ppas-ubuntu.html

  • 这很好也很简单,但是输出还包括 Ubuntu 基础存储库。如果您打算这样做,您也可以使用您提供的链接中使用的完整的最终命令作为源:`apt-cache policy | grep http | awk '{print $2 $3}' | 排序 -u`。输出更有条理,更容易让人眼前一亮。 (5认同)