zypper: identifying older packages

On Kubuntu I learnt how to make a local apt repository so that I can take backup of my downloaded packages to use on multiple systems I have.

On openSUSE YaST/zypper is already intelligent enough to just work with a dir of RPMs, so I guess I can just backup /var/cache/zypp but I’m not sure if zypper will automatically remove older version of downloaded files.

So I’d like to know either whether zypper will automatically do this, or there is any way I can use zypper to identify which file is older?

On Kubuntu, the version string is easily identifiable from the downloaded DEB file name because it is always of the format: packagename_version_architecture.deb and underscores aren’t used in package names, but on openSUSE, the format doesn’t really separate package name from version because it uses a hyphen and sometimes hyphens and underscores are used with numbers in package names also. For example compare: http://software.opensuse.org/package/libusb-1_0 and http://packages.ubuntu.com/trusty/libusb-1.0-0. Or should I try to extract the package name and version number using rpm (how?) and then compare?

On 2014-12-07 13:06, jamadagni wrote:
>
> On Kubuntu I learnt how to make a local apt repository so that I can
> take backup of my downloaded packages to use on multiple systems I have.
>
> On openSUSE YaST/zypper is already intelligent enough to just work with
> a dir of RPMs, so I guess I can just backup /var/cache/zypp but I’m not
> sure if zypper will automatically remove older version of downloaded
> files.

No.

However, possibly you need the old versions in order to reconstruct a
system, and on a second step, you upgrade it.

> So I’d like to know either whether zypper will automatically do this, or
> there is any way I can use zypper to identify which file is older?

You can identify “older” /installed/ rpms, yes.


rpm -q -a --queryformat "%{INSTALLTIME}	%{INSTALLTIME:day} \
%{BUILDTIME:day} %-30{NAME}	%15{VERSION}-%-7{RELEASE}	%{arch} \
%25{VENDOR}%25{PACKAGER} == %{DISTRIBUTION} %{DISTTAG}
" \
| sort | cut --fields="2-" | tee rpmlist | less -S

However, what you can remove is not old versions, but those rpms in the
update repo that have an older version in the same repo. Notice that as
they are not installed, but simply files in a directory, there is no way
that yast, zypper, rpm, etc, can identify them. You have to create a
script for that.

I don’t bother, I could shoot my own foot easily.

What zypper does is, on a repo with multiple versions, choose the one
with bigger number, which should be the most recent.

> On Kubuntu, the version string is easily identifiable from the
> downloaded DEB file name because it is always of the format:
> packagename_version_architecture.deb and underscores aren’t used in
> package names, but on openSUSE, the format doesn’t really separate
> package name from version because it uses a hyphen and sometimes hyphens
> and underscores are used with numbers in package names also. For example
> compare: http://software.opensuse.org/package/libusb-1_0 and
> http://packages.ubuntu.com/trusty/libusb-1.0-0. Or should I try to
> extract the package name and version number using rpm (how?) and then
> compare?

There is a format, but you have to know it. An rpm query finds and
separate names and versions and releases.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)