0

I would want to know if it is possible to search packages in Fedora (using dnf) without it having to sync anything previously.

I've read Fedora wiki about rpm, but I don't think I understand properly the values of metadata_expire, metadata_timer_sync and dnf-makecache timer. The only thing I believe I understand is that dnf-automatic would be for managing downloads of packages (and also, if wanted, install them).

And that using cacheonly, if set to true, would make installations fail (sudo rpm install package_name) as it will not try to download any rpm files that weren't already in the cache.

I'll try to explain what I want to achieve:

  • Being able to search for packages without sudo (so no typing my long password) and without it having to sync metadata previously... (I don't mind that this is a separate cache from sudo).
  • When installing (therefore, with sudo) to update everything needed so it installs without errors the last version of any package.

In the first of the two "modes", if it has to work using cached info, ideally I would like to "automate", in some way, the act of updating that cache every "reasonable" time to do that (like once a day?) without manual intervention.

To try to explain myself better, I will try to describe the reasons why I want that:

I search to often for packages (because I don't use graphical software managers) and that waiting time of about 5 to 10 seconds so many times, is really annoying. I would like to experiment searching for packages on my terminal in a quicker way than opening a full web-browser and googling for it.

Thank you all! I am new to Fedora and I don't really know how I could get the package manager to behave in that desired manner, nor if it is possible.

2 Answers 2

0

Being able to search for packages without sudo (so no typing my long password)...

For this, it is perfectly possible to search in the repos without having to use escalated privileges (i.e. sudo). A normal dnf search packagename suffices.

... and without it having to sync metadata previously... (I don't mind that this is a separate cache from sudo).

If I understand you correctly, you want to search in the central repository without having it go through DNF first? Then, I'm afraid that's not possible... no package manager (that I know of) does this.


When installing (therefore, with sudo) to update everything needed so it installs without errors the last version of any package.

Again, if I understand you correctly: you want to download the latest version of software without having to update the cache? Then, the answer is no. It will download the latest version that the cache knows about (e.g. if you last updated the cache when version of "Package X" was version 3.5, and the new one is 3.9, it will download 3.5).

As a continuum to the last point: you can set the cache to never expire (which is not a good idea, as described above, unless you plan on manually refreshing it), but in that case it is better to extend the timeout. If you want to do that, you can edit your /etc/dnf/dnf.conf. For example:

# see `man dnf.conf` for defaults and possible options [main] gpgcheck=True installonly_limit=3 clean_requirements_on_remove=True best=False skip_if_unavailable=True fastestmirror=True metadata_expire=72 # default is 48 hrs. metadata_timer_sync=72 # default is 3 hrs. 

ideally I would like to "automate", in some way, the act of updating that cache every "reasonable" time to do that (like once a day?) without manual intervention.

You can make a cronjob to refresh the cache in the background if you want. Please @ me in the comments if you don't know how to do it, and I'll try to sort you out.

2
  • 1. Yes but that wasn't a doubt on itself, but combined with: 2. Not exactly. I want to dnf search without it having to sync previously metadata (and wait those many seconds every so often) 3. I think this could work for me (I didn't understand metadata_expire worked with hours) if I can combine it with the fourth point. Metadata expiring in just 1 day would be nice if I can: 4. Make it refresh the metadata on "background" every day sometime after boot (not too long). What command should I program with cron? Commented Sep 9, 2022 at 15:13
  • And, also, are "metadata" and "cache" the same thing? If those are different things, then I'm not really understanding what updates what. I want sudo install to just behave like it does (install everything on its last version); but I would want dnf search to work without ever having to wait for any "syncthing" (but, ideally, at the same time, have it update that cache/metadata(?) on the background from time to time so its results aren't really old and "out-of-time". Commented Sep 9, 2022 at 15:25
0

You can use dnf -C search linux

From the manpage:

 -C, --cacheonly Run entirely from system cache, don't update the cache and use it even in case it is expired. DNF uses a separate cache for each user under which it executes. The cache for the root user is called the system cache. This switch allows a regular user read-only access to the system cache, which usually is more fresh than the user's and thus he does not have to wait for metadata sync. 
4
  • That runs from "system cache", meaning "root" cache. So if you haven't run any sudo dnf whatever before for a given time, it will fail. Even if you previously did a dnf search package and it updated the "user" cache. So that doesn't work for what I want: using dnf search and obtaining always results without having to see sometime the updating cache/metadata. Unless I manage to make it have not-expired "root" cache to look from. Example: dnf -C search vlc I obtained: Error: Cache-only enabled but no cache for 'rpmfusion-free-updates'. After a sudo dnf makecache, the same worked. Commented Sep 9, 2022 at 16:07
  • At least now I know the -C flag uses the "cache" from "root", which I will always want to have very updated. So if I always use dnf search with the -C flag, I won't have to maintain two caches. Now I would need to learn to "deactivate" any user cache (so I the system doesn't waste resources/data downloading cache for user), and, at the same time, have the system update a system(root) cache every day on the background so that the user dnf -C flag has always where to look. Any ideas how could I manage that in cron? Commented Sep 9, 2022 at 16:11
  • @PolGZ see systemctl status dnf-makecache.timer. they have already setup a systemd timer for this. Commented Sep 9, 2022 at 16:21
  • Thanks @toppk. I see default is 3 hours. That's more often that what I would thought would be necessary. But, at the same time, I got that error before using the user dnf -C flag. That would mean that it won't run until 3 hours have past since boot? or maybe in this case it was only because I had just added the rpmfusion repo and it didn't do another refresh yet? Can I assume that, if I didn't add any recent new repo, it will always be a recent enough (system)cache that can be consulted from dnf -C search? Commented Sep 9, 2022 at 16:29

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.