1

I'm working on a successor of auto-apt which indexes package information used by apt and traces I/O requests of files contained in those packages as a program wrapper and installes them automatically.

Therefore I'd like to know how many packages there're roughly in Ubuntu (the potency of 10 is sufficient), so that I can conduct some estimates on algorithmic complexity.

The original code seems unmaintained for decades and the author isn't reachable under the last know address (I wrote him ~ a year ago, but he didn't reply). The program seems to have been kicked out of Ubuntu in 17.10. Furthermore the code is complete comment- and test-free (don't ever do that, please!) and I need to guess what the purpose of a tree-like data structure was (could have been a programming challenge) and whether I can just replace it with a fast third-party key-value implementation.

2
  • 4
    Possible duplicate of How many packages are in the main repository? Jan 8, 2018 at 15:08
  • 2
    @ThomasWeller I needed to change the meaning to ask about a rough estimate of all files in all packages because I missed that I don't want to know the number of packages only, but the number of files in them, sorry. Jan 8, 2018 at 15:41

2 Answers 2

2

The apt-file command can be used to look up which package provides a given file. You need to run apt-file update so that it can download the file listing, and:

$ 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

So Contents-amd64.gz is a 31 MB file after compression. Opening it in Vim, I see it has 5400831 lines, with about 30 lines in this header:

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

So, we have:

5.4 million files, give or take a few.

2
  • You probably want to also count at least xenial-updates and xenial-security.
    – fkraiem
    Jan 9, 2018 at 10:20
  • @fkraiem Dunno, those don't add packages to that are not in xenial, AFAIK, but xenial-backports might be worth counting.
    – muru
    Jan 9, 2018 at 10:24
2

On my 17.10 system I have 181,367 files and directories installed (this number is displayed, for example, whenever you apt install something) in 1,360 packages (apt list --installed | wc -l). That's an average of about 133 files/directories per package.

There are 58,108 packages in 17.10 (apt list | grep -c artful), so assuming my installed packages are representative this yields roughly 7,749,038 files and directories.

1
  • This average of 133 f/d seems good, I almost have twice as many package as you do, and I get 140 f/d (330609 files for 2350 packages) - if you need some kind of confirmation ;)
    – N. Cornet
    Jan 9, 2018 at 10:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .