volitank / nala

Nala is a front-end for libapt-pkg.
GNU General Public License v3.0
1.33k stars 49 forks source link

Bug? : Depending issue when installing some packages #27

Closed CicadaSeventeen closed 5 months ago

CicadaSeventeen commented 7 months ago

When I try to install podman in debian 12, nala try to install such packages:

============================================================================================================================================================================================================================================
 Installing                                                                                                                                                                                                                                 
============================================================================================================================================================================================================================================
  Package:                                                                      Version:                                                                                                                                             Size:  
  aardvark-dns                                                                  1.4.0-3                                                                                                                                             767 KB  
  buildah                                                                       1.28.2+ds1-3+b1                                                                                                                                     6.1 MB  
  catatonit                                                                     0.1.7-1+b1                                                                                                                                          264 KB  
  cgroupfs-mount                                                                1.4                                                                                                                                                   6 KB  
  conmon                                                                        2.1.6+ds1-1                                                                                                                                          38 KB  
  containerd                                                                    1.6.20~ds1-1+b1                                                                                                                                    25.9 MB  
  containernetworking-plugins                                                   1.1.1+ds1-3+b5                                                                                                                                      6.8 MB  
  criu                                                                          3.17.1-2                                                                                                                                            665 KB  
  crun                                                                          1.8.1-1+b1                                                                                                                                          290 KB  
  docker-compose                                                                1.29.2-3                                                                                                                                            123 KB  
  fuse-overlayfs                                                                1.10-1                                                                                                                                               43 KB  
  golang-github-containers-common                                               0.50.1+ds1-4                                                                                                                                         36 KB  
  golang-github-containers-image                                                5.23.1-4                                                                                                                                             32 KB  
  iptables                                                                      1.8.9-2                                                                                                                                             360 KB  
  libintl-perl                                                                  1.33-1                                                                                                                                              720 KB  
  libintl-xs-perl                                                               1.33-1                                                                                                                                               16 KB  
  libip6tc2                                                                     1.8.9-2                                                                                                                                              19 KB  
  libmodule-find-perl                                                           0.16-2                                                                                                                                               11 KB  
  libmodule-scandeps-perl                                                       1.31-2                                                                                                                                               42 KB  
  libnet1                                                                       1.1.6+dfsg-3.2                                                                                                                                       60 KB  
  libprotobuf32                                                                 3.21.12-3                                                                                                                                           932 KB  
  libslirp0                                                                     4.7.0-1                                                                                                                                              63 KB  
  libsort-naturally-perl                                                        1.03-4                                                                                                                                               13 KB  
  libsubid4                                                                     1:4.13+dfsg1-1+b1                                                                                                                                   211 KB  
  needrestart                                                                   3.6-4                                                                                                                                                59 KB  
  netavark                                                                      1.4.0-3                                                                                                                                             1.0 MB  
  podman                                                                        4.3.1+ds1-8+b1                                                                                                                                     10.7 MB  
  podman-docker                                                                 4.3.1+ds1-8+b1                                                                                                                                       19 KB  
  python3-docker                                                                5.0.3-1                                                                                                                                              90 KB  
  python3-dockerpty                                                             0.4.1-4                                                                                                                                              11 KB  
  python3-docopt                                                                0.6.2-4.1                                                                                                                                            26 KB  
  python3-dotenv                                                                0.21.0-1                                                                                                                                             25 KB  
  python3-json-pointer                                                          2.3-2                                                                                                                                                15 KB  
  python3-jsonschema                                                            4.10.3-1                                                                                                                                             68 KB  
  python3-protobuf                                                              3.21.12-3                                                                                                                                           245 KB  
  python3-pyrsistent                                                            0.18.1-1+b3                                                                                                                                          60 KB  
  python3-rfc3987                                                               1.3.8-2                                                                                                                                               9 KB  
  python3-texttable                                                             1.6.7-1                                                                                                                                              12 KB  
  python3-uritemplate                                                           4.1.1-2                                                                                                                                              11 KB  
  python3-webcolors                                                             1.11.1-1                                                                                                                                             13 KB  
  python3-websocket                                                             1.2.3-1                                                                                                                                              40 KB  
  runc                                                                          1.1.5+ds1-1+b1                                                                                                                                      2.7 MB  
  slirp4netns                                                                   1.2.0-1                                                                                                                                              37 KB  
  tini                                                                          0.19.0-1                                                                                                                                            255 KB  
  uidmap                                                                        1:4.13+dfsg1-1+b1                                                                                                                                   189 KB  

============================================================================================================================================================================================================================================
 Suggested, Will Not Be Installed                                                                                                                                                                                                           
============================================================================================================================================================================================================================================
  Package:                                                                      Version:                                                                                                                                             Size:  
  containers-storage                                                            1.50.2+ds1-2                                                                                                                                        2.3 MB  
  firewalld                                                                     2.0.1-1                                                                                                                                             373 KB  
  containers-storage                                                            1.50.2+ds1-2                                                                                                                                        2.3 MB  
  python-jsonschema-doc                                                         4.10.3-2                                                                                                                                             81 KB  

============================================================================================================================================================================================================================================
 Summary                                                                                                                                                                                                                                    
============================================================================================================================================================================================================================================
 Install 45 Packages                                                                                                                                                                                                                        

 Total download size   59.1 MB   
 Disk space required  241.9 MB   

However, firstly, installing podman by apt only gets such 31 paackages:

  aardvark-dns buildah catatonit conmon containernetworking-plugins crun
  docker-compose fuse-overlayfs golang-github-containers-common
  golang-github-containers-image iptables libip6tc2 libslirp0 libsubid4
  netavark podman podman-docker python3-docker python3-dockerpty
  python3-docopt python3-dotenv python3-json-pointer python3-jsonschema
  python3-pyrsistent python3-rfc3987 python3-texttable python3-uritemplate
  python3-webcolors python3-websocket slirp4netns uidmap

Secondly, after installation, the next time I run nala it autoremove some of the packages listed and installed above. The packages remained here is just the same as the packages that apt try to install.

It sounds like that nala have problem solving depends for podman.

Os: debian 12

volitank commented 7 months ago

Very interesting. There may be something we do that is different from apt here. It will probably take me a while to figure this on out. I'll build a VM and see if I can reproduce, and then it's just about hunting down the issue.

volitank commented 7 months ago
Screenshot 2023-11-15 at 2 10 33 PM

At least on one of my servers that doesn't currently have podman it seems like it's the same to be installed. Will continue trying to reproduce it.

In the meantime which version of nala are you using nala --version. Shouldn't be a huge difference though as I don't believe I've messed with this logic lately.

volitank commented 7 months ago

Hmm did a fresh bookworm server. Nala installed from the debian repo. Still 37 for both nala and apt

volitank commented 7 months ago

Seems like I can get a little closer to the packages that are wanting to be installed with sudo nala install podman-docker, namely it wanting to install docker-compose makes me think it's this one. Are you sure you're not inadvertently trying to install podman-docker with Nala and podman with apt?

CicadaSeventeen commented 7 months ago

On another device on debian bookworm which has installed podman, trying to install podman-docker by nala will try to install 21 packages, but apt tries to install 8 packages.

It seems that I mistaken podman-docker as podman. I need to go back to the other device to read the apt log to make sure.

CicadaSeventeen commented 7 months ago

On another device on debian bookworm which has installed podman, trying to install podman-docker by nala will try to install 21 packages, but apt tries to install 8 packages.

After using nala to install podman-docker and then immediately sudo nala autoremove, it will autoremove 8 of the 21 packages that have just installed.

packages that nala tries to install:

  cgroupfs-mount                                                       1.4                                                                                                                               6 KB  
  containerd                                                           1.6.20~ds1-1+b1                                                                                                                25.9 MB  
  criu                                                                 3.17.1-2                                                                                                                        665 KB  
  docker-compose                                                       1.29.2-3                                                                                                                        123 KB  
  libintl-perl                                                         1.33-1                                                                                                                          720 KB  
  libintl-xs-perl                                                      1.33-1                                                                                                                           16 KB  
  libmodule-find-perl                                                  0.16-2                                                                                                                           11 KB  
  libmodule-scandeps-perl                                              1.31-2                                                                                                                           42 KB  
  libnet1                                                              1.1.6+dfsg-3.2                                                                                                                   60 KB  
  libsort-naturally-perl                                               1.03-4                                                                                                                           13 KB  
  needrestart                                                          3.6-4                                                                                                                            59 KB  
  podman-docker                                                        4.3.1+ds1-8+b1                                                                                                                   19 KB  
  python3-docker                                                       5.0.3-1                                                                                                                          90 KB  
  python3-dockerpty                                                    0.4.1-4                                                                                                                          11 KB  
  python3-docopt                                                       0.6.2-4.1                                                                                                                        26 KB  
  python3-dotenv                                                       0.21.0-1                                                                                                                         25 KB  
  python3-protobuf                                                     3.21.12-3                                                                                                                       245 KB  
  python3-texttable                                                    1.6.7-1                                                                                                                          12 KB  
  python3-websocket                                                    1.2.3-1                                                                                                                          40 KB  
  runc                                                                 1.1.5+ds1-1+b1                                                                                                                  2.7 MB  
  tini                                                                 0.19.0-1                                                                                                                        255 KB 

packages that apt tries to install

  docker-compose podman-docker python3-docker python3-dockerpty python3-docopt python3-dotenv python3-texttable python3-websocket

packages that nala auto-removed:

  cgroupfs-mount                                                       1.4                                                                                                                              33 KB  
  containerd                                                           1.6.20~ds1-1+b1                                                                                                               100.8 MB  
  libintl-perl                                                         1.33-1                                                                                                                          4.4 MB  
  libintl-xs-perl                                                      1.33-1                                                                                                                           58 KB  
  libmodule-find-perl                                                  0.16-2                                                                                                                           31 KB  
  libmodule-scandeps-perl                                              1.31-2                                                                                                                          106 KB  
  libsort-naturally-perl                                               1.03-4                                                                                                                           42 KB  
  needrestart                                                          3.6-4 

Here both nala and apt try to install docker-compose when installing podman-docker. That is not the difference. I have been very likely to mistaken podman and podman-docker ( but I can confirm it later ).

However, the problem that when installing a package (like podman-docker here) nala and apt do not perform the same is still here. And the related problem that nala somehow installs some packages that itself will later autoremove is still here too.

volitank commented 7 months ago

Did you try it with apt? I just did this on my system. I can reproduce it trying to remove those packages, but apt does the same. See screen shot

screenshot

Now if we install podman-docker with Nala, both nala and apt will attempt to auto remove these. If we instead install podman-docker with apt, neither will try to auto remove them. So it is a difference in the way Nala and apt are marking packages when installed, but it's not really a bug with dependency resolution or wrongly auto removing packages.

I can try to dig in and see what exactly is going on here, it's a weird issue for sure.

volitank commented 7 months ago

Before when i looked into this I was doing just podman, which was correct. Reset the VM from scratch just to be sure and sure enough podman-compose causes Nala to install more packages than apt does. Now to figure out why. Reproducing the issue is half the battle.

screenshot

volitank commented 7 months ago

Just documenting my steps here. I believe the issue to lie in docker-compose, which is a recommend for podman-docker. If we skip installing recommends it selects the right amount of packages. So now to checkout docker-compose.

volitank@hyprland:~$ sudo nala install podman-docker --no-install-recommends --simple
Installing:
  conmon, containernetworking-plugins, crun, dirmngr, gnupg, gnupg-l10n, gnupg-utils, golang-github-containers-common, golang-github-containers-image, gpg, gpg-agent, gpg-wks-client, gpg-wks-server, 
  gpgsm, iptables, libassuan0, libgpgme11, libip6tc2, libksba8, libnetfilter-conntrack3, libnfnetlink0, libnpth0, libsubid4, libyajl2, pinentry-curses, podman, podman-docker
Recommended, Will Not Be Installed:
  netavark, buildah, fuse-overlayfs, slirp4netns, [ catatonit | tini | dumb-init ], uidmap, docker-compose
Suggested, Will Not Be Installed:
  pinentry-gnome3, tor, parcimonie, xloadimage, pinentry-gnome3, scdaemon, firewalld, pinentry-doc, containers-storage, docker-compose
Summary:
  Install 28
  Total download size 26.7 MB, Disk space required 104.5 MB
Do you want to continue? [Y/n] n
Abort.
volitank@hyprland:~$ sudo apt install podman-docker --no-install-recommends
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  conmon containernetworking-plugins crun dirmngr gnupg gnupg-l10n gnupg-utils golang-github-containers-common golang-github-containers-image gpg gpg-agent gpg-wks-client gpg-wks-server gpgconf gpgsm
  iptables libassuan0 libgpgme11 libip6tc2 libksba8 libnetfilter-conntrack3 libnfnetlink0 libnpth0 libsubid4 libyajl2 pinentry-curses podman
Suggested packages:
  pinentry-gnome3 tor parcimonie xloadimage scdaemon firewalld pinentry-doc containers-storage docker-compose
Recommended packages:
  netavark buildah fuse-overlayfs slirp4netns catatonit | tini | dumb-init uidmap docker-compose
The following NEW packages will be installed:
  conmon containernetworking-plugins crun dirmngr gnupg gnupg-l10n gnupg-utils golang-github-containers-common golang-github-containers-image gpg gpg-agent gpg-wks-client gpg-wks-server gpgconf gpgsm
  iptables libassuan0 libgpgme11 libip6tc2 libksba8 libnetfilter-conntrack3 libnfnetlink0 libnpth0 libsubid4 libyajl2 pinentry-curses podman podman-docker
0 upgraded, 28 newly installed, 0 to remove and 0 not upgraded.
Need to get 26.7 MB of archives.
After this operation, 104 MB of additional disk space will be used.
Do you want to continue? [Y/n] n
Abort.
volitank@hyprland:~$ nala show podman-docker
Package: podman-docker
Version: 4.3.1+ds1-8+b1
Architecture: amd64
Installed: no
Priority: optional
Essential: no
Section: admin
Source: libpod
Origin: Debian
Maintainer: Debian Go Packaging Team <pkg-go-maintainers@lists.alioth.debian.org>
Installed-Size: 188 KB
Depends: podman
Recommends: docker-compose
Conflicts: docker.io
Homepage: https://github.com/containers/podman
Download-Size: 19 KB
APT-Sources: http://deb.debian.org/debian/ stable/main amd64 Packages
Description: engine to run OCI-based containers in Pods - wrapper for docker
 Podman is an engine for running OCI-based containers in Pods.
 Podman provides a CLI interface for managing Pods, Containers, and
 Container Images.
 .
 At a high level, the scope of libpod and podman is the following:
  * Support multiple image formats including the OCI and Docker image
    formats.
  * Support for multiple means to download images including trust & image
    verification.
  * Container image management (managing image layers, overlay filesystems,
    etc).
  * Full management of container lifecycle.
  * Support for pods to manage groups of containers together.
  * Resource isolation of containers and pods.
  * Support for a Docker-compatible CLI interface through Podman.
 .
 Podman is a daemon-less alternative to Docker.
 .
 This package installs a wrapper script that acts like the original docker
 implementation
volitank commented 7 months ago

No bueno. I think it has something to do with how we resolve packages. I'll have to mess with the code. I now believe the issue is the Conflicts: docker-io. If you install docker-compose standalone with nala or apt they give the same packages, and also want to install docker.io, but the podman-docker package conflicts with it so it cannot be installed. To me this is a strange way to package something, but I'll try to figure out where I went wrong.

volitank commented 7 months ago

This definitely isn't going to be an easy fix, but I figured out why I believe.

┌─[volitank@volidesk]─[~/volian-team/nala]─[main]                                                                                                                                                          
└──╼$ apt-cache rdepends criu
criu
Reverse Depends:
  runc

┌─[volitank@volidesk]─[~/volian-team/nala]─[main]                                                                                                                                                          
└──╼$ apt-cache rdepends runc
runc
Reverse Depends:
  docker.io
  singularity-container
  podman
  buildah
  containerd

┌─[volitank@volidesk]─[~/volian-team/nala]─[main]                                                                                                                                                          
└──╼$ nala show buildah
Package: buildah
Version: 1.32.0+ds1-2
Architecture: amd64
Installed: no
Priority: optional
Essential: no
Section: devel
Source: golang-github-containers-buildah
Origin: Debian
Maintainer: Debian Go Packaging Team <team+pkg-go@tracker.debian.org>
Installed-Size: 23.6 MB
Depends: 
  uidmap
  golang-github-containers-common (> 0.49.1)
  libc6 (>= 2.34)
  libdevmapper1.02.1 (>= 2:1.02.97)
  libgpgme11 (>= 1.4.1)
  libseccomp2 (>= 2.5.0)
  libsqlite3-0 (>= 3.36.0)
  libsubid4 (>= 1:4.11.1)
Recommends: fuse-overlayfs (>= 0.7.1~), crun | runc

Crun and runc you can do either or for this. We refer to them as or-deps. Either is fine. Right now in Nala the resolver is selecting both of them for install. I'm unsure as to why. Under the hood python-apt should be using the same resolver that apt is using. I wonder if this bug would be present in rust-apt that I've been working on for the rust rewrite of nala.

I think I have this pretty narrowed down, but how to solve this is kind of tricky, since we aren't really dealing with the resolver and it's abstracted through python-apt.

The autoremovable packages is pretty easy to solve, can just loop through what needs to be installed, check if they are auto removable and just don't install them. But there are still a few packages that nala wants to install that apt doesn't. They don't show up as auto removable because runc and crun are both listed in buildah and podman dependencies. So as far as the system is concerned they don't need to go.

This may take me some time, I'd like to solve it as correct as possible so I don't break some other packages. I could probably hack it out real quick but it wouldn't be a good choice imo.

volitank commented 7 months ago

Had to look pretty deep in apt's code to see how they were handling this. I was able to get it to provide the correct packages this time.

screenshot

The way that I did it isn't exactly correct though. It will probably only work for this package and break others. But I know the path forward now, I think.

It seems that they run through and mark all the packages without marking all of the dependencies and protecting it with the resolver, they then go back through later marking it with the dependencies included.

My head kind of hurts from all this research so quickly. But seems like we may have a path forward.

volitank commented 7 months ago

Some more proof of work. Here I just copied the edited install.py to the server I set up to test. Did an install without the patch, install with the patch and then apt install to see the differences. I guess this has got it figured out.

screenshot

CicadaSeventeen commented 7 months ago

Thanks for your work. It seems that you have found out the problem.

volitank commented 7 months ago

Np. Bugs like this I try to take a bit more seriously. It will still be a couple of weeks before I can finalize the change.

There are some things apt is doing that I need to figure out, as it's probably a future bug if I don't, seems like a resolver edge case.

volitank commented 6 months ago

Commit https://github.com/volitank/nala/commit/4c3c03fdb435c25aab81eb10745a7bd95e1e2b23 will fix this.

Turns out the additional code I was talking about is for some command line things Nala doesn't support. like choosing individual target releases like apt install nala/sid neofetch/bookworm

volitank commented 5 months ago

This issue should be resolved with https://gitlab.com/volian/nala/-/releases/v0.15.0