rpm-software-management / dnf5

Next-generation RPM package management system
Other
259 stars 87 forks source link

Clarify under which circumstances the dnf cache directory can be shared #1215

Closed DaanDeMeyer closed 7 months ago

DaanDeMeyer commented 10 months ago

dnf seems to use some kind of cache key for repositories in its cache directory (e.g. fedora-ffabc111530caf27) but I can't find any information on how this cache key is calculated. Does it include $releasever, what if two different distributions use the same repository name, ...? It would be great if https://dnf5.readthedocs.io/en/latest/misc/caching.7.html#caching was extended with information on whether a cache directory can be shared and in which circumstances. Specifically, if the repository definitions are different, should a different cache directory also be used?

DaanDeMeyer commented 10 months ago

I just found the get_unique_id() function which answers my question. It would be great if this was documented.

jan-kolarik commented 10 months ago

Hi, thanks for the report. We'll try to improve the docs regarding this.

j-mracek commented 10 months ago

Repo ID - must be unique In cache path we use a hash calculated from metalink, mirrorlist, and baseurl after substitution. The hash is calculated from the first present value. This is used to prevent collisions between different providers and major versions of distributions.

There is even a doc string

    /// @return A unique ID of the repository, consisting of its id and a hash
    /// computed from its source URLs (metalink, mirrorlist or baseurl, first
    /// one set is used in the order listed).
    std::string get_unique_id() const;
DaanDeMeyer commented 10 months ago

@j-mracek Yes this makes sense, It would be great if this was documented outside of the code in the official documentation though.

j-mracek commented 10 months ago

I will add a link between cachedir and the method

j-mracek commented 10 months ago

Patch has been provided. @DaanDeMeyer May I ask you for a review?

DaanDeMeyer commented 10 months ago

@j-mracek Slightly related, do you know if the cache directory can be shared between dnf and dnf5? Can dnf5 use a cache directory generated by dnf and vice-versa?

j-mracek commented 10 months ago

@j-mracek Slightly related, do you know if the cache directory can be shared between dnf and dnf5? Can dnf5 use a cache directory generated by dnf and vice-versa?

I do not recommend to do it and it is not supported. But the hash is calculated by the same way, metadata are at the same location. Only libsolv files are generated by a different way and they are stored at a different location. DNF5 does not download filelists by default therefore it might be also an issue. But this is a present state. In future it might be completely incompatible and the change might happen silently (implementation detail) because we will only care about DNF5 compatibility.