Home

Awesome

License: GPL v2 Build Status

makeself - Make self-extractable archives on Unix

makeself.sh is a small shell script that generates a self-extractable compressed tar 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/SHA256 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 done. All 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, so that they will know they are actually shell scripts (with quite a lot of binary data attached to them though!).

I am trying to keep the code of this script as portable as possible, i.e it is 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.

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 please 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 certain 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 can be passed the following arguments:

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

Startup Script

The startup script must be a regular Shell script.

Within the startup script, you can use the $USER_PWD variable to get the path of the folder from which the self-extracting script is executed. This is especially useful to access files that are located in the same folder as the script, as shown in the example below.

my-self-extracting-script.sh --fooBarFileParameter foo.bar

Building and Testing

Clone the git repo and execute git submodule update --init --recursive to obtain all submodules.

Maven Usage

Makeself is now supported by the following maven plugin makeself-maven-plugin. Please refer to project for usage and report any bugs in regards to maven plugin on that project.

License

Makeself itself 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.

Contributing

I will gladly consider merging your pull requests on the GitHub repository. However, please keep the following in mind:

Download

Get the latest official distribution here (version 2.5.0).

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

Version history

Links

Contact

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

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

This project is now hosted on GitHub. Feel free to submit patches and bug reports on the project page.


Stephane Peter