Zypper doesn't keep the cache for downloads

When I install a package, uninstall, then reinstall it, it downloads the package again, then it installs.
Same thing for when updating the system, and, for instance, there’s an internet issue that makes Zypper stop, running the update command again makes it re-download almost every package.

I have set the setting “keeppackages=1” in every repository, and the issue still persists.

@ZiadA Hi and welcome to the Forum :smile:
Perhaps setting commit.downloadMode value in /etc/zypp/zypp.confmight help.

Check “man zypper” for more information.

           -p, --priority [1-2147483647]|0
               Set the priority of the repository. Priority of 1 is the highest, and 2147483647 is the lowest. -p 0 will set the
               priority back to the default (99). Packages from repositories with higher priority will be used even if there are
               better versions available in a repository with a lower priority.

====>      -k, --keep-packages
               Enable RPM files caching for the repository.

           -K, --no-keep-packages
               Disable RPM files caching.

1 Like

I’m trying the solutions but I really do not appreciate Zypper being stuck at either “Refreshing service ‘openSUSE’.” or “Zypper is currently cleaning up, exiting as soon as possible.” It’s taking pretty long.

I can’t delete replies, so this reply is edited.

I used DownloadInAdvance and DownloadAsNeeded as the variable for commit.downloadMode and it still doesn’t cache the packages, even after running zypper refresh.

I already set that, as this is the same as adding “keeppackages=1” to the repository files.

Is that “keeppackages=1” literal, or are you using “” for that zypp.conf line item? If without quotes, this could be a Leap bug, if others can reproduce. I just tried reproducing with one 16.0, and all 9 packages updated are still in the cache now.

I don’t normally have keeppackages=1 with Leap, including 16.0, but I do for TW and Slowroll, without any “”, and it works. I do use commit.downloadMode = DownloadAsNeeded in zypp.conf with all, but commonly override using -d option.

1 Like

Without the quotes, yes.

If that is the case of this being a bug, then that’s bad, considering that this is my first time using OpenSUSE.

We have only your word for it.

We have only your word for it.

Show the actual repository definition. List the package cache for this repository. Show the full zypper command invocations to “install, uninstall and reinstall it” with the complete output. List the package cache between each zypper invocation.

My Zypper repositories (just the default ones, assuming that’s what you meant):

Repository priorities are without effect. All enabled repositories share the same priority.

# | Alias                       | Name                      | Enabled | GPG Check | Refresh
--+-----------------------------+---------------------------+---------+-----------+--------
1 | openSUSE:repo-non-oss       | repo-non-oss (16.0)       | Yes     | (r ) Yes  | Yes
2 | openSUSE:repo-non-oss-debug | repo-non-oss-debug (16.0) | No      | ----      | ----
3 | openSUSE:repo-openh264      | repo-openh264 (16.0)      | No      | ----      | ----
4 | openSUSE:repo-oss           | repo-oss (16.0)           | Yes     | (r ) Yes  | Yes
5 | openSUSE:repo-oss-debug     | repo-oss-debug (16.0)     | No      | ----      | ----
6 | openSUSE:repo-oss-source    | repo-oss-source (16.0)    | No      | ----      | ----

My Zypper cache

ls /var/cache/zypp/packages
openSUSE:repo-oss

Running the commands (for example, installing, uninstalling, and re-installing Flameshot):

sudo zypper install flameshot           
Refreshing service 'openSUSE'.
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following package is suggested, but will not be installed:
  flameshot-fish-completion

The following 3 NEW packages are going to be installed:
  flameshot flameshot-bash-completion flameshot-zsh-completion

3 new packages to install.

Package download size:   653.7 KiB

Package install size change:
              |       2.8 MiB  required by packages that will be installed
     2.8 MiB  |  -      0 B    released by packages that will be removed

Backend:  classic_rpmtrans
Continue? [y/n/v/...? shows all options] (y): y

Checking for file conflicts: (1 skipped) ........................................................................................................[done]
Warning: 3 packages had to be excluded from file conflicts check because they are not yet downloaded.

    Note: Checking for file conflicts requires not installed packages to be downloaded in advance in
    order to access their file lists. See option '--download-in-advance / --dry-run --download-only'
    in the zypper manual page for details.

Retrieving: flameshot-12.1.0-bp160.1.13.x86_64 (repo-oss (16.0))                                                                   (1/3), 615.7 KiB    
Retrieving: flameshot-12.1.0-bp160.1.13.x86_64.rpm ................................................................................[done (190.6 KiB/s)]
(1/3) Installing: flameshot-12.1.0-bp160.1.13.x86_64 ............................................................................................[done]
Retrieving: flameshot-bash-completion-12.1.0-bp160.1.13.noarch (repo-oss (16.0))                                                   (2/3),  18.6 KiB    
Retrieving: flameshot-bash-completion-12.1.0-bp160.1.13.noarch.rpm .................................................................[done (18.6 KiB/s)]
(2/3) Installing: flameshot-bash-completion-12.1.0-bp160.1.13.noarch ............................................................................[done]
Retrieving: flameshot-zsh-completion-12.1.0-bp160.1.13.noarch (repo-oss (16.0))                                                    (3/3),  19.4 KiB    
Retrieving: flameshot-zsh-completion-12.1.0-bp160.1.13.noarch.rpm ...................................................................[done (8.8 KiB/s)]
(3/3) Installing: flameshot-zsh-completion-12.1.0-bp160.1.13.noarch .............................................................................[done]
Running post-transaction scripts ................................................................................................................[done]

sudo zypper remove flameshot
Reading installed packages...
Resolving package dependencies...

The following 3 packages are going to be REMOVED:
  flameshot flameshot-bash-completion flameshot-zsh-completion

3 packages to remove.

Package install size change:
              |         0 B    required by packages that will be installed
    -2.8 MiB  |  -    2.8 MiB  released by packages that will be removed

Backend:  classic_rpmtrans
Continue? [y/n/v/...? shows all options] (y): y
(1/3) Removing: flameshot-bash-completion-12.1.0-bp160.1.13.noarch ..............................................................................[done]
(2/3) Removing: flameshot-zsh-completion-12.1.0-bp160.1.13.noarch ...............................................................................[done]
(3/3) Removing: flameshot-12.1.0-bp160.1.13.x86_64 ..............................................................................................[done]
Running post-transaction scripts ................................................................................................................[done]
 
sudo zypper install flameshot
Refreshing service 'openSUSE'.
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following package is suggested, but will not be installed:
  flameshot-fish-completion

The following 3 NEW packages are going to be installed:
  flameshot flameshot-bash-completion flameshot-zsh-completion

3 new packages to install.

Package download size:   653.7 KiB

Package install size change:
              |       2.8 MiB  required by packages that will be installed
     2.8 MiB  |  -      0 B    released by packages that will be removed

Backend:  classic_rpmtrans
Continue? [y/n/v/...? shows all options] (y): y

Checking for file conflicts: (1 skipped) ........................................................................................................[done]
Warning: 3 packages had to be excluded from file conflicts check because they are not yet downloaded.

    Note: Checking for file conflicts requires not installed packages to be downloaded in advance in
    order to access their file lists. See option '--download-in-advance / --dry-run --download-only'
    in the zypper manual page for details.

Retrieving: flameshot-12.1.0-bp160.1.13.x86_64 (repo-oss (16.0))                                                                   (1/3), 615.7 KiB    
Retrieving: flameshot-12.1.0-bp160.1.13.x86_64.rpm ................................................................................[done (293.6 KiB/s)]
(1/3) Installing: flameshot-12.1.0-bp160.1.13.x86_64 ............................................................................................[done]
Retrieving: flameshot-bash-completion-12.1.0-bp160.1.13.noarch (repo-oss (16.0))                                                   (2/3),  18.6 KiB    
Retrieving: flameshot-bash-completion-12.1.0-bp160.1.13.noarch.rpm .................................................................[done (17.9 KiB/s)]
(2/3) Installing: flameshot-bash-completion-12.1.0-bp160.1.13.noarch ............................................................................[done]
Retrieving: flameshot-zsh-completion-12.1.0-bp160.1.13.noarch (repo-oss (16.0))                                                    (3/3),  19.4 KiB    
Retrieving: flameshot-zsh-completion-12.1.0-bp160.1.13.noarch.rpm ...................................................................[done (3.6 KiB/s)]
(3/3) Installing: flameshot-zsh-completion-12.1.0-bp160.1.13.noarch .............................................................................[done]
Running post-transaction scripts ................................................................................................................[done]

As you can see, it still shows the download size when attempting to re-install, and it definitely downloads the package again.

These are the last tests I have done, as I will stop using OpenSUSE Leap 16, and OpenSUSE in general, for now.

Thank you all for the help anyway.

FTR

1253740 – keeppackages does not work in Leap 16.0

1 Like

Wishing sucess.

In case you might return later (and I assume that on other Linux forums this will be the same). Please always include that one line before the output you show. That line contains the prompt and the command that results in the output and without it people see only some lines without the context ad have to guess what you did, who you were and where you were…

And special about a repository list. Always create one that includes the URLs. Else the crucial information is missing. Something like zypper lr -d does this trick.

1 Like

In general, it’s not desirable to keep every package in every version in the cache, because the normal case is that you install it once and then you’ll never need it again. If you keep them, over time you’ll end up with every package that you have installed twice which will require not double, but about 1.5 times the disk space of the whole installed system.

This is why this is switched off by default.

As for poor performance, after long usage (many install/update/remove operations), the RPM database can benefit from being reorganized (think of it like the old Windows “defrag”):

sudo rpm --rebuilddb
1 Like

If you have a low bandwidth internet connection and have to update several installations of the same operating system then a local packet cache is quite useful. All my systems use packet-caching and their cache directory is relocated to a directory on my NAS.

So in my opinion the option to cache packets should be available (and fully functional).

GitHub - Firstyear/opensuse-proxy-cache: opensuse-proxy-cache

When I was in a similar situation, I used to do a half-automated “rsync”-Job to my NAS once a week or so. Probably there are also scripts for mirroring.

But anyway, I checked the zypper / libzypp -Documentation, and there was no real guarantee to cache all packages / all versions forever. It might also just use the cache until disk space gets lower and then get rid of the oldest / most unused packages.

A cache is not a mirror.

@arvidjaar : Thank you for the link. Sounds really interesting.

Packet caching might look like “a poor mans solution” however you only keep packets which are installed in any of your systems (i.e. not the whole repository content).

I do not keep the cache for ever. As I know the update status of my systems I can delete the cache regularly without loosing on the advantages (lower bandwidth usage, speedier updates).