install4j install additional packages for different Linux families

57 views Asked by At

I use Install4j for my application distribution. I have a Linux installer and during installation process I need to install additional packages. For example sudo apt-get install libpcsclite1

I don't understand which Action should I use in the installer for executing a Bash script or simple package installation.

And another question: I need to support all families of Linux; for example for Oracle Linux the command must be sudo yum install libpcsclite1

Maybe Install4j has some ready solution for such case or tool for understanding which family the current Linux distro belongs to?

2

There are 2 answers

0
Bondar Anton On BEST ANSWER

Thanks Ingo for the solution. It works fine. Additionally in install4j when you add .sh file you should do it with execute Linux permissions (for example 744). And my script for install packages:

#!/bin/bash
#
# Install additional packages for such dists: Ubuntu, Debian, Mint, Oracle  

releaseFile=/etc/os-release

if [ -f $releaseFile ]; then
    . $releaseFile
    os=$ID
    [ -z "$os" ] && os=$ID_LIKE
else
    echo "Release file not found." >&2
    exit 1
fi

case $os in
    ubuntu|debian|mint)
        echo "Detected Debian family distribution."
        sudo apt-get update
        sudo apt-get install libpcsclite1
        ;;
    ol)
        echo "Detected Oracle Linux."
        sudo yum install pcsc-lite
        ;;
    *)
        echo "Unsupported Linux distribution: $os" >&2
        exit 1
        ;;
esac
2
Ingo Kegel On

As of install4j 10.x, there is no pre-defined action to install packages across a range of Linux distributions.

The RPM and DEB media file types have "Dependencies" fields in their media wizard to specify dependencies, so they will be automatically installed by the respective package managers.

If you want to install a dependency in a GUI installer, you would have to use "Run executable or batch file" actions and detect the used package manager yourself in some way.

Calling sudo will not work in the GUI because you will not be able to authenticate. Instead, you would have to locate the "Request privileges" action in the "Startup" node of the installer and set the "Linux privilege requirement" property to "Require root" or "Try to obtain privileges". Then, ensure that the "Action elevation type" property of the "Run executable or batch file" actions (or of their parent screen or parent action group, if any) is set to "Elevate to maximum privileges" (this is the default value for that action). Then the action will have root privileges and you set the "Executable" property to /usr/bin/apt-get or /usr/bin/yum.