Use FPM to create java jdk RPM package

image_pdfimage_print

Creating packages from redhat or debian systems can be a royal pain. FPM takes some of the pain away. Refer to the FPM wiki for install and usage instructions.

To create an RPM for Oracle’s (sun) java jdk 7:

  1. Download jdk7 from Oracle site. (example, jdk1.7.0_65)
  2. untar into /opt folder, (result: /opt/jdk1.7.0_65)
  3. create alternatives.sh script in the exploded folder
  4. create uninstall.sh script in the same location
  5. run fpm command
  6. (recommended) upload rpm to your custom yum repo

#alternatives.sh
#!/bin/bash
alternatives --install /usr/bin/java java /opt/jdk1.7.0_65/bin/java 1

#uninstall.sh
#!/bin/bash
alternatives --remove java /opt/jdk1.7.0_65/bin/java
rm -rf /opt/jdk1.7.0_65

Run the fpm command to generate an rpm
fpm -s dir -t rpm --after-install /opt/jdk1.7.0_65/alternatives.sh --after-remove /opt/jdk1.7.0_65/uninstall.sh --name jdk7 -v 1.7.0.65 /opt/jdk1.7.0_65

Leave a Reply

Your email address will not be published. Required fields are marked *

Comments Protected by WP-SpamShield Spam Blocker