1
votes

I'm trying to stop installation of an rpm if I have a particular version of a package already installed.

Say I have 2 packages A-7.1.1.rpm & Main_package-1.0.rpm to be installed.

And I've A-1.4.0.rpm already installed on the machine. So what I want to achieve is that, if the installed version of A < 7.1.0 then upgrade of Main_package should not happen.

I tried to put Conflicts tag in the spec file of Main_package as follows.
Conflicts : A < 7.1.0
And executed yum install *.rpm

Here yum finds a latest version of package 'A' in the directory (ie, A-7.1.1.rpm), it doesn't conflict. What I want to check is, if the machine has a particular version of package A.

I could not find any other tags that I can use within the spec file.
Is there any way I can achieve this?

Note: I can't have this check inside a script which then invokes yum install *.rpm

I can execute only yum install *.rpm, nothing else.

2
Conflicts is the correct tag. When you invoke yum install; you say it doesn't conflict. Yum should allow installation of A-7.1.1, but not together with your main_package. Does yum allow installation of both together? You could check as well if the main_package has the correct conflicts tag set; using rpm -qp /path/to/Main_package-1.0.rpm --conflicts - Chris Maes
PS: don't ask questions on Two sites together! please remove your question on unix/linux! - Chris Maes
Hi Chris, yes. rpm -qp shows the correct conflict. If I install both together - installation is going through, because yum sees that I've a version > than what I've mentioned in the conflict tag. But If I try to install main_package alone, conflict is working. What I want to compare is against the already installed package A-1.4.0 Yes. i'll remove the question from other site. - Manu Mathew
yum is working correctly; you're just not clear when asking him what to do... you ask him to install main_package, which conflicts with A < 7.1.0; on the other hand you give him a solution to the problem: upgrade A so he can work with 7.1.1. So in fact the real problem is that he allows an upgrade of A? You are not telling him he can't... - Chris Maes
hmm. yeah yum is working as expected. Is there a way to stop installation if yum finds an already installed package of a particular version when I do yum install *.rpm - Manu Mathew

2 Answers

0
votes

There is a solution, but it is not very clean and not recommended: you can check in the pre-section of your package A whether the other version is installed and abort installation:

%pre
if [[ $(rpm -q A --qf "%{VERSION}-%{RELEASE}") == "1.4.0" ]]
then
    # abort installation in this case!
    exit 1
fi

see this related question for some more information.

I do think you should rethink your design, because it is a quite ugly solution (and note that A-7.1.1 won't have this %pre section and will thus still install without problem)

0
votes

yum has means to configure "don't upgrade package XXX" by pattern through CLI option or configuration. See https://access.redhat.com/solutions/10185