Why does libvirt-daemon-system have so many dependencies on Debian?

On my headless debian 11 (bullseye) server, when I attempt to install libvirt-daemon-system, apt threatens to basically install an entire graphical environment, including audio libraries and everything:

mic@micserver:~$ sudo apt install libvirt-daemon-system
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  adwaita-icon-theme alsa-topology-conf alsa-ucm-conf at-spi2-core augeas-lenses dbus-user-session dconf-gsettings-backend dconf-service fontconfig glib-networking glib-networking-common
  glib-networking-services gsettings-desktop-schemas gstreamer1.0-libav gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-x gtk-update-icon-cache hicolor-icon-theme i965-va-driver
  ibverbs-providers intel-media-va-driver ipxe-qemu jq libaa1 libaacs0 libasound2 libasound2-data libass9 libasyncns0 libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data libatspi2.0-0 libaugeas0 libavc1394-0
  libavcodec58 libavfilter7 libavformat58 libavutil56 libbdplus0 libbluray2 libbrlapi0.8 libbs2b0 libcaca0 libcacard0 libcairo-gobject2 libcairo2 libcapstone4 libcdparanoia0 libchromaprint1 libcodec2-0.9
  libcolord2 libdatrie1 libdaxctl1 libdconf1 libdrm-amdgpu1 libdrm-common libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libdrm2 libdv4 libdw1 libepoxy0 libexecs0 libfdt1 libflac8 libflite1 libfribidi0 libgbm1
  libgdk-pixbuf-2.0-0 libgdk-pixbuf2.0-bin libgdk-pixbuf2.0-common libgfortran5 libgl1 libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libgme0 libgraphite2-3 libgsm1 libgstreamer-plugins-base1.0-0
  libgstreamer1.0-0 libgtk-3-0 libgtk-3-bin libgtk-3-common libgudev-1.0-0 libharfbuzz0b libibverbs1 libiec61883-0 libigdgmm11 libjack-jackd2-0 libjq1 libjson-glib-1.0-0 libjson-glib-1.0-common liblapack3
  liblilv-0-0 libmfx1 libmp3lame0 libmpg123-0 libmysofa1 libndctl6 libnetcf1 libnl-route-3-200 libnorm1 libogg0 libopenmpt0 libopus0 liborc-0.4-0 libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libparted2
  libpciaccess0 libpgm-5.3-0 libpixman-1-0 libpmem1 libpocketsphinx3 libpolkit-agent-1-0 libpolkit-gobject-1-0 libpostproc55 libproxy1v5 libpulse0 libquadmath0 librabbitmq4 libraw1394-11 librdmacm1
  librest-0.7-0 librsvg2-2 librsvg2-common librubberband2 libsamplerate0 libserd-0-0 libshine3 libshout3 libslirp0 libsndfile1 libsord-0-0 libsoup-gnome2.4-1 libsoup2.4-1 libsoxr0 libspeex1 libsphinxbase3
  libspice-server1 libsratom-0-0 libsrt1.4-gnutls libssh-gcrypt-4 libswresample3 libswscale5 libtag1v5 libtag1v5-vanilla libthai-data libthai0 libtheora0 libtwolame0 libudfread0 libunwind8 liburing1
  libusbredirparser1 libv4l-0 libv4lconvert0 libva-drm2 libva-x11-2 libva2 libvdeplug2 libvdpau-va-gl1 libvdpau1 libvidstab1.1 libvirglrenderer1 libvirt-clients libvirt-daemon libvirt-daemon-config-network
  libvirt-daemon-config-nwfilter libvirt-daemon-driver-lxc libvirt-daemon-driver-vbox libvirt-daemon-driver-xen libvisual-0.4-0 libvorbis0a libvorbisenc2 libvorbisfile3 libvpx6 libvte-2.91-0 libvte-2.91-common
  libvulkan1 libwavpack1 libwayland-client0 libwayland-cursor0 libwayland-egl1 libwayland-server0 libx11-xcb1 libx264-160 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-render0
  libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcomposite1 libxcursor1 libxdamage1 libxencall1 libxendevicemodel1 libxenevtchn1 libxenforeignmemory1 libxengnttab1 libxenhypfs1 libxenmisc4.14 libxenstore3.0
  libxentoolcore1 libxentoollog1 libxfixes3 libxinerama1 libxkbcommon0 libxml2-utils libxrandr2 libxshmfence1 libxv1 libxvidcore4 libxxf86vm1 libzmq5 libzvbi-common libzvbi0 mdevctl mesa-va-drivers
  mesa-vdpau-drivers mesa-vulkan-drivers ocl-icd-libopencl1 ovmf parted pocketsphinx-en-us policykit-1 qemu-system-common qemu-system-data qemu-system-gui qemu-system-x86 qemu-utils seabios va-driver-all
  vdpau-driver-all

