Hugo Corrá
Hugo Corrá

Reputation: 14779

Detect Install or Update inside the %install section

How can I differ from a fresh install of an update inside the %install section? I can use the following code inside the %pre section, but it doesn't work inside the %install section:

if [ $1 -eq 1 ]; then
    #install
else
    #update
fi

The main problem is that inside the %install section I want to copy some files (via cp command) only in the case of a fresh install.

Upvotes: 1

Views: 69

Answers (1)

Etan Reisner
Etan Reisner

Reputation: 80921

The %install sections runs during rpm creation. It doesn't run during rpm installation. It is for "installing" the packaged files so that the rpm creation process can find them.

tl;dr You can't do that.

You either always install them to somewhere temporary and only copy them to final locations when in fresh install mode or you use %config(noreplace) marking on files that need not to be modified on upgrade (when they've been modified locally already).

Upvotes: 2

Related Questions