Ubuntu – How are packages classified in apt-mark showauto/showmanual

apt

I compare the outputs of

$ dpkg --get-selections | grep -v deinstall | awk ' { print $1 } ' > dpkg.txt

$ apt-mark showmanual > manual.txt

$ apt-mark showauto > auto.txt

I think that

  • dpkg.txt will be all packages
  • manual.txt will be "primary" packages
  • auto.txt will be dependencies of packages in manual.txt

I checked and dpkg.txt is the "sum" of auto.txt and manual.txt as I expect but I am seeing "primary" packages such as apport, locate, unzip, zip in auto.txt and lots of lib files (dependencies?) in manual.txt.

Why is that?

I have looked at man apt-mark but that does not explain my question:

       showauto
           showauto is used to print a list of automatically installed packages with each package on a new line. All automatically installed
           packages will be listed if no package is given. If packages are given only those which are automatically installed will be shown.

and

       showmanual
           showmanual can be used in the same way as showauto except that it will print a list of manually installed packages instead.

I also point out that I have not marked packages using apt-mark auto or apt-mark manual.

Please note that I don't have any problems with my system. This is only for my understanding.

Best Answer

We cannot just say that apt-mark showmanual shows only dependecies that are automatically installed.

Some packages which normally would be auto-installed are marked otherwise because they or their depender are in special sections.

So its normal that if you do:

$ apt-get install foo
NEW: foo

you get it as manually installed

on the other hand, if it is:

$ apt-get install foo
NEW: foo foo-data

foo-data will appear as automatical installed.

Morover

If foo is automatical installed and you do:

$ apt-get install foo

at the end of the operation foo will be marked as manually installed.

We are asking a machine to be clever, but machines are idiots. We might not have installed an Xserver,which is there in manually installed (You must be like when did I install Xserver manually), but the installer did because it believes we need it and don't want it removed. The same goes for installing gnome and marking everything gnome depends on as manual because users assume that removing just the (metapackage) gnome will not automatically also remove all the gnome applications they grow used to.

Then we follow a tutorial or we use one of those diseases like crappy installer scripts from dubious sources which just apt-get install everything.

This is distinct from your usecase of getting to know which packages are installed by you rather than some automated process. It might overlap at times, but not always. The big problem you have to face is that it is pretty hard to decide if you or software ordered an installation. Many times its both.

Example: An application which installs packages (for you) to enable hardware support (for you). [do you see what I did here?] Is this auto or manually installed?

First: An auto-installed packages has 'Auto-Installed: 1' Flag set.

Second: If you have no data, default to a safe option and this is here "auto-installed: 0" (= manually installed) as it isn't removing anything.

So you can't just say that one contains completely manually installed and the other one completely automatically installed.

(It has also historical reasons as this tracking wasn't implemented from the beginning and there was a time people cared about upgrades a lot).