I don’t understand where this is coming from, though. Looking at apt-cache dependencies, the package seems much more sane:

mic@micserver:~$ apt-cache depends libvirt-daemon-system
libvirt-daemon-system
  Depends: adduser
  Depends: gettext-base
 |Depends: iptables
  Depends: firewalld
  Depends: libvirt-clients
  Depends: libvirt-daemon
  Depends: libvirt-daemon-config-network
  Depends: libvirt-daemon-config-nwfilter
 |Depends: libvirt-daemon-system-systemd
  Depends: libvirt-daemon-system-sysv
  Depends: logrotate
  Depends: policykit-1
 |Depends: debconf
  Depends: <debconf-2.0>
    cdebconf
    debconf
  Breaks: systemd-sysv
  Recommends: dmidecode
  Recommends: dnsmasq-base
  Recommends: iproute2
  Recommends: mdevctl
  Recommends: parted
  Suggests: apparmor
  Suggests: auditd
  Suggests: nfs-common
  Suggests: open-iscsi
  Suggests: pm-utils
  Suggests: radvd
  Suggests: systemd
  Suggests: systemtap
  Suggests: <zfsutils>

Can these dependencies be avoided?

Asked By: mic_e

||

Yes, you can tell apt to ignore recommended packages:

sudo apt install --no-install-recommends libvirt-daemon-system

This will only pull in strict dependencies.

You may want to pick and choose recommended packages instead of ignoring them completely; recommended packages are defined as

packages that would be found together with this one in all but unusual installations.

To explore the dependency chain of a given package, you can use apt-rdepends:

apt-rdepends -sDepends,PreDepends,Recommends libvirt-daemon-system | less

This would allow you to examine all the recommended packages in the chain and decide whether to install them or not. For example, you may not want QEMU (qemu-system), or support for LXC (libvirt-daemon-driver-lxc). In such cases, you can request a full installation, minus some packages:

sudo apt install libvirt-daemon-system qemu-system- libvirt-daemon-driver-lxc-

Note the - after the names of packages which shouldn’t be installed: this instructs apt to remove the named package (so not only will it not install them, it will remove them if they are already installed).

To understand the relationships which end up pulling in seemingly-unrelated packages, ask aptitude; for example:

$ aptitude why libvirt-daemon-system gsettings-desktop-schemas
i   libvirt-daemon-system     Depends    libvirt-daemon (= 7.0.0-3)       
i   libvirt-daemon            Recommends qemu-kvm | qemu-system (>= 0.9.1)
i   qemu-system               Depends    qemu-system-x86                  
i A qemu-system-x86           Depends    libspice-server1 (>= 0.14.2)     
i A libspice-server1          Recommends gstreamer1.0-plugins-good        
i A gstreamer1.0-plugins-good Depends    libsoup2.4-1 (>= 2.48)           
i A libsoup2.4-1              Depends    glib-networking (>= 2.32.0)      
i A glib-networking           Depends    gsettings-desktop-schemas        
Answered By: Stephen Kitt
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.