如何在不添加 PPA 的情况下查看其信息

如何在不添加 PPA 的情况下查看其信息

有没有办法不运行:

sudo apt-add-repository [PPA]

您可以通过终端获取 PPA 的描述(以及可能的其他一些附加信息)吗?

答案1

快速破解(需要包python3-launchpadlib):

#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys,re

from launchpadlib.launchpad import Launchpad
import httplib2
import  lazr.restfulclient.errors

if len(sys.argv) < 2:
    print('Syntax: {cmd} ppa'.format(cmd=sys.argv[0]))
    print()
    print('For example: {cmd}  ppa://diesch/testing'.format(cmd=sys.argv[0]))
    sys.exit(2)


try:
    lp = Launchpad.login_anonymously('foo', 'production', None)
except  httplib2.HttpLib2Error as e:
    print('Error connection to launchpad.net:', e)
    sys.exit(1)


ppa_name = sys.argv[1].strip()

m = re.search(r'^(ppa:)?(?P<user>[^/]+)/(?P<name>.+)', ppa_name)
if m:
    user, name = m.group('user', 'name')
else:
    print('Unvalid PPA name:', ppa)
    sys.exit(1)

try:    
    owner =  lp.people[user]
    ppa = owner.getPPAByName(name=name)

    print('PPA {name} at {url}'.format(name=ppa_name, url=ppa.web_link))
    print()
    print('Owner: {owner} ({url})'.format(owner=owner.display_name,
                                            url=owner.web_link))
    print()
    print(ppa.description) 
except lazr.restfulclient.errors.RestfulError as e:
    print('Error getting PPA info:', e)
    exit(1)

将其另存为例如ppa-info,使其可执行并运行它

ppa-info ppa:diesch/testing

如果 PPA 存在,您将获得一些信息,如所有者和描述,否则您将收到一条错误消息。

答案2

add-apt-repository确认添加 PPA:

$ sudo add-apt-repository ppa:gnome3-team/gnome3
 Before upgrading your system to a new Ubuntu release (i.e. from Ubuntu 14.04 to 14.10), you should probably run 'ppa-purge ppa:gnome3-team/gnome3' first.

*** You need to run 'sudo apt-get dist-upgrade' to avoid problems. ***
Please read the output before entering 'Y' to make sure important packages won't be removed.

=== Ubuntu 14.10 (Utopic) ===
GNOME 3.12 that didn't make it into the normal Ubuntu 14.10 repositories.

=== Ubuntu 14.04 (Trusty) ===
GNOME 3.10 that didn't make it into the normal Ubuntu 14.04 repositories.

=== Ubuntu 12.04 (Precise) ===
Parts of GNOME 3.4 that didn't make it into the normal Ubuntu 12.04 repositories.

=== Bugs ===
On Trusty (14.04) and newer please use 'ubuntu-bug' to report bugs against packages in this PPA
 More info: https://launchpad.net/~gnome3-team/+archive/ubuntu/gnome3
Press [ENTER] to continue or ctrl-c to cancel adding it
^CTraceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 139, in <module>
    sys.stdin.readline()
KeyboardInterrupt

$ sudo add-apt-repository ppa:ondrej/common 
 Lowest common denominator needed to build other packages, a.k.a. build essentials.
 More info: https://launchpad.net/~ondrej/+archive/ubuntu/common
Press [ENTER] to continue or ctrl-c to cancel adding it
^CTraceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 139, in <module>
    sys.stdin.readline()
KeyboardInterrupt

因此,获取 PPA 信息(而不添加它)的最简单方法是运行add-apt-repository,然后按CtrlC

相关内容