我从 20.04 正式升级到 22.04 后尝试安装 php7.4
cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"
运行add-apt-repository ppa:ondrej/php
结果出现如下错误:
Traceback (most recent call last):
File "/usr/bin/add-apt-repository", line 364, in <module>
sys.exit(0 if addaptrepo.main() else 1)
File "/usr/bin/add-apt-repository", line 347, in main
shortcut = handler(source, **shortcut_params)
File "/usr/lib/python3/dist-packages/softwareproperties/shortcuts.py", line 40, in shortcut_handler
return handler(shortcut, **kwargs)
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 82, in __init__
if self.lpppa.publish_debug_symbols:
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 120, in lpppa
self._lpppa = self.lpteam.getPPAByName(name=self.ppaname)
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 107, in lpteam
self._lpteam = self.lp.people(self.teamname)
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 98, in lp
self._lp = login_func("%s.%s" % (self.__module__, self.__class__.__name__),
File "/usr/lib/python3/dist-packages/launchpadlib/launchpad.py", line 494, in login_anonymously
return cls(
File "/usr/lib/python3/dist-packages/launchpadlib/launchpad.py", line 230, in __init__
super(Launchpad, self).__init__(
File "/usr/lib/python3/dist-packages/lazr/restfulclient/resource.py", line 472, in __init__
self._wadl = self._browser.get_wadl_application(self._root_uri)
File "/usr/lib/python3/dist-packages/lazr/restfulclient/_browser.py", line 451, in get_wadl_application
return Application(url, content)
File "/usr/lib/python3/dist-packages/wadllib/application.py", line 1139, in __init__
self.doc = self._from_string(markup)
File "/usr/lib/python3/dist-packages/wadllib/application.py", line 1178, in _from_string
return self._from_stream(io.BytesIO(markup))
File "/usr/lib/python3/dist-packages/wadllib/application.py", line 1163, in _from_stream
for event, elem in ET.iterparse(stream, events):
File "/usr/lib/python3.10/xml/etree/ElementTree.py", line 1260, in iterator
yield from pullparser.read_events()
File "/usr/lib/python3.10/xml/etree/ElementTree.py", line 1331, in read_events
raise event
File "/usr/lib/python3.10/xml/etree/ElementTree.py", line 1303, in feed
self._parser.feed(data)
xml.etree.ElementTree.ParseError: mismatched tag: line 16, column 14
python -V
Python 3.10.4
我看到其他几篇帖子讨论了可能的解决方案。我添加了语言包,但尝试手动添加存储库并导入公钥不起作用。
我尝试的手动方法不起作用。输出:
gpg --keyserver keyserver.ubuntu.com --recv 4F4EA0AAE5267A6C
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key 4F4EA0AAE5267A6C: public key "Launchpad PPA for Ondřej Surý" imported
gpg: Total number processed: 1
gpg: imported: 1
apt update
Hit:1 http://us.archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://us.archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu jammy-backports InRelease
Get:4 http://us.archive.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Hit:5 http://nginx.org/packages/mainline/ubuntu focal InRelease
Get:6 http://ppa.launchpad.net/ondrej/php/ubuntu jammy InRelease [23.9 kB]
Err:6 http://ppa.launchpad.net/ondrej/php/ubuntu jammy InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4F4EA0AAE5267A6C
Reading package lists... Done
W: GPG error: http://ppa.launchpad.net/ondrej/php/ubuntu jammy InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4F4EA0AAE5267A6C
E: The repository 'http://ppa.launchpad.net/ondrej/php/ubuntu jammy InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
添加后检查密钥显示 ppa repo 密钥存在
apt-key list
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
/etc/apt/trusted.gpg
--------------------
pub rsa1024 2009-01-26 [SC]
14AA 40EC 0831 7567 56D7 F66C 4F4E A0AA E526 7A6C
uid [ unknown] Launchpad PPA for Ondřej Surý
pub rsa4096 2012-05-11 [SC]
790B C727 7767 219C 42C8 6F93 3B4F E6AC C0B2 1F32
uid [ unknown] Ubuntu Archive Automatic Signing Key (2012) <[email protected]>
/etc/apt/trusted.gpg.d/ubuntu-keyring-2018-archive.gpg
------------------------------------------------------
pub rsa4096 2018-09-17 [SC]
F6EC B376 2474 EDA9 D21B 7022 8719 20D1 991B C93C
uid [ unknown] Ubuntu Archive Automatic Signing Key (2018) <[email protected]>
但是 apt update 仍然提示它没有公钥??
pt update
Hit:1 http://us.archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://us.archive.ubuntu.com/ubuntu jammy-updates InRelease [109 kB]
Hit:3 http://us.archive.ubuntu.com/ubuntu jammy-backports InRelease
Get:4 http://us.archive.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Get:5 http://ppa.launchpad.net/ondrej/php/ubuntu jammy InRelease [23.9 kB]
Hit:6 http://nginx.org/packages/mainline/ubuntu focal InRelease
Err:5 http://ppa.launchpad.net/ondrej/php/ubuntu jammy InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4F4EA0AAE5267A6C
Reading package lists... Done
W: GPG error: http://ppa.launchpad.net/ondrej/php/ubuntu jammy InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4F4EA0AAE5267A6C
E: The repository 'http://ppa.launchpad.net/ondrej/php/ubuntu jammy InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
我在这里遗漏了什么? 钥匙是存在的,为什么 apt 表现得好像不存在一样?
编辑:正如我上面提到的,使用 apt-key 或 gpg 添加密钥不起作用。