A virtual OpenBSD machine as desktop test machine
==================================================

Desktop test machine
--------------------
I wanted to set up a virtual machine as a desktop, in order to
investigate the optimal selection of packages. See also [1].

In search for packages with a lot dependencies
----------------------------------------------
I haven't found a way to list the number of dependencies of an
installed package.

We can however, request the signature string of a package. The
signature string contains some information of the package, as
well as a list of dependencies.

For example:

  pkg_info -S zsh
  Information for inst:zsh-5.9

  Signature: zsh-5.9,10,@libiconv-1.17,@pcre-8.45,c.97.1,curses.14.0,iconv.7.1,m.10.1,pcre.3.0

For some packages, the list with dependencies is much, much
longer.

The signature list can be broken up in a list of dependencies,
but the total length of the list gives a fair estimate. We are
only interested in relative differences.

To get an idea of the length of the signature string, we can
pipe the output of this command through wc -c. This is more
efficient that splitting the signature string for each
package, while still giving a fair insight.

In order to do this for all manual installed packages, I came
up with the following command:

  for file in $(pkg_info -m | sed "s/ .*$//")
  do
  echo $(pkg_info -S $file | wc -c) $file
  done | sort -rn

This command gives us a list of packages, sorted by the length
of their signature string.

Virtual machine
---------------
I started with the installation of a new virtual machine.
OpenBSD 7.4 was just released, so this was a good option to
install a fresh vm with OpenBSD 7.4 on it.

Make sure the disk image is large enough for the installation
of several packages. Make sure that the partitioning uses the
full image. During the initial install, the automatic
partitioning left a large part of the virtual disk unused. I
manually edited the partitioning in order to let OpenBSD use the
whole disk.

I used the qcow2 format, which makes it possible to use
this image to clone it for other machines.

Being very creative, I named the image file "vm1.qcow2".

After the installation is finished, boot the machine up and
issue the command 'syspatch', so we have the latest patches.

Clone the image file
--------------------
With the flag "-b" we can clone a qcow2 image:

  vmctl create -b vm1.qcow2 desktop.qcow2

Do some testing
---------------
Now that we have a pristine installed OpenBSD 7.4 system, we
can install a single package, and see what happens.

The workflow is as follows:

* Start the virtual machine
* Install a single package
* Check how many packages are installed due to
 dependencies
* Halt the virtual machine
* Delete the image
* Clone the pristine image again

Calibre
-------
I started with installing Calibre.

This is the result:

* Only manual installed packages:
 pkg_info -m
 calibre-5.44.0p2    ebook management application
 intel-firmware-20230808v0 microcode update binaries for Intel CPUs
 quirks-6.159        exceptions to pkg_add rules and cache
* All installed packages:
 pkg_info | wc -l
      199

So, installing just Calibre leads to almost 200 packages to be
installed. When going through the list, I see some packages
that will be installed for other purposes too, like gnutls,
hunspell, lz4, sqlite3, tiff, xz, and zstd. But still we can
conclude that Calibre requires a lot of packages.

From this suite, I only use ebook-convert, which is a command
line utility.

So, my first action will be to put Cabibre on a jail on the
central FreeBSD server in my home network, and remove it from
my laptops.

On my X201, I did:

  pkg_delete calibre
  pkg_delete -a

This caused the number of installed packages to go from
481 to 429. This supports our idea that the installation
of calibre on a pristine system install packages that are
a dependency for other packages too.

VLC
---
The next candidate is vlc. I hardly play video's, so let us
try to predict if removing this package does matter.

Installing vlc on a pristine OpenBSD vm gives the following
result:

* Only manual installed packages:
 intel-firmware-20230808v0 microcode update binaries for Intel CPUs
 quirks-6.159        exceptions to pkg_add rules and cache
 vlc-3.0.18p3        VideoLAN client; multimedia player
* All installed packages:
 pkg_info | wc -l
    103

This confirms our idea that this is a good candidate to remove.

Just as with Calibre, I deleted vlc from my X201:

  pkg_delete vlc
  pkg_delete -a

This caused the number of installed packages to go from
429 to 417. So, that is not that drastic, and we still have
to do some work to get this number lower.

Chromium
--------
Next on the list are Gimp and LibreOffice, but I do use these
at least once a month, so I'll keep these.

Next is Chromium. I don't remember having used Chromium on
this laptop. Normally I use as web browser either eww, lynx,
links+, or Firefox.

So, let us fire up a fresh vm and see what happens.

This is the result:

* Only manual installed packages:
 pkg_info -m
 chromium-117.0.5938.149 Chromium browser
 intel-firmware-20230808v0 microcode update binaries for Intel CPUs
 quirks-6.159        exceptions to pkg_add rules and cache
* All installed packages:
 pkg_info | wc -l
       54

This is not as drastic as with Calibre or vlc. But everything
helps, so let's delete that from the X201 too.

  pkg_delete chromium
  pkg_delete -a

This caused the number of installed packages to go from
417 to 415.

Repeat
------
I followed this process, and after deleting some more packages
I ended with 123 manual installed packages, 309 all installed
packages.

Reality check
-------------
The next question is, what is an acceptable number of
packages. For this, I turned things around.

Starting from the list of those manually 123 installed
packages, I created a smaller list, with only the packages
which I know I use. Because I compile Emacs myself, I also
added the packages needed for this.

Again I booted a pristine OpenBSD vm, and now installed
all the packages from this list.

This gave the following results:

* Only manual installed packages:
 pkg_info -m | wc -l
     78
* All installed packages:
 pkg_info | wc -l
    265

Conclusion
----------
Around 300 installed packages (manual and installed
dependencies) seems to be a reasonable amount for a
minimalist desktop system. As stated above, after some
cleaning up the packages on my OpenBSD X201 laptop there are
now in total 309 installed packages. So that looks OK.

Let's see how that is in a couple of months :)

[1]: gopher://box.matto.nl/0/too-many-packages-on-my-openbsd-laptop.txt


Last edited: $Date: 2023/10/17 18:38:04 $