How to make a package from another repo "sticky?"

This is more a question about dnf than anything else, but I haven’t been able to figure out if this is possible (and maybe it isn’t). Here’s the scenario:

  1. If you want a particular package that was updated in Cooker installed, you can install it as a one-off without adding the Cooker repo permanently (which would be bad). If, for example, you want a newer version of Syncthing, you can install it like this:
    sudo dnf upgrade --enablerepo=cooker-x86_64 syncthing
    
  2. Once you do this, the next time you try to update your system (I’m using Rome), dnf wants to downgrade Syncthing to the version in the Rome repo.
  3. To get around this, you can exclude the package when doing the distro sync.
  4. However, eventually Rome will get the updates from Cooker and you then won’t want to exclude the package. But Cooker might then get an even more up to date version, and then you’ll want to install that version again.

My question is, is there a way to make the idea “I want the Cooker version of this package, and this package alone” sticky? In other words, I want Rome for the stability, but certain packages should always come from Cooker. And when I distro-sync, it should check certain packages against the Cooker repo for updates (because I’ve specified it) instead of the Rome version.

As I said, this may not be possible; I haven’t been able to find anything about dnf that allows this. But I figured I’d ask, because there are people here much more experienced with it than I am. :slight_smile:

3 Likes

This could actually be very helpful. Sorry that I can’t provide an answer…I’m just commenting to express my interest in something like this maybe being possible :stuck_out_tongue_closed_eyes:

1 Like

You may be able to do something with dnf’s repository-packages command, the 4th last example in its documentation page sounds near to what you want to achieve:

dnf [options] repository-packages <repoid> remove-or-distro-sync [<package-spec>...]

Select all packages installed from the repository. Upgrade, downgrade or keep those of them that are available in another repository to match the latest version available there and remove the others along with any packages depending on the packages being removed. If clean_requirements_on_remove is enabled (the default) also removes any dependencies that are no longer needed.

Link to command page: https://dnf.readthedocs.io/en/latest/command_ref.html#repository-packages-command

By using the --exclude= parameter that you already mentioned and following up with the dnf repository-packages command you may be able to chain or script them together to get to where you want to be with that.

As it may involve potentially ruinous usage of dnf, I would recommend spinning up a VM and trying out what you are wanting to do inside those safer confines to preserve your system as-is until you get what you are wanting to do figured out. :slightly_smiling_face:

Edit to add:

There is a potential issue with the repository-packages command going forward though, I cannot seem to find it in DNF5’s documentation, so it may just be a temporary resolution, but dnf5 does have a versionlock that may also fit your needs - https://dnf5.readthedocs.io/en/latest/commands/versionlock.8.html

2 Likes

Thank you all. So far, I’ve been unsuccessful. Using Syncthing as the example (since 1.29.2 is in Rome and 1.29.7 is in Cooker), I went ahead (in a VM) and installed the Cooker version of Syncthing like this:

sudo dnf --setopt=downgrade=False upgrade --enablerepo=cooker-x86_64 syncthing

Unfortunately, a regular distro sync asks for confirmation of the downgrade, because I’m on Rome.

If I try this:

sudo dnf repository-packages cooker-x86_64 remove-or-distro-sync --refresh --allowerasing

I still get prompted to downgrade Syncthing, and it doesn’t seem to want to do the distro sync either.

So far, the only thing that works is to use an --exclude list like so:

 sudo dnf distro-sync --refresh --allowerasing --exclude=syncthing

This, of course, won’t then capture updates from the Cooker repo like I want. I’d have to keep track of them and install them manually.

I’m still on dnf4, since I’m on Rome. Maybe this works in dnf5?