我正在研究一个后续程序,它以程序包装器的形式auto-apt
索引所使用的包信息并跟踪这些包中包含的文件的 I/O 请求并自动安装它们。apt
因此我想知道 Ubuntu 中大约有多少个软件包(10 个就足够了),以便我可以对算法复杂度进行一些估算。
原始代码似乎几十年来都没有维护过,而且作者在最后一个已知地址下无法联系到(我大约在一年前写信给他,但他没有回复)。该程序似乎已在 17.10 版中被踢出 Ubuntu。此外,代码完全没有注释和测试(千万不要这样做!),我需要猜测树状数据结构的用途是什么(这可能是一个编程挑战),以及我是否可以用快速的第三方键值实现来替换它。
答案1
该apt-file
命令可用于查找哪个包提供了给定的文件。您需要运行apt-file update
以便它可以下载文件列表,然后:
$ apt-file update
apt-file is now using the user's cache directory.
If you want to switch back to the system-wide cache directory,
run 'apt-file purge'
Downloading complete file http://jp.archive.ubuntu.com/ubuntu/dists/xenial/Contents-amd64.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
9 31.7M 9 2927k 0 0 282k 0 0:01:54 0:00:10 0:01:44 481k
压缩后的文件大小为Contents-amd64.gz
31 MB。在 Vim 中打开它,我看到它有 5400831 行,其中约 30 行位于此标题中:
This file maps each file available in the Ubuntu
system to the package from which it originates. It includes packages
from the DIST distribution for the ARCH architecture.
You can use this list to determine which package contains a specific
file, or whether or not a specific file is available. The list is
updated weekly, each architecture on a different day.
When a file is contained in more than one package, all packages are
listed. When a directory is contained in more than one package, only
the first is listed.
The best way to search quickly for a file is with the Unix `grep'
utility, as in `grep <regular expression> CONTENTS':
$ grep nose Contents
etc/nosendfile net/sendfile
usr/X11R6/bin/noseguy x11/xscreensaver
usr/X11R6/man/man1/noseguy.1x.gz x11/xscreensaver
usr/doc/examples/ucbmpeg/mpeg_encode/nosearch.param graphics/ucbmpeg
usr/lib/cfengine/bin/noseyparker admin/cfengine
This list contains files in all packages, even though not all of the
packages are installed on an actual system at once. If you want to
find out which packages on an installed Debian system provide a
particular file, you can use `dpkg --search <filename>':
$ dpkg --search /usr/bin/dselect
dpkg: /usr/bin/dselect
FILE LOCATION
因此,我们有:
540 万个文件,多或少。
答案2
在我的 17.10 系统上,我安装了 181,367 个文件和目录(例如,每当您apt install
执行某些操作时都会显示此数字),这些文件和目录分布在 1,360 个软件包中 ( apt list --installed | wc -l
)。平均每个软件包大约有 133 个文件/目录。
17.10 () 中有 58,108 个软件包apt list | grep -c artful
,因此假设我安装的软件包具有代表性,则大约有 7,749,038 个文件和目录。