当前位置: 首页>>技术教程>>正文


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

, , ,

问题描述

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

最佳方法

对于那些只想检查已安装的 PPA 而不实际自动对其执行任何操作的人,您可以执行以下操作:

$ apt-cache policy

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

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

引自here

\\n

[apt-cache policy] retrieves priorities associated with each repository resource. From\\n its output, you can infer a list of all available repositories and\\n PPAs.

\\n

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

次佳方法

来自How can I get a list of all repositories and PPAs from the command line into an install script?

部分答案看起来有您正在寻找的内容:

#! /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

将其另存为 listppa.sh

listppa.sh > installppa.sh

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

installppa.sh

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/14013.html,未经允许,请勿转载。