Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Question:

What do I put in the foo.spec file so that the rpm's will remove the previous rpm before installing?

Description:

I have created a spec file that creates rpm's for a few packages that use the same source and provide the same service, each with a slightly different configuration. E.g. they each provide the same "capability"

Here's an example of the essentials that my .spec file looks like:

%define version     1234
%define name        foo
%define release     1
%define pkgname     %{name}-%{version}-%{release}

Name:               %{name}
Version:            %{version}
Release:            %{release}
Provides:           %{name}

%package one
Summary:            Summary for foo-one
Group:              %{group}
Obsoletes:          %{name} <= %{version}
Provides:           %{name} = %{version}

%description one
Blah blah blah

%package two
Summary:            Summary for foo-two
Group:              %{group}
Obsoletes:          %{name} <= %{version}
Provides:           %{name} = %{version}

%description two
Blah blah blah

# %prep, %install, %build and %clean are pretty simple 
# and omitted here for brevity sake

%files one
%defattr(-,root,root,-)
%{_prefix}/%{pkgname}

%files two
%defattr(-,root,root,-)
%{_prefix}/%{pkgname}

When I install the first one, it installs ok. I then remove the first one, and then install the second one, that works fine too.

I then install the first one, followed immediately by installing the second one, and they both install, one over the other, but, I was expecting that the second one would be removed before installing the second.

Example session:

# rpmbuild foo and copy rpms to yum repo

$ yum install foo-one
...
$ yum list installed|grep foo
foo-one.noarch           1234-1                @myrepo

$ yum install foo-two
...[Should say that it is removing foo-one, but does not]...

$ yum list installed|grep foo
foo-one.noarch           1234-1                @myrepo
foo-two.noarch           1234-1                @myrepo

$ rpm -q --provides foo-one
foo = 1234
foo-one = 1234-1

$ rpm -q --provides foo-two
foo = 1234
foo-two = 1234-1

What do I put in the foo.spec file so that the rpm's will remove the previous rpm before installing?

Thank you,

.dave.

share|improve this question
1  
Shot in the dark: isn't this what obsoletes is for? –  Charles Jun 6 '12 at 22:34
    
What differs between the packages and consequently their deployments - binaries, configuration or both? –  nearora Jun 6 '12 at 23:07
    
What differs? Since I'm packaging a PHP app, the configuration and the php code. –  fatehks Jun 12 '12 at 22:13
add comment

1 Answer

You want to make those packages conflict with each other, so that yum knows that they cannot be installed simultaneously.

%package one
Summary:            Summary for foo-one
Group:              %{group}
Obsoletes:          %{name} <= %{version}
Provides:           %{name} = %{version}
Conflicts:          %{name}-two
share|improve this answer
    
I added "Conflicts:" and that at least dis-allowed the installation if the version was the same, so that's what I'm using. Thanks. –  fatehks Jun 12 '12 at 22:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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