How to reinstall a package in the cache without having to re-download it?


I’m writing a blog post at the moment, wherein I am comparing the various package managers I have a reasonable amount of experience with, including ZYpp and one aspect with respect to which I am comparing them is their speed to reinstall the vim package (a package I choose at random that I knew would be present on all the distros compared), after the package has already been downloaded (so as to eliminate download time as a possible variable influencing the time taken to install the package). The problem is that, running

zypper in -y --force vim

seems to always re-download the package even when I only just installed (and hence downloaded) the package. I am here to ask is there a way wherein I can get zypper to reinstall the vim package without having to redownload it?

Thanks for your time,

If the package is already in the case, zypper will take it from the cache instead of downloading it again.
Although, if the package has been updated in the meantime, zypper will of course download the new version.

You can manually install all packages in zypper’s cache by running something like:

rpm -Uvh /var/cache/zypp/packages/*/*

zypper also only runs rpm in the end to actually install packages.

OK, well I was doing this on a VirtualBox VM and I checked its cache and it does not seem like the vim package is being stored there after it is downloaded by zypper. I keep reinstalling it and every single time it re-downloads it before it installs it. I thought it was cached by default. The vim package I am referring to is the one in the openSUSE-Tumbleweed-Oss repo. How do I get zypper to store the package in the cache?

EDIT: nvm I found the answer in the openSUSE forums, namely here

You need to configure in the /etc/zypp/zypp.conf file to your requirements…

No, this cannot be configured there.

You have to set keeppackages=1 in the repo config, either with YaST, “zypper mr -k XXX”, or by editing the corresponding file in /etc/sysconfig/repos.d/.

Otherwise zypper deletes a package from the cache after it successfully installed it.

Ahh ok, think you meant /etc/zypp though :wink: I’m spoiled, have a local mirror, so never worried…

@fusion809 also be aware if running btrfs/snapper that both caching files and running lots of zypper commands will increase snapshots and space used. If not already configured, suggest you adjust the config file or run the snapper cleanup job…

Yes, /etc/zypp/repos.d/ of course, sorry.

I was typing /etc/sysconfig/ in another reply and apparently got confused… :shame:


A780GM-m3<2016Feb17><16:23></etc/zypp/repos.d>grep keeppackages *

so I guess its pick and choose which keeppackages are set to 1 for the ones required to be held

NB: all files are dated 17Feb2016 10:36, time of last update (ymmv)

Yes, exactly.
This can (has to) be configured for each repo separately.

And the default is keeppackages=0.