简体   繁体   中英

rpm yum install : how to put conflicts on an already installed package?

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.

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)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM