LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   build an RPM that requires JAVA_HOME to be set before insall? (https://www.linuxquestions.org/questions/linux-software-2/build-an-rpm-that-requires-java_home-to-be-set-before-insall-767315/)

dsollen 11-06-2009 09:19 AM

build an RPM that requires JAVA_HOME to be set before insall?
 
Thanks to the great help I've gotten here I've managed to create a working RPM that does a bit of system configuration despite having little working knowledge of linux before starting. My RPM appeared to be working for awhile now but as a final test I installed it on a completely fresh install of RedHat enterprise edition 5.2 (after installing prereq rpms). It seems I'm running into a problem that the IMQ program(ie java message queues) will not boot correctly when I do this because it doesn’t know where to find the JRE.

I want to make sure that when my rpm is run the program actually works afterwards, and it won't work without IMQ. I was thinking I would have the RPM modify the IMQ configuration file to provide a -javahome argument when it boots up. I don't think I can set the configuration file to say '-javahome $JAVA_HOME' because the JAVA_HOME environmental variable won't be set until later in the boot up process after IMQ has attempted, and failed, to boot.

so I had thought the rpm could set whatever the value of JAVA_HOME is at the time the rpm is installed as the home for IMQ. So my questions are...

1) how can I require that JAVA_HOME is set prior to running my RPM, and have the RPM not install if JAVA_HOME isn't set
2) is there a good way to have rpm be able to undo the change I made to the configuration file if it is erased? Should I save a version of the old configuration file before I make the changes somewhere to be used?
3) is this the best way to do things, or is there a simpler method?

kbp 11-07-2009 07:27 AM

Put the test in the '%pre' section and exit on failure ( you may need to create a %pre section)

Code:

%pre
if [ $1 = 1 ]; then
  if [ -z $JAVA_HOME ]; then
  echo "JAVA_HOME is not set, exiting..."
  exit 1
  fi
fi

cheers

unSpawn 11-07-2009 04:02 PM

Quote:

Originally Posted by dsollen (Post 3747105)
how can I require that JAVA_HOME is set prior to running my RPM, and have the RPM not install if JAVA_HOME isn't set

How about having the package that sets JAVA_HOME as a dependency? (As shown in http://www.linuxquestions.org/questi...96#post3728396 post #9: 'rpm -qf /etc/java/java.conf' yields "jpackage-utils".) That's the compliant way of doing things and you don't need to fidget with all sorts of easily breakable workarounds, patches, config changes etc.


All times are GMT -5. The time now is 10:20 AM.