Bug 1381332 - [rfe] Remove install-time dependencies at the end of a transaction
Summary: [rfe] Remove install-time dependencies at the end of a transaction
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf
Version: rawhide
Hardware: All
OS: Linux
medium
unspecified
Target Milestone: ---
Assignee: rpm-software-management
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-10-03 17:54 UTC by Stephen Gallagher
Modified: 2020-02-14 07:29 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Stephen Gallagher 2016-10-03 17:54:21 UTC
Description of problem:
Some packages (such as linux-firmware) are needed only during the installation of other RPMs and do not necessarily need to remain on the installed system after the transaction has concluded. It would be ideal if DNF could automatically remove these packages after the standard transaction has completed to save disk space on installed systems.

Version-Release number of selected component (if applicable):
dnf-1.1.10-2.fc25

How reproducible:
N/A

Steps to Reproduce:
1. Using a mock configuration for Fedora, install the kernel-core package

Actual results:
Mock installs linux-firmware as a "Requires(pre):" dependency of kernel-core. This package consumes approximately 120MiB of disk space and is not needed at runtime.

Expected results:
Mock installs linux-firmware at the beginning of the transaction, then removes the package after all package scripts have been run. Significantly less storage space is consumed on the resulting system.

Additional info:

linux-firmware is one example, but there are likely many other packages whose presence on the installed system is unnecessary after the installation transaction is completed.

Comment 1 Igor Gnatenko 2016-10-03 18:04:09 UTC
Definitely nice thing to have!

I would not say that it's something what we would do tomorrow, but anyway ;)

Comment 2 Jaroslav Mracek 2017-06-29 18:25:57 UTC
I tried one nice experiment with kernel-core, first I removed linux-firmware, then install additional kernel-core and surprisingly linux-firmware was installed again. That means additionally I downloaded and installed 41 MB and this was only experiment with single package. I do believe that for normal distribution this behavior cannot be applied, but for some corner cases, where you will not expect installing of updates.

Comment 3 Jaroslav Mracek 2017-08-01 17:35:32 UTC
There is blocker because we cannot distinguish between requires and requires-pre, because libsolv returns only unique values. Igor Gnatenko promised to investigate the issue.

Comment 4 Panu Matilainen 2017-08-02 07:17:44 UTC
It's an interesting idea, for image generation at least. For general purpose use probably not so much, because at least in Fedora practically every package gets updated once or usually more during the distro lifetime, so you'd end up downloading those usually unchanging install-time dependencies several times only to be removed after install of something else.

I don't know libsolv well at all but it does seem to know about the fine-grained dependencies these days. If I had to guess after a quick glance at the code, I'd say it seems to filter out the install-only requires from the rpmdb .solv data. So it might be possible to get the install-only dependencies from the delta between available and installed package dependencies. But don't take my word for that.

Another problem is that the repodata's idea of pre-requires is confused and flawed which makes it useless for most purposes. The pre-requires in repodata could only be used for install-ordering, but it's not sufficient for this feature. You need to look at the real rpm-level dependency type bitmap to determine whether something is truly only needed for install but eg not for removal. Of course removal-only dependencies could also be considered, but then for general use you might have to download something just to remove something else, and I dont think the world is ready for that :)

Finally, I doubt the Fedora package set is ready for this, it's not an uncommon  misunderstanding to assume that "Requires(pre/post): foo" implies "Requires: foo", ie that the dependency is always required. See eg bug 1469136, this is one of those almost annually recurring "bugs".

Comment 5 Jaroslav Mracek 2019-06-28 09:32:06 UTC
Please could you prove an rpm command that will remove only install-time dependencies?

Comment 6 Panu Matilainen 2019-06-28 10:01:15 UTC
Sorry, I dont understand. No such command exists in rpm, nor does it make sense to add one. You'd need to figure it out from the dependency data.

Comment 7 Jaroslav Mracek 2019-07-04 07:25:15 UTC
What about to add a new option for "dnf autoremove" command that will remove also install only dependencies?

Comment 8 Stephen Gallagher 2019-07-11 19:58:52 UTC
(In reply to Jaroslav Mracek from comment #7)
> What about to add a new option for "dnf autoremove" command that will remove
> also install only dependencies?

How would it determine which ones to remove?

Comment 9 Jaroslav Mracek 2019-07-22 06:39:09 UTC
Stephen Gallagher see https://github.com/openSUSE/libsolv/issues/330. Please could you answer a question from Comment 8?

Comment 10 Stephen Gallagher 2019-07-22 10:25:38 UTC
(In reply to Jaroslav Mracek from comment #9)
> Stephen Gallagher see https://github.com/openSUSE/libsolv/issues/330. Please
> could you answer a question from Comment 8?

What question do you want me to answer? Comment 8 was my own question...

Comment 11 Jaroslav Mracek 2019-07-22 18:09:32 UTC
Sorry - Comment 7

Comment 12 Stephen Gallagher 2019-07-22 20:28:16 UTC
Are you suggesting that this would be a mode of `dnf autoremove` or an addition to it?

I might want to clean up the `Requires(pre|post)` content but not all of the stuff that `dnf autoremove` currently discards.

Comment 13 Jaroslav Mracek 2019-07-24 06:49:48 UTC
Lets put it this way, we cannot remove install only dependency at the end of transaction, because in fact this will be the second rpm transaction for a single command (new unsupported workflow). Therefore another command should handle it. Autoremove is the command that I will use when I want to make my system smaller. But you want to have system extremely smaller, because you create a container. 

Additionally - this feature has an additional value only for system that will never perform upgrade, or reinstall.

Comment 14 Stephen Gallagher 2019-07-24 10:37:54 UTC
(In reply to Jaroslav Mracek from comment #13)
> Lets put it this way, we cannot remove install only dependency at the end of
> transaction, because in fact this will be the second rpm transaction for a
> single command (new unsupported workflow). Therefore another command should
> handle it. Autoremove is the command that I will use when I want to make my
> system smaller. But you want to have system extremely smaller, because you
> create a container. 
> 
> Additionally - this feature has an additional value only for system that
> will never perform upgrade, or reinstall.

I disagree with this statement. There are many environments for which bandwidth for the upgrade is cheaper than long-term storage. I can see many cases where a datacenter setup (with a local repo mirror) would prefer to avoid having the `linux-firmware` package installed on all of their systems, wasting at least 200MiB of storage space (space usage has gotten much larger since the initial report of this BZ). Far simpler to have it installed only for the duration of the update process and then removed.

If it has to be two steps, I think it's fine if it's the `dnf autoremove` command. What I was asking above (probably unclearly) was how you intend it to behave. Assuming a hypothetical `--scriptlet-pkgs` flag (I'm just making up a name), there are two ways it could function:

1) `dnf autoremove` removes all packages that it does in its normal operation, plus all of those that are installed solely to satisfy a Requires(*)
2) `dnf autoremove` removees only those packages that are installed solely to satisfy a Requires(*)

I'd prefer option 2, since the first one may also be removing content that I need but happens to be leaf packages.


Note You need to log in before you can comment on or make changes to this bug.