Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm very new to RPM packaging and I'm curious if, during the installation of one RPM it is possible to conditionally install another RPM if needed.

In a nutshell.

My RPM requires a particular JRE. While installing my RPM, what is the best way to:

  1. Check for the existence of the JRE and...
  2. If the JRE does not exist, install it.
share|improve this question
add comment

1 Answer 1

This is called a "dependency". You can define a dependency using Requires in your spec file:

Requires: A comma-separate list of packages that are required when the program is installed. Note that the BuildRequires tag lists what is required to build the binary RPM, while the Requires tag lists what is required when installing/running the program; a package may be in one list or in both. In many cases, rpmbuild automatically detects dependencies so the Requires tag is not always necessary. However, you may wish to highlight some specific packages as being required, or they may not be automatically detected.

Source: http://fedoraproject.org/wiki/How_to_create_an_RPM_package

share|improve this answer
    
Okay, that detects that the jre is not present. My big problem though is how I install the jre when the failed dependency is detected. Can it be scripted or does the installer of my rpm have to manually install the jre rpm? –  Kip Russell Nov 7 '12 at 23:30
    
@KipRussell The JRE needs to be available in a configured yum repo. You then need to install the RPM using yum, see: unix.stackexchange.com/questions/54969/… –  jordanm Nov 7 '12 at 23:41
    
jordanm... I have a yum repo and it has the required jre rpm available. What I'm wondering though, which is the same question asked at the end of the link you gave me, is whether the installation of the jre can happen 'automatically.' So myapp.rpm detects the missing dependency and kicks off the install of the jre. Or better yet, can the dependencies somehow be packaged with myapp.rpm. –  Kip Russell Nov 7 '12 at 23:57
    
Yum will do that automatically if it can find the package. –  jordanm Nov 8 '12 at 0:00
    
That doesn't seem to be what I'm seeing. yum list available to verify the package (jdk.x86_64) is in my repo and I see it. I then add the package name to my spec file Requires section. The rpm builds fine, but when I try to run it I get a 'error: failed dependencies.' As a test I placed a commonly available rpm (zziplib) in the Requires section. I got the same error. Yum is not automatically attempting a download/install. –  Kip Russell Nov 8 '12 at 0:29
show 1 more 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.