如何使用 apt 和 gpg 将 gcc/gpp 6 至 9 从防火墙后面安装到 Xenial 系统上?

如何使用 apt 和 gpg 将 gcc/gpp 6 至 9 从防火墙后面安装到 Xenial 系统上?

我尝试为 Ubuntu 16.04 (xenial) 获取高于 gcc/gpp-5 的编译器。

我将这些行添加到 /etc/apt/sources.list

deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main
deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main

deb http://ppa.launchpad.net/jonathonf/gcc/ubuntu xenial main
deb-src http://ppa.launchpad.net/jonathonf/gcc/ubuntu xenial main

当随后运行“apt update”时,我得到了这个:

Err:9 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial InRelease
 The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 1E9377A2BA9EF27F
Err:16 http://ppa.launchpad.net/jonathonf/gcc/ubuntu xenial InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 8CF63AD3F06FC659

然后我尝试添加键:

# apt-key adv --keyserver keyserver.ubuntu.com --recv-key 1E9377A2BA9EF27F
Executing: /tmp/tmp.hQqulW3vSQ/gpg.1.sh --keyserver
keyserver.ubuntu.com
--recv-key
1E9377A2BA9EF27F
> gpg: requesting key BA9EF27F from hkp server keyserver.ubuntu.com
gpgkeys: key 1E9377A2BA9EF27F not found on keyserver
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0
gpg: keyserver communications error: key not found
gpg: keyserver communications error: bad public key
gpg: keyserver receive failed: bad public key

# apt-key adv --keyserver keyserver.ubuntu.com --recv-key 8CF63AD3F06FC659
Executing: /tmp/tmp.9sbMVJgRDb/gpg.1.sh --keyserver
keyserver.ubuntu.com
--recv-key
8CF63AD3F06FC659
gpg: requesting key F06FC659 from hkp server keyserver.ubuntu.com
gpgkeys: key 8CF63AD3F06FC659 not found on keyserver
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0
gpg: keyserver communications error: key not found
gpg: keyserver communications error: bad public key
gpg: keyserver receive failed: bad public key

如何简单地将一组较新的编译器引入该平台?

我发现在防火墙后面很难实现这样的事情。标准配方不起作用,甚至“sudo -E”对我来说也失败了。我目前不知道如何改进 apt-* 工具集的调试打印。

答案1

(该解决方案的开发部分基于 N0rbert 和我在他的初始提案中的对话)

对问题的理解逐渐深入,发现“gpg”访问是有问题的/悬空的操作。用户“nobar”的评论对于获得最后的线索最有帮助:

gpg: no valid OpenPGP data found.

In this scenario, the message is a cryptic way of telling you that the download failed.

请参阅那里讨论的完整主题:https://stackoverflow.com/questions/21338721/gpg-no-valid-openpgp-data-found

现在就采取措施解决主题中的问题...

http://keyserver.ubuntu.com/- 对于每个丢失的键(BA9EF27F / F06FC659),请执行以下操作:

  • 在提供的输入框中输入每个带有“0x”前缀的缺失键
  • 选择“获取匹配键的详细索引”单选按钮
  • 点击按钮“搜索密钥”
  • 在结果页面中单击“pub”行中的链接,并将目标网页保存到您的下载文件夹(我使用了短 keyId 和 *.txt 扩展名;实际上它是一个 HTML 文件内容,但这是一个不太重要的事情)
  • 以 root 身份对每个下载的文件运行以下命令:

    apt-key add ***name-of-the-file***
    

当上述操作完成两次(每个键一次)后,运行此操作以检查其是否有效:

apt update

结果除了包含其他几行之外还应该包含类似以下几行的内容:

Get:23 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial/main Sources [13.4 kB]
Get:24 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial/main amd64 Packages [86.8 kB]
Get:25 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial/main i386 Packages [85.1 kB]
Get:27 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial/main Translation-en [14.4 kB]
Get:28 http://ppa.launchpad.net/jonathonf/gcc/ubuntu xenial/main Sources [12.1 kB]
Get:29 http://ppa.launchpad.net/jonathonf/gcc/ubuntu xenial/main amd64 Packages [79.7 kB]
Get:30 http://ppa.launchpad.net/jonathonf/gcc/ubuntu xenial/main i386 Packages [78.4 kB]
Get:31 http://ppa.launchpad.net/jonathonf/gcc/ubuntu xenial/main Translation-en [15.7 kB]

最后的操作是安装您选择的额外 gcc 版本:

apt install gcc-6 g++-6
apt install gcc-7 g++-7
apt install gcc-8 g++-8
apt install gcc-9 g++-9

这对我来说终于成功了。所有物品均来自 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu在 amd64 存储库版本中。如果我想在其他 PPA 上设置更高的优先级,我想我需要交换 sources.list 文件中的行。

检查已安装的 gcc 二进制文件的版本现在返回以下文本:

# gcc-6 --version
gcc-6 (Ubuntu 6.5.0-2ubuntu1~16.04) 6.5.0 20181026
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# gcc-7 --version
gcc-7 (Ubuntu 7.4.0-1ubuntu1~16.04~ppa1) 7.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# gcc-8 --version
gcc-8 (Ubuntu 8.3.0-16ubuntu3~16.04) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# gcc-9 --version
gcc-9 (Ubuntu 9.1.0-2ubuntu2~16.04) 9.1.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

检查已安装的 g++ 二进制文件的版本现在返回以下文本:

# g++-6 --version
g++-6 (Ubuntu 6.5.0-2ubuntu1~16.04) 6.5.0 20181026
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# g++-7 --version
g++-7 (Ubuntu 7.4.0-1ubuntu1~16.04~ppa1) 7.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# g++-8 --version
g++-8 (Ubuntu 8.3.0-16ubuntu3~16.04) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# g++-9 --version
g++-9 (Ubuntu 9.1.0-2ubuntu2~16.04) 9.1.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

更新: 这些命令(截至目前)显然使用了 Jonathon PPA:

# apt install clang

目前该命令的结果是:

$ clang --version
clang version 3.8.0-2ubuntu3~trusty5 (tags/RELEASE_380/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

# clang++ --version
clang version 3.8.0-2ubuntu3~trusty5 (tags/RELEASE_380/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

相关内容