Search code examples
javarpmrpmbuildrpm-spec

Izpack executable jar to RPM


I'm trying to create a rpm package for an executable jar generated using izpack. It's basically an installer wizard that allows a user to install a tool/software. It provides an executable jar. So we have to do

Java -jar file.jar

To initialize the wizard. I'm trying to automate it in Linux by creating an rpm that takes this jar and an sh file that executes this jar and runs the sh file when I execute the rpm file. I'm new to rpmbuild and all the tutorials online are about copying a particular jar from the rpm file to a target location not about how to execute it.

Can someone provide me a sample spec file which does the following

Creates an rpm file with .jar and .sh When rpm -i file.rpm is executed, it runs the .sh file which in turn executes the jar and opens the wizard.

I'm open to any other suggestions on how to make jar auto execute. I'm basically trying to create an exe similar file for linux

Thanks in advance.


Solution

  • I highly recommend not doing this for various reasons, because it is the exact opposite of what RPMs are supposed to do. You should instead do the installation process on a build machine (as a non-root user!) and then capture the files to be installed.

    Why is your approach a bad idea?

    • Installation script is hidden from the user (they cannot just query the RPM scriptlet to see what changes, beyond files, you made to their system)
    • The final installed files won't be controlled in any way, e.g. you won't be able to verify if they had been corrupted (rpm -V) or query what package installed them (rpm -q --whatprovides /path/to/file)
    • "Removing" or "Upgrading" the package won't actually do anything unless you write detailed scripts to handle all these unknown files
    • All the other reasons I didn't list as why you use a package manager instead of blindly distributing tarball distributions like we did in the dark ages

    That said, if you insist on breaking things, your solution is to put the java installation call in %post, which will execute after the files have been installed. It will call it again when you upgrade the package, so the other installer needs to handle that. But again, this is not the right approach.