Bug 2221663

Summary: Uninstalling dnf leaves /var/cache/dnf with files there
Product: [Fedora] Fedora Reporter: Vít Ondruch <vondruch>
Component: dnfAssignee: David Cantrell <dcantrell>
Status: NEW --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 39CC: daniel.mach, jkolarik, jmracek, jrohel, mblaha, nsella, packaging-team-maint, pkratoch, ppisar, rpm-software-management
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 2216849 Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Vít Ondruch 2023-07-10 14:53:06 UTC
This is follow up of #2216849 where apart of wrong directory ownership, I have complained about leaving old stuff behind. Nobody bothered to answer.

BTW these are precisely the issues I was afraid when I was pointing that DNF5 is wrong name and idea and DNF should keep the DNF name (together with e.g. bug 2216850). It is sad that this happens :( I can't see nothing "right" about this migration.




+++ This bug was initially created as a clone of Bug #2216849 +++

~~~
$ ll /var/cache/dnf
total 236812
drwxr-xr-x. 1 root root       16 Feb 24  2021 commandline-e5106bc4577995c5
drwxr-xr-x. 1 root root       16 Nov  6  2020 commandline-f24b2296296d9941

... snip ...


$ rpm -qf /var/cache/dnf
file /var/cache/dnf is not owned by any package

$ ll /var/cache/libdnf
total 0

$ rpm -qf /var/cache/libdnf
libdnf5-5.0.14-1.fc39.x86_64

$ ll /var/cache/libdnf5/
total 0
drwxr-xr-x. 1 root root 24 Jun 22 22:17 copr:copr.fedorainfracloud.org:atim:shortwave-0753e68d23b426e2
drwxr-xr-x. 1 root root  0 Jun 22 22:17 copr:copr.fedorainfracloud.org:minzord:MinzRepo-0d8ed193db788372
drwxr-xr-x. 1 root root 24 Jun 22 22:17 copr:copr.fedorainfracloud.org:vondruch:doublecmd-6e0d024f0675de55
drwxr-xr-x. 1 root root 24 Jun 22 22:17 flexibee-933c35cd256edfab
drwxr-xr-x. 1 root root 48 Jun 22 22:17 rawhide-2d95c80a1fa0a67d
drwxr-xr-x. 1 root root 48 Jun 22 22:17 rpmfusion-free-rawhide-11a4e834e18e3a11
drwxr-xr-x. 1 root root 48 Jun 22 22:17 rpmfusion-free-tainted-756867963ab562f2
drwxr-xr-x. 1 root root 48 Jun 22 22:17 rpmfusion-nonfree-rawhide-978ef37952204a2d
drwxr-xr-x. 1 root root 48 Jun 22 22:17 rpmfusion-nonfree-tainted-1fa5052018c68452

$ rpm -qf /var/cache/libdnf5/
file /var/cache/libdnf5 is not owned by any package
~~~

BTW I also don't understand why `/var/cache/dnf` is not either used or removed after (forced) update to dnf5

Reproducible: Always

--- Additional comment from Petr Pisar on 2023-06-26 16:31:26 CEST ---

/var/cache/libdnf5 is only used by DNF5.
/var/cache/libdnf is used neither by DNF5, nor DNF4.
/var/cache/dnf directory is only used by DNF4.

You are right that libdn5 package should own /var/cache/libdnf5 instead of /var/cache/dnf. This has been fixed in upstream fives days ago <https://github.com/rpm-software-management/dnf5/commit/f33e35aadbd1b71d0ff8d6f4ec36493db9ee3ead>. I guess this will be addressed in a next Fedora build.

I guess /var/cache/dnf was left orphaned on your system after uninstalling dnf. Keeping nonempty directories is a standard RPM behavior. Removing that tree could be achieved with an RPM postuninstallation script, but this is not a typical approach used in Fedora. The files are usually kept there for case a user would install the package again.

--- Additional comment from Vít Ondruch on 2023-06-28 11:28:27 CEST ---

(In reply to Petr Pisar from comment #1)
> I guess /var/cache/dnf was left orphaned on your system after uninstalling
> dnf. Keeping nonempty directories is a standard RPM behavior. Removing that
> tree could be achieved with an RPM postuninstallation script, but this is
> not a typical approach used in Fedora. The files are usually kept there for
> case a user would install the package again.

I am not sure if the cache directory content was changed, but:

1) I would expect that the same directory is still used.
2) If that is not possible due to format change, then I'd expect that the data are migrated.

It might not sound useful, but running Rawhide, the cache might be the most convenient place to get the older version of package which used to work. I think I have proposed somewhere, that DNF should consider the cache for updates/downgrades, which unfortunately was not implemented (yet). But this is out of scope of this ticket.

--- Additional comment from Jaroslav Mracek on 2023-06-28 12:35:15 CEST ---

Changing status to post because the issue is fixed in upstream. See comment 1. The patch will be released next week.

--- Additional comment from Vít Ondruch on 2023-06-28 13:16:48 CEST ---

(In reply to Jaroslav Mracek from comment #3)
> Changing status to post because the issue is fixed in upstream. See comment
> 1. The patch will be released next week.

Sorry, but:

1) The upstream fix will leave behind yet another directory
2) I have provided more thought on this topic. Could you please elaborate? Is the cache compatible or not? Can it be reused?

--- Additional comment from Pavla Kratochvilova on 2023-06-29 18:11:42 CEST ---

Sorry, I can't answer your questions, Vít, but the aforementioned patch is part of bodhi update https://bodhi.fedoraproject.org/updates/FEDORA-2023-3f321278b5
(I didn't realize that for releases which haven’t yet reached the activation point, bugs can be associated to bodhi updates only by adding keywords to the changelog in the build, and not after that, so, I will handle this manually.)

Comment 1 Vít Ondruch 2023-07-10 15:33:22 UTC
I don't necessarily agree with the move to DNF. I have asked this question. Let me quote my concern:

> I am not sure if the cache directory content was changed, but:
>
> 1) I would expect that the same directory is still used.
> 2) If that is not possible due to format change, then I'd expect that the data are migrated.
>
> It might not sound useful, but running Rawhide, the cache might be the most convenient place to get the older version of package which used to work. I think I have proposed somewhere, that DNF should consider the cache for updates/downgrades, which unfortunately was not implemented (yet). But this is out of scope of this ticket.

I am afraid that the solution in the context of DNF will be "just delete the directory", which should not be the primary solution IMHO.

Comment 2 Fedora Release Engineering 2023-08-16 08:12:08 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 39 development cycle.
Changing version to 39.