Bug 2216849

Summary: dnf5 owns wrong directories in /var/cache
Product: [Fedora] Fedora Reporter: Vít Ondruch <vondruch>
Component: dnf5Assignee: rpm-software-management
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: unspecified    
Version: rawhideCC: jkolarik, nsella, pkratoch, ppisar, rpm-software-management
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2221663 (view as bug list) Environment:
Last Closed: 2023-07-10 10:57:15 UTC 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-06-22 20:31:27 UTC
~~~
$ 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

Comment 1 Petr Pisar 2023-06-26 14:31:26 UTC
/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.

Comment 2 Vít Ondruch 2023-06-28 09:28:27 UTC
(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.

Comment 3 Jaroslav Mracek 2023-06-28 10:35:15 UTC
Changing status to post because the issue is fixed in upstream. See comment 1. The patch will be released next week.

Comment 4 Vít Ondruch 2023-06-28 11:16:48 UTC
(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?

Comment 5 Pavla Kratochvilova 2023-06-29 16:11:42 UTC
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.)