1

I manage an RPM package and there are versions numbered like:

my-package-1.1.1-1, my-package-1.1.2-1, my-package-1.1.3-1, my-package-1.2.0-0.alpha01.1.

I'm now trying to get another package to depend on my-package < 1.2 so that only a 1.1 version is installed. However when I install with yum, it will always install the latest version (my-package-1.2.0-0.alpha01) instead of one that satisfies the requirement.

How can I check what yum thinks my package's version is?

Here is the spec for the package with the requirement:

Name:       test
Version:    1
Release:    1
Requires: my-package < 1.2

%description
%prep
%build
%install
%files

I also tried Requires: my-package < 0:1.2 with no success.

The rpm spec for my-package 1.2 starts with:

Name: my-package
Provides: my-package
Version: 1.2.0
Release: 0.alpha01.1%{?dist}

and for the 1.1 versions:

Name: my-package
Provides: my-package
Version: 1.1.3
Release: 1%{?dist}

Only the Version: line is changed to set different versions numbers. No epoch is set, so I assume it will default to 0:.

rpmdev-vercmp "1.2.0-0.alpha01.1" "1.2" correctly returns 1.2.0-0.alpha01.1 > 1.2. So I don't think the numbering is incorrect.

Weirdly: even if I set Epoch: 200 on my 1.2 version of my-package and set the test package to require my-package < 10:1.2 it installs the 200:1.2.0 version.

I think the problem is that yum isn't correctly parsing the built my-package.rpm's version. How can I check?

EDIT 1

Here are some diagnostics using rpm -q, it looks like version dependencies are correct?:

$ rpm -qp  --requires test-1-1.x86_64.rpm 
my-package < 1.2
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(PayloadIsXz) <= 5.2-1


$ rpm -qp --provides my-package-1.1.3-1.noarch.rpm 
my-package
my-package = 1.1.3-1

$ rpm -qp --provides my-package-1.2.0-0.alpha01.1.noarch.rpm 
my-package
my-package = 1.2.0-0.alpha01.1

EDIT Reproduction steps!

I made reproduction code! Tested it on Centos7 running from home dir. Requires rpmdevtools and createrepo to be installed.

#/bin/bash
echo "Name:       my-package
Provides:   my-package
Version:    \${VERSION}
Release:    \${RELEASE}
Summary:    NA
License:    NA

%description
%prep
%build
%install
%files
" | tee template.spec

echo "Name:       has-requirement
Version:    1
Release:    1
Summary:    NA
License:    NA

Requires: my-package < 1.2

%description
%prep
%build
%install
%files
" | tee has-requirement.spec

vers=("1.1.1" "1.1.2" "1.1.3" "1.2.0")


rpmdev-setuptree
for v in ${vers[@]}; do
    VERSION=$v RELEASE="1" envsubst '$${VERSION} $${RELEASE}' < template.spec > my-package.spec
    rpmbuild -ba my-package.spec
done
rpmbuild -ba has-requirement.spec

repodir="$PWD/repo"
mkdir -p $repodir
mv ./rpmbuild/RPMS/x86_64/my-package* $repodir
createrepo $repodir

echo "[temp]
name=temp repo
baseurl=file://$repodir
enabled=1
gpgcheck=0" | sudo tee /etc/yum.repos.d/temp.repo

sudo yum clean all; sudo rm -rf /var/cache/yum
sudo yum search my-package --show-duplicates
sudo yum localinstall --assumeno $PWD/rpmbuild/RPMS/x86_64/has-requirement-1-1.x86_64.rpm
2

you can ask rpm to tell you the requirement for your test package:

if it is installed:

rpm -q test --requires

if it is not installed:

rpm -qp /path/to/test.rpm --requires

that could help you out.

You error is indeed strange; are you sure the correct test.rpm is being installed; with the correct depencency?

  • You're right I'd forgotten about using rpm --provides, unfortunately it isn't giving me any more clues though. I'm checking the install with yum localinstall --assumeno and seeing what dependencies resolve – jenny May 17 at 12:30
1

For the sake of anyone else facing this problem of yum not recognising dependency versions, this is how I fixed the dependency resolution.

In my dependency package, the rpm spec header started with:

Name:       my-package
Provides:   my-package
Version:    1.2.0
Release:    0

The line Provides: my-package was redundant and it was confusing yum because it meant all versions of the package were providing my-package. I don't entirely know why that was causing version and epoch numbers to be ignored, but there you go.

Removing the my-package package name from the list of stuff it provides, made yum observe versioning requirements as expected.

I think this is probably a bug in yum. I haven't tested if dnf does the same thing.

  • not sure this is a bug, but I do agree that yum sometimes behaves strangely with Provides and Obsoletes... watch out with those :) – Chris Maes May 21 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.