RPM Build Spec file i want to check rpm is being install or update
Asked Answered
H

2

5

i want to check the rpm i have created is install or update by user(client) like

rpm -ivh abc.rpm

or

rpm -Uvh abc.rpm

is their any %command in spec file to get info regarding this command.

my requirement is if i have a rpm named abc-0.1-2.rpm and now user want to install it prior installing abc.0.1-1.rpm with command rpm -ivh abc.0.1-2.rpm then it allow to install or user directly update rpm with command rpm -Uvh abc.0.1-2 before installing the older version then stop to doing this.

Hie answered 6/12, 2012 at 9:11 Comment(0)
B
1

Your %pre[un] and %post[un] scripts are given "a number representing the number of instances of the package currently installed on the system, after the current package has been installed or erased," so that tells you if the RPM is currently installed or not. See this section of Maximum RPM.

Bromic answered 6/12, 2012 at 9:54 Comment(2)
what about %postun? how to detect if the package is being removed by user as apposed to being removed by rpm to be upgraded to another version? what would $1 variable have in that case?Tiruchirapalli
Then you would get 0, as explained in the reference.Bromic
C
10

To expand on the above:

In your %post[un] or %pre[un] sections there's a variable you can check to see if this package already exists on the system (is being updated/cleanup from upgrade) or not (first time install/final uninstall).

It looks like this:

%post
if [ $1 -eq 1 ]; then
    echo "First install complete"
else
    echo "Upgrade complete"
fi
Carrollcarronade answered 13/3, 2014 at 19:59 Comment(0)
B
1

Your %pre[un] and %post[un] scripts are given "a number representing the number of instances of the package currently installed on the system, after the current package has been installed or erased," so that tells you if the RPM is currently installed or not. See this section of Maximum RPM.

Bromic answered 6/12, 2012 at 9:54 Comment(2)
what about %postun? how to detect if the package is being removed by user as apposed to being removed by rpm to be upgraded to another version? what would $1 variable have in that case?Tiruchirapalli
Then you would get 0, as explained in the reference.Bromic

© 2022 - 2024 — McMap. All rights reserved.