Blog

Create a Self-Extracting Installer in Linux

by | Nov 19, 2014 | Software Development, Solutions

Ultimately many would want to write complex RPMs to install software packages, however, those who are accountable for writing such packages may agree that this task may be cumbersome and impractical.

Where the RPM may accomplish the goal of wrapping an application in some sort of container for distribution, this goal is also possible by using a self-extracting archive or an installer which can launch an embedded script.

This is where a utility called makeself comes in. Makeself is described as “a small shell script that generates a self-extractable tar.gz archive from a directory. The resulting file appears as a shell script (many of those have a .run suffix) and can be launched as is.

Install makeself

cd /opt/app
wget https://megastep.org/makeself/makeself-2.1.5.run
chmod 755 makeself-2.1.5.run
./makeself-2.1.5.run
cd makeself-2.1.5
cp *.sh /usr/bin

Example
Suppose you want to package and distribute a version of libevent2 for several CentOS 6 servers. Here is one way.

mkdir rpmfile
cd rpmfile

wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/aevseev/CentOS_CentOS-6/x86_64/libevent2-2.0.21-1.1.x86_64.rpm
wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/aevseev/CentOS_CentOS-6/x86_64/libevent-devel-2.0.21-1.1.x86_64.rpm

echo '#!/bin/bash
yum install -y libevent2-2.0.21-1.1.x86_64.rpm libevent-devel-2.0.21-1.1.x86_64.rpm' > libevent-install.sh
chmod +x libevent-install.sh
cd ..

Command

#makeself.sh ./DIRECTORY ./FINAL-PRODUCT-NAME.run "SFX installer for COMMENT HERE" ./FILE-IN-DIRECTORY-TO-RUN.sh
makeself.sh ./rpmfile ./libevent-devel.run "SFX installer for libevent-devel (2.0.21)" ./libevent-install.sh

Use the .run file

./libevent-devel.run

Source(s)
https://xmodulo.com/how-to-create-a-self-extracting-archive-or-installer-in-linux.html
https://megastep.org/makeself/

Categories

Related Posts

0 Comments