Use makeself to create an installation file

Source: Internet
Author: User

Use makeself to create an installation file

Makeself.shis a small shellscript used to generate a self-decompressed tar.gz compressed package from a directory. The result file is displayed as a shell script (most with. run as the suffix) and can be run automatically. This document will decompress itself to a temporary directory and execute an optional command (for example, an installation script ). It is very similar to the files generated by Winzip Self-extracting in Windows. The Makeself documentation also includes checksum for integration of subverification (CRC or MD5 checksum ).

The Makeself. sh script is only used to create a document from the file directory. The generated document is actually a compressed (gzip, bzip2, or compressed) TAR file. Add a small Shell script at the beginning of the file. This is a small Stub script used to extract files, run embedded commands, and delete temporary files. To install software contained in this document, you only need to run the document, for example, sh nice-software.rum. I recommend that these files use "run" or "sh" as the suffix. Do not confuse users because they know that it is actually a Shell script with a considerable amount of binary data.

Makeself has been rewritten since 2.1 and tested on the following Platform:

1. Linux (all releases)

2. Sun Solaris (version 8 or later)

3. HP-UX (11.0 and 11i on the HPPA server)

4. SCO OpenUnix and OpenServer

5. ibm aix 5.1L

6 MacOS X (Dario)

7. sg irix 6.5

8. FreeBSD

9. UnicOS/Cray

10. Cygwin (Windows)

Home Page (Latest Version 2.2.0 ):

Https://github.com/megastep/makeself

Http://megastep.org/makeself/

Source code download:

Https://github.com/megastep/makeself/archive/release-2.2.0.tar.gz

Download the latest official release:

Http://cdn.megastep.org/makeself/makeself-2.2.0.run

Makeself Installation

To install makeself on Linux, download the latest archive format file, execute the downloaded file, when the file is self-extracted, it will create a new directory under the current directory called makeself-2.2.0, copy all shell scripts to the/usr/bin directory to complete the installation.

$ Wgethttp: // megastep.org/makeself/makeself-2.2.0.run

$ Chmod 755 makeself-2.2.0.run

$./Makeself-2.2.2.run

$ Makeself-2.2.0 cd

$ Sudo cp *. sh/usr/bin

Usage

The basic usage of makeself. sh is as follows:

Makeself. sh [args] archive_dir file_namelabel startup_script [script_args]

The "label" parameter is the message printed during SFX decompression. "start_script" specifies the script and command to be executed after the SFX archive file is decompressed successfully. It is useful when you want to create a self-extracting Installation File. Generally, the startup script copies and installs the extracted content to the appropriate target directory. The Startup Script must be in the packaged directory, so the script is included in the SFX archive file.

1. args is an optional parameter of Makeself, which can be:

-- Vesion: print the version information to the console and exit immediately;

--- Gzip: Use GZIP for compression (default option)

--- Bzip2: Use bzip2 for compression

--- Compress: Use the compress command of Unix to compress data.

--- Nocomp: no compression

--- Notemp: you do not need to compress the file to a temporary directory, but create a new subdirectory under the current directory.

--- Current: the file will be decompressed to the current directory, instead of sub-directories, and the -- notemp option is hidden.

--- Follow: follow all symbolic links and package the symbolic link files.

--- Append: recent data is stored in an existing document, instead of creating a new data.

--- Header: Makeself2.0 can start with a standalone file storage header stub, called a makeelf-header.sh, which is assumed to be located in the same location as makeself.

--- Copy :....

2. archive_dir: directory name that contains the archive file

3. file_name: name of the created archive file

4. label: describes any text string of the software package. It is displayed when the file is decompressed.

5. startup_script: command in the extract file directory, so if you want to execute

In the program in this directory, you must add the prefix "./" before your command. For example,./program is correct, and script_args is an additional parameter for modifying the command.

Here is an example. Assume that the user has a package image stored in the/home/joe/mysoft directory, and it wants to generate a self-extracting mysoft. sh package, which will start the setup script stored in the/home/joe/mysoft directory and execute the following command:

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

The following is a command to create the Makeself. run document containing the makeself release:

Makeself. sh -- notempmakeself makeself. run "Makeself by Stephen ane Peter" echo "Makeself has extracted itself"

The document generated by makeself can pass the following parameters:

--- Keep: place the file and decompress it to a temporary directory (it will be deleted after the embedded script is executed ). The file is directly decompressed to the current working directory until you delete it.

--- Verbose: prompt the user before executing the embedded command

--- Target: allows you to extract directories to any location.

--- Confirm: prompt the user to confirm before running the embedded command

--- Info: Print general information about the document (pressure-free)

--- Lsm: Print LSM entries

--- Check: Use the embedded checksum to check the document.

--- Nochown: by default, after decompression, run the "chown-R" command in the target directory so that all files belong to the current user. If you need to run most of the tasks as a root user, tar will try to re-create and initialize the user owner. You can disable this behavior.

--- Tar: run the tar command on the document content and use the following parameters as command parameters.

--- Noexec: Do not run the embedded script after decompression.

Parameters following any document will be passed as additional parameters to embedded commands. Before any of these options, you should use the -- dedicated command line structure to ensure that Makeself will not try to explain them.

Create self-extracting document

To create a self-decompressed file that contains all files under the backup Directory, perform the following operations. The START function only prints "Extraction done" and does not do more.

$ 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 "...

./

./Jpeg/

./Jpeg/1.jpg

.

.

CRCs: 2238411397

MD5: 0b0fd3a2ba08ffcec821b9cbaa11b70d

 

Self-extractible archive "./backup. run" successfully created.

To decompress the files in the document, a simple execution document is as follows:

$./Backup. run

Creating directory backup

Verifying archive integrity... All good.

Uncompressing SFX archive forbackup .............

Done

Create a self-extracting Installation File

If you want to create a self-extracting installation file, you need to prepare a separate STARTUP script, which will execute the installation process after decompression.

1. Create a temporary directory

# Mkdir sftpupload

2.copy the sftpupload-20141118.zip file to this directory.

# Cp <dir>/sftpupload-20141118.zip sftpupload

3. Create a Shell installation script named install. sh in the sftpupload directory:

# Vi sftpupload/install. sh #! /Bin/bashecho "Upload start... "CURRENT_DIR = 'pwd' echo" 1. current directory $ CURRENT_DIR "INSTALL_DIR =/data/natspace/nat/script/pyscript/sftpuploadTEMP_DIR = $ CURRENT_DIR/sftpuploadzip_file1_sftpupload-20141118.zip echo" 2. unzip file: $ ZIP_FILE to $ TEMP_DIR "rm-rf $ TEMP_DIRunzip $ ZIP_FILE-d $ TEMP_DIRcd $ TEMP_DIRecho" 3. check the directory: $ INSTALL_DIR "if [! -D $ INSTALL_DIR]; thenmkdir-p $ INSTALL_DIRfiecho "4. Remove stop-*. shscript! "Rm-rf $ INSTALL_DIR/stop-* echo" 5. move file to $ INSTALL_DIR "mv-f * $ INSTALL_DIRchmod 755 $ INSTALL_DIR /*. shecho "6. delete the directory: $ CURRENT_DIR "cd $ INSTALL_DIRrm-rf $ CURRENT_DIR # TODO: the echo" 7. execute stop-all.shscript ". /stop-all.shecho "Update done! "

Then let the startup script be executable:

$ Chmod 755 sftpupload/install. sh

Continue, create a self-extracting Installation File and package the startup script as follows:

$ Makeself. sh sftpupload. run "Update sftpupload program"./install. sh

Note: The install. sh (installation script) must be prefixed with "./" and the install. sh script must have executable permissions.

Note: install. sh (installation script) must be placed in the makeself package directory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.