Makeself.sh is a small Shell script that is used to generate a catalog from a self-extracting tar.gz archive. The results show a shell script file (as most in .run suffix), it can be run automatically. This document will extract itself to a temporary directory and an optional arbitrary command execution (for example: an installation script). It is very similar to Windows in the Winzip self-extracting files generated. Makeself It also includes verification and validation integrated child (CRC or MD5 checksum) is used.
Makeself.sh script itself is only used to create a document from a file directory. Generated documentation is actually a compressed (using gzip, bzip2, or compress) TAR file, at the beginning of the file to join a short Shell script. This is a small Stub script to execute unzip the file, run the embedded command and delete temporary files. To install the document contained in the software, the user only needs to run the "document", for example: sh nice-software.rum. I recommend these files using the "run" or "sh" as a suffix, do not confuse the user, because they know that it is actually a Shell script behind it with quite a bit of binary data.
2.1 From the beginning, makeself has been rewritten in the following test platform:
1. Linux (all distributions)
2. Sun Solaris (8 and above)
3. HP-UX (11.0 and 11i HPPA RISC on)
4. SCO OpenUnix and OpenServer
5. IBM AIX 5.1L
6 MacOS X (Dario)
7. SG IRIX 6.5
9. UnicOS / Cray
Home (current version 2.2.0):
Download the latest official release:
To install makeself on Linux, download the latest version of the archive format files, execute the downloaded file, since the file when extracting creates a new directory called makeself-2.2.0 in the current directory, copy all of the shell script to the / complete the installation under usr / bin directory.
$ Wgethttp: //megastep.org/makeself/makeself-2.2.0.run
$ Chmod 755 makeself-2.2.0.run
$ Cd makeself-2.2.0
$ Sudo cp * .sh / usr / bin
makeself.sh the basic use is as follows:
makeself.sh [args] archive_dir file_namelabel startup_script [script_args]
"Label" parameter is the message SFX decompressed print, "start_script" and specify the script command after SFX archive unzipped successfully executed. When you want to create a self-extracting installation file will be useful. Typically startup script to copy and extract the contents to install the appropriate target directory. Startup script must be in the package directory, so the script is included in the SFX archive.
1. args is an optional parameter Makeself, usable are:
--vesion: Print version information to the console, and then quit immediately;
- --gzip: Use GZIP compression (the default option)
- --bzip2: Compressed with bzip2
- --compress: Using the Unix compress command to compress data
- --nocomp: No compression
- --notemp: Do not extract the files to a temporary directory, but create a new subdirectory in the current directory.
- --current: Files will be extracted to the current directory rather than a subdirectory implied --notemp Options
- --follow: Follow all symbolic links, symbolic links to package those files.
- --append: Recent data to an existing document, instead of creating a new data.
- --header: Makeself2.0 start can use a separate header file storage stub, called makeelf-header.sh, located makeself assume the same position.
- --copy: ....
2. archive_dir: directory containing the name of the archive
3. file_name: Create archive file name
4. label: any text string description of the package, when extracting files show
5. startup_script: In order to extract the file directory, so if you want to execute a
Program in this directory, you must add the prefix "./", for example, before your command: ./ program is correct, script_args is an additional parameter change command.
Here is an example, assume that the user has a mirrored packet is stored in the / home / joe / mysoft directory that you want to generate a self-extracting mysoft.sh package, setup will start stored in the / home / joe / mysoft directory script, execute the following command:
makeself.sh/home/joe/mysoft mysoft.sh "Joe's Nice Software Package" ./setup
The following is to create a command contains Makeself release makeself.run document:
makeself.sh --notempmakeself makeself.run "Makeself by Stephane Peter" echo "Makeself has extracted itself"
Makeself by the generated document can pass the following parameters:
- --keep: Place extract the files to a temporary directory (embedded after the execution of the script will be deleted). Unzip the file directly into the current working directory until you delete it.
- --verbose: Before executing the embedded command prompts the user
- --target: Allows the extracted directory to any location
- --confirm: Before running the embedded command prompts the user to confirm
- --info: Print out the general information about the document (no decompression)
- --lsm: Print LSM entry
- --check: Using the embedded checksum verification documents, not extracting archive
- --nochown: Default, after decompression run "chown -R" command in the target directory, so that all the files belonging to the current user. If you run as root most need this, tar will attempt to re-create the initial user owner. You can disable this behavior.
- --tar: The content of the document run the tar command, use the latter as a parameter to the command parameters.
- --noexec: After decompression does not run the embedded script
Any arguments after the document as additional parameters passed to the embedded command. Before any of these options, you should use the display - specialized command-line structure to ensure Makeself does not try to explain them.
Create self-extracting archive
To create a self-extracting file that contains all the files in the backup directory, do the following operation. Start function simply prints "Extraction done" do more things.
$ Makeself.sh --notemp./backup ./backup.run "SFX archive for backup" echo "Extractiondone"
Header is 403 lines long
About to compress 1540 KB of data ...
Adding files to archive named "./ backup.run" ...
Self-extractible archive "./ backup.run" successfully created.
In order to extract the document file, simply perform document:
Creating directory backup
Verifying archive integrity ... All good.
Uncompressing SFX archive forbackup .............
Create self-extracting installation file
If you want to create a self-extracting installation file, you need to prepare a separate startup script, it will perform the installation process after the extraction is complete.
1. Create a temporary directory
2. Copy the file to the directory sftpupload-20141118.zip
#cp < dir> /sftpupload-20141118.zip sftpupload
3. Then create a script in sftpupload Shell installation directory, called install.sh:
# Vi sftpupload / install.sh
#! / Bin / bash
echo "Upload start ..."
CURRENT_DIR = `pwd`
echo "1. Current directory $ CURRENT_DIR"
INSTALL_DIR = / data / natspace / nat / script / pyscript / sftpupload
TEMP_DIR = $ CURRENT_DIR / sftpupload
ZIP_FILE = sftpupload-20141118.zip
echo "2. Unzip file: $ ZIP_FILE to $ TEMP_DIR"
rm -rf $ TEMP_DIR
unzip $ ZIP_FILE -d $ TEMP_DIR
cd $ TEMP_DIR
echo "3. Check the directory: $ INSTALL_DIR"
if [! -d $ INSTALL_DIR]; then
mkdir -p $ INSTALL_DIR
echo "4. Remove stop -. * shscript!"
rm -rf $ INSTALL_DIR / stop- *
echo "5. Move file to $ INSTALL_DIR"
mv -f * $ INSTALL_DIR
chmod 755 $ INSTALL_DIR / *. sh
echo "6. Delete the directory: $ CURRENT_DIR"
cd $ INSTALL_DIR
rm -rf $ CURRENT_DIR # TODO: makeself after execution of the script is finished remove the directory itself
echo "7. Execute stop-all.shscript"
echo "Update done!"
Then let the startup script has the executable:
$ Chmod 755 sftpupload / install.sh
Continue to create a self-extracting installation file, package startup script, as follows:
$ Makeself.sh sftpupload sftpupload.run "Update sftpupload program" ./install.sh
You must have a note :: install.sh (installation script) before "./" prefix, and install.sh script must have executable permission.
Note: install.sh (installation script) must be placed makeself package directory.