如何列出我系统中添加的所有ppa存储库,并将其保存到一个.txt文件中,这样我就不需要花时间在为新安装搜索ppa上,我只需在我的.txt文件中选择一个ppa行并附加到命令sudo add-apt-repository?还有其他方法可以做到这一点,而无需手动提供gpg密钥吗?
$ 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
...
来源:http://ask.xmodulo.com/list-installed-repositories-ppas-ubuntu.html[
apt-cache policy
]检索与每个存储库资源相关联的优先级。通过它的输出,您可以推断出所有可用的存储库和PPA的列表。
从{{link1:如何在命令行中获取所有存储库和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
将此保存为listppa.sh
listppa.sh > installppa.sh
installppa.sh
从我的答案获取到的信息,在如何通过命令行获得所有存储库和PPA的列表,并转成安装脚本?中。
以ppa:用户/仓库
格式列出PPAs:
grep -E '^deb\s' /etc/apt/sources.list /etc/apt/sources.list.d/*.list |\
cut -f2- -d: |\
cut -f2 -d' ' |\
sed -re 's#http://ppa\.launchpad\.net/([^/]+)/([^/]+)(.*?)$#ppa:\1/\2#g' |\
grep '^ppa:'
ppa:USER/REPO
:grep
(不要忘记在sed
命令之后的上一行中删除|\
)。
apt-cache policy | grep http | awk '{print $2 $3}' | sort -u
。这样输出结果更有条理,更容易阅读。 - pjd