Zypper, How to keep exactly only one version of any downloaded(cached) package of any repository?

Hi, As I’m new to OpenSUSE, before this I used Arch Linux. In Arch I used PAMAC and paccache to control how much version of cached packages will be kept in cache. So if I set it to 1, I would have only latest version of any specific package(say Firefox).
Now I’m looking for any zypper command or configuration to do so in OpenSUSE but I’m unable get any news about that. Please guide me if there is any tool to do so.

Note: I’m even unaware that how much cache version zypper keep by default.

I am not sure I understand your question complete (pointing to what another operating system/distro might have for features may only help those that used it beside using openSUSE and it is always a bit tricky to assume that something you experienced in another distro will have a 100% equivalent), but according to

man zypper

you can switch caching for a repo on/off. Normally it is off. When switched on, I assume only the last installed version of a package is kept.

First,
For details, I’d also recommend the zypper MAN pages for detailed documentation, and if you have follow up questions, post your question…

For what your’e asking,
We don’t really lock at the repo level, and caching happens pretty much automatically as part of any action you take… for example, when you download a package for installation, then the package is cached and not immediately removed after installation.

But if you want to lock a particular application version, the the lock is done at the package level.
Although the zypper MAN pages describes how to do this using the CLI,
You might also at least as easily do this using the YaST Software Manager…
First, you search for the package in question, verify it’s installed and read the version of the application.
You then also have the option to lock the package with a few clicks.

All very intuitive and shouldn’t require any documentation but if you have troubles locking your package using zypper or YaST, just provide details what you tried and what you see instead of what you expected.

TSU

No, they are all kept.

I occasionally run the command:


find . -name '*rpm' -atime +14 -print0 | xargs -0 rm -f

to delete older kept packages (older than 14 days).

Hm, I looked there and could only find some administrative files, no RPMs. Thus my conclusion
seems to be wrong.
I guess (but the OP is not very clear about his goal) that he wants to know if the install of a newer version will then delete the RPM of the older version in the cache.

Looking in my cache, I see:


ls -l zypper*    
-rw-r--r-- 1 root root 1327608 Jun 15 10:06 zypper-1.14.5-1.2.x86_64.rpm
-rw-r--r-- 1 root root 1335536 Jun 23 20:17 zypper-1.14.6-1.1.x86_64.rpm

and


ls -l xdg-desktop-portal-kde*
-rw-r--r-- 1 root root 100892 Jun 15 11:11 xdg-desktop-portal-kde-5.12.90-1.3.x86_64.rpm
-rw-r--r-- 1 root root 101092 Jun 17 13:52 xdg-desktop-portal-kde-5.13.0-1.1.x86_64.rpm
-rw-r--r-- 1 root root 101336 Jun 22 13:28 xdg-desktop-portal-kde-5.13.1-1.1.x86_64.rpm
-rw-r--r-- 1 root root 101404 Jun 27 15:46 xdg-desktop-portal-kde-5.13.1-1.2.x86_64.rpm
-rw-r--r-- 1 root root 101688 Jun 30 13:42 xdg-desktop-portal-kde-5.13.2-1.1.x86_64.rpm
-rw-r--r-- 1 root root 135224 Jul 11 11:29 xdg-desktop-portal-kde-5.13.2-2.1.x86_64.rpm

No, the older version is not deleted. That’s why I manually delete older rpm files when the total size of the cache gets a bit big.


du -h
5.1G    .

That’s for the Tumbleweed OSS repo. When it grows to more than 10G, I’ll do some cleaning up.

Maybe I should comment on why I keep these. I’m following a suggestion by Carlos, a few years ago. With the aid of some symbolic links, the package cache is actually on an NFS server. I have more than one system running Tumbleweed. The first that I update will download the new packages. Others will use the already downloaded copy. This reduces network load and increases update speed. (I do much the same with Leap 15.0).

I understand. You have a reason to cache them, thus you switched keep-packages on. The default is: off (what I have and that explains why my caches are empty)…

Now back to the OP. As he does not explain why he wants this, I am still not sure if he wants to keep the cache as small as possible (where the default would serve him well) or if he indeed wants the last version of every package kept for a reason like you have.

Oh, when all people understood: Describe the goal, not the step

Thank You and all other, at least it is cleared that zypper would keep all of the packages, older versions. I got only solution in mind is to script down this problem, compare files and remove older version(By the way, looking a bit problematic since there is no exact way of writing files names and version inside filename.)

**The cache reason is simple to make it quick and fast to reinstall. **I don’t want to sit down again and look at screen for half an hour and more waiting for packages being updated.

I don’t want to sit down again and look at screen for half an hour and more waiting for packages being updated.

Why would you need to do that??

Hi,

Might as well use the absolute default path where the rpm’s are instead of using the current directory.

/var/cache/zypp*

Yes the glob is not quoted so the directory expands to both zypp and zypper.

Running

echo /var/cache/zypp*

Should give you both directories

/var/cache/zypp /var/cache/zypper

Just my 2 cents.

Fair enough.

However, my package cache is on my NFS server, with symbolic links into it from /var/cache/zypp. And I have a cache for Tumbleweed and a cache for Leap 15.0. So I select what part I am wanting to clean.

Tumbleweed, I clean up frequently because there are so many changes. For Leap 15.0, I clean up saved packages from the update repo and from packman. But not so often from the main oss repo, because those never change.

Cleaning up from the current directory allows me to pick and choose. I’m doing it manually, and not with a cron job.