rpm-software-management / dnf5

Next-generation RPM package management system
Other
239 stars 75 forks source link

dnf5daemon: Get dependencies to be downloaded (sizes are good enough) #1593

Closed mcrha closed 3 days ago

mcrha commented 1 month ago

The gnome-software can show how many bytes the app will take to download, but it shows only the main package, not its dependencies. Consider app like hedgewars, which also requires hedgewars-data and possibly other.

On the command line:

# dnf install hedgewars
Dependencies resolved.
==============================================================================================================================================================
 Package                                    Architecture                    Version                                    Repository                        Size
==============================================================================================================================================================
Installing:
 hedgewars                                  x86_64                          1.0.2-7.fc39                               updates                          2.7 M
Installing dependencies:
 SDL2_mixer                                 x86_64                          2.6.3-2.fc39                               fedora                           159 k
 SDL2_net                                   x86_64                          2.2.0-3.fc39                               fedora                            19 k
 SDL2_ttf                                   x86_64                          2.20.2-2.fc39                              fedora                            43 k
 compat-lua-libs                            x86_64                          5.1.5-23.fc39                              fedora                           167 k
 dejavu-sans-fonts                          noarch                          2.37-20.fc39                               updates                          1.3 M
 hedgewars-data                             noarch                          1.0.2-7.fc39                               updates                          139 M
 physfs                                     x86_64                          3.0.2-12.fc39                              fedora                            84 k
 wqy-zenhei-fonts                           noarch                          0.9.46-30.fc39                             fedora                           7.6 M

Transaction Summary
==============================================================================================================================================================
Install  9 Packages

Total download size: 151 M
Installed size: 183 M

while gnome-software shows only 2.8MB for the Hedgewars app.

A naive solution could be to get the package dependencies and check what it'll return, at least for not-yet-installed packages (it won't cover updates, I guess), but I did not find a way to it. The rpm.Rpm interface allows "whatrequires", but not "requires", as I could otherwise:

   $ dnf repoquery --requires hedgewars

Nonetheless, I'm not interested in precise dependencies, the sizes (downloaded and installed) are good enough for my use case (and I do not think I could catch all the downloaded cases with the simple (and single) call to get the requires, because those requires can have their own requires to be installed and so on). A new package property install_size_with_deps and download_size_with_deps, both calculated on demand, only if needed (because it's an expensive operation), would do the trick too, but I understand it's too specific and single-purpose thing, thus not so great in the generic API the daemon (tries to/) does have.

Maybe a "simulate-install" operation, which would return a list of the packages to be installed, if the install is executed, ideally with the sizes? Something what would mimic what the dnf install hedgewars table above shows.

jan-kolarik commented 1 month ago

I am marking this as RFE as when trying with the current PackageKit backend, the situation is the same as described, download size is based on the package itself without calculating dependencies.

mcrha commented 1 week ago

I'd say this works already, +/- improvements suggested at https://github.com/rpm-software-management/dnf5/pull/1626#issuecomment-2302551247

mcrha commented 3 days ago

Let me close this. One get call "install", and then stop at the Goal::resolve() and examine the response with packages to be installed, where also the sizes are available. No need for an extra API, it was only that this possibility was not obvious to me.