makeself - Make self-extractable archives on Unix

makeself.sh is 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. The archive will then uncompress itself to a temporary directory and an optional arbitrary command will be executed (for example an installation script). This is pretty similar to archives generated with WinZip Self-Extractor in the Windows world. Makeself archives also include checksums for integrity self-validation (CRC and/or MD5 checksums).

The makeself.sh script itself is used only to create the archives from a directory of files. The resultant archive is actually a compressed (using gzip, bzip2, or compress) TAR archive, with a small shell script stub at the beginning. This small stub performs all the steps of extracting the files, running the embedded command, and removing the temporary files when it's all over. All what the user has to do to install the software contained in such an archive is to "run" the archive, i.e sh nice-software.run. I recommend using the "run" (which was introduced by some Makeself archives released by Loki Software) or "sh" suffix for such archives not to confuse the users, since they know it's actually shell scripts (with quite a lot of binary data attached to it though!).

I am trying to keep the code of this script as portable as possible, i.e it's not relying on any bash-specific features and only calls commands that are installed on any functioning UNIX-compatible system. This script as well as the archives it generates should run on any Unix flavor, with any compatible Bourne shell, provided of course that the compression programs are available.

As of version 2.1, Makeself has been rewritten and tested on the following platforms :

If you successfully run Makeself and/or archives created with it on another system, then let me know!

Examples of publicly available archives made using makeself are :

Important note for Apache users: By default, most Web servers will think that Makeself archives are regular text files and thus they may show up as text in a Web browser. The correct way to prevent this is to add a MIME type for this file format, like so (in httpd.conf) :

AddType application/x-makeself .run

Important note for recent GNU/Linux distributions: Archives created with Makeself prior to v2.1.2 were using an old syntax for the head and tail Unix commands that is being progressively obsoleted in their GNU forms. Therefore you may have problems uncompressing some of these archives. A workaround for this is to set the environment variable $_POSIX2_VERSION to enable the old syntax, i.e. :

export _POSIX2_VERSION=199209

Usage

The syntax of makeself is the following:

makeself.sh [args] archive_dir file_name label startup_script [script_args]

Here is an example, assuming the user has a package image stored in a /home/joe/mysoft, and he wants to generate a self-extracting package named mysoft.sh, which will launch the "setup" script initially stored in /home/joe/mysoft :

makeself.sh /home/joe/mysoft mysoft.sh "Joe's Nice Software Package" ./setup

Here is also how I created the makeself.run archive which contains the Makeself distribution :

makeself.sh --notemp makeself makeself.run "Makeself by Stephane Peter" echo "Makeself has extracted itself"

Archives generated with Makeself 2.1 can be passed the following arguments:

Any subsequent arguments to the archive will be passed as additional arguments to the embedded command. You should explicitly use the -- special command-line construct before any such options to make sure that Makeself will not try to interpret them.

License

Makeself is covered by the GNU General Public License (GPL) version 2 and above. Archives generated by Makeself don't have to be placed under this license (although I encourage it ;-)), since the archive itself is merely data for Makeself.

Download

Get the latest official distribution here (version 2.1.5).

The latest development version can be grabbed from GitHub. Feel free to submit any patches there through the fork process.

Version history

Links

Contact

This script was written by Stéphane Peter (megastep at megastep.org) I welcome any enhancements and suggestions.

Contributions were included from John C. Quillan, Bjarni R. Einarsson, Francois Petitjean, and Ryan C. Gordon, thanks to them! If you think I forgot your name, don't hesitate to contact me.

icculus.org also has a Bugzilla server available that allows bug reports to be submitted for Loki setup, and since Makeself is a part of Loki setup, you can submit bug reports from there!


Stéphane Peter
Last modified: Fri Jan 4 15:51:05 PST 2008