Ubuntu 上是否有可用的软件包

Ubuntu 上是否有可用的软件包

我想使用 shell 脚本找出我配置的存储库中是否提供了未安装在 Ubuntu 上的软件包,最好不要使用需要检查命令输出来确定发生了什么的脚本。我可以毫无困难地确定软件包是否已安装,但确定它是否可用又是另一个问题。

答案1

更改redis为您想要检查的任何包。

grep "^Package: redis" /var/lib/apt/lists/*_binary-$(dpkg --print-architecture)_Packages

在我的机器上产量如此。

$ grep "^Package: redis" /var/lib/apt/lists/*_binary-$(dpkg --print-architecture)_Packages
/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic-security_universe_binary-amd64_Packages:Package: redis
/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic-security_universe_binary-amd64_Packages:Package: redis-sentinel
/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic-security_universe_binary-amd64_Packages:Package: redis-server
/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic-security_universe_binary-amd64_Packages:Package: redis-tools
/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_universe_binary-amd64_Packages:Package: redis
/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_universe_binary-amd64_Packages:Package: redis-redisearch
/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_universe_binary-amd64_Packages:Package: redis-redisearch-doc
/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_universe_binary-amd64_Packages:Package: redis-sentinel
/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_universe_binary-amd64_Packages:Package: redis-server
/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_universe_binary-amd64_Packages:Package: redis-tools
/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic-updates_universe_binary-amd64_Packages:Package: redis
/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic-updates_universe_binary-amd64_Packages:Package: redis-sentinel
/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic-updates_universe_binary-amd64_Packages:Package: redis-server
/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic-updates_universe_binary-amd64_Packages:Package: redis-tools
/var/lib/apt/lists/ppa.launchpad.net_chris-lea_redis-server_ubuntu_dists_bionic_main_binary-amd64_Packages:Package: redis
/var/lib/apt/lists/ppa.launchpad.net_chris-lea_redis-server_ubuntu_dists_bionic_main_binary-amd64_Packages:Package: redis-sentinel
/var/lib/apt/lists/ppa.launchpad.net_chris-lea_redis-server_ubuntu_dists_bionic_main_binary-amd64_Packages:Package: redis-server
/var/lib/apt/lists/ppa.launchpad.net_chris-lea_redis-server_ubuntu_dists_bionic_main_binary-amd64_Packages:Package: redis-tools

universe您可以看到它输出来自 Ubuntu 主存储库( )和外部存储库的一个chris-lea/redis-server

假设您要创建一个 shell 脚本,您可以轻松地根据您的需要进行调整。

采取的步骤https://serverfault.com/questions/252333/list-all-packages-from-a-repository-in-ubuntu-debian

相关内容