makeself

megastepGPL-2.0活跃维护

用纯 Shell 脚本实现的 Unix 自解压打包工具,把目录和安装脚本压成一个可直接运行的 .run 文件,方便分发和部署软件。

A self-extracting archiving tool for Unix systems, in 100% shell script.

release-2.7.1发布于 2025-12-10 10:13 UTC2,632star409fork同步于 2026-11-07 07:33 UTC

怎么上手

由 README 提炼,执行前请确认
git clone https://github.com/megastep/makeself.git
cd makeself
git submodule update --init --recursive
硬件要求按 README 说明

README 未说明,纯 Shell 脚本,不依赖 GPU 或特定硬件,可在任意 Unix 兼容系统运行

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

纯 Shell 实现的自解压归档工具,把目录打包成可直接运行的 .run 安装包

用纯 Shell 脚本实现的 Unix 自解压打包工具,把目录和安装脚本压成一个可直接运行的 .run 文件,方便分发和部署软件。

核心能力

  • 用 makeself.sh 将目录打包为自解压 tar 归档
  • 生成文件带 shell 脚本头,可直接 sh 运行解压
  • 支持 gzip、bzip2、xz、zstd、lz4 等多种压缩
  • 内置 CRC 与 MD5/SHA256 校验自检完整性
  • 可嵌入启动脚本,解压后自动执行安装命令

容易踩的坑

使用 bzip2、xz、zstd 等压缩需系统已安装对应命令;Web 服务器需添加 application/x-makeself MIME 类型否则浏览器按文本显示;旧版归档在部分 GNU 系统解压可能需设置 _POSIX2_VERSION=199209

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本release-2.7.1
  1. release-2.7.1Makeself v2.7.1最新正式版2025-12-10 · 2025-12-10 10:13 UTC
    • Base64 encoding now runs after compression, consistent with other post-compression encryption/encoding options.
    • Documentation updated to reflect that compression can be combined with encryption/encoding.

    Full Changelog: https://github.com/megastep/makeself/compare/release-2.7.0...release-2.7.1

  2. release-2.7.0Makeself v2.7.02025-12-10 · 2025-12-10 01:38 UTC
    查看更新说明
    • Compression now precedes encryption so both can be enabled together.
    • Signing passphrases are masked in stored metadata.
    • Added coverage for combined encryption + compression flows.

    What's Changed

    New Contributors

    Full Changelog: https://github.com/megastep/makeself/compare/release-2.6.0...release-2.7.0

  3. release-2.6.0Makeself v2.62025-09-27 · 2025-09-27 04:13 UTC
    查看更新说明

    Highlights

    • Added --preextract hook with --show-preextract, enabling scripted checks before extraction and full shUnit2 coverage.
    • Introduced --comp-extra so archives can pass extra flags (e.g., --no-name) to any compressor, plus positive/negative tests.
    • Documented SETUP_NOCHECK=1 to skip integrity verification; new regression test ensures behavior.

    Changes

    • CI: Migrated Linux runners to Ubicloud, refreshed BSD/Solaris VMs, ensured zstd availability, and updated Actions to Node 20-compatible versions.
    • Build tweaks: Restored Rocky Linux 9 images, improved base64 handling for BSD/macOS, fixed zstd offset plus checksum messaging.
    • UX fixes: --accept now skips pager, pager invokes -e when available, directory creation and checksum success emit via stdout.
    • Security: OpenSSL encryption defaults to -pbkdf2 with SHA-256 digest to avoid deprecated key derivation.
    • Docs: Updated README/man page for new flags (--comp-extra, --preextract, --target) and checksum environment variable.

    Contributors

    Stephane Peter, Mark Landis, Mykyta Poberezhniy, OMRON SENTECH, zero-pytagoras, Aaron Queen, Dridi Boukelmoune, Jan Vermaete, Joakim Fors, Peter Whittaker, Stas Fomin, emirbuljubasic, mpoberezhniy, the-real-neil

  4. release-2.5.0Makeself v2.5.02023-03-13 · 2023-03-13 11:37 UTC
    查看更新说明
    • Adds improved support for NetBSD, OpenBSD
    • Improved support for minimal Linux distributions such as Alpine
    • Added bzip3 compression support
    • Increased control over GPG signing via the GPG extra parameters
  5. release-2.4.5Makeself 2.4.52021-06-23 · 2021-06-23 12:22 UTC
    查看更新说明

    This release mostly addresses possible incompatibilities with the default ustar TAR format, by introducing a new --tar-format option when creating the format. This allows the user to create an archive using a TAR format more suitable to their use case, such as posix, v7 or anything else supported by their tar command.

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    makeself - Make self-extractable archives on Unix

    License: GPL v2 Build Status

    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 decompress 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 :

    • Linux (all distributions)
    • Sun Solaris (8 and above)
    • HP-UX (tested on 11.0 and 11i on HPPA RISC)
    • SCO OpenUnix and OpenServer
    • IBM AIX
    • macOS (Darwin)
    • SGI IRIX 6.5
    • FreeBSD
    • OpenBSD
    • NetBSD
    • UnicOS / Cray
    • Windows (Cygwin, WSL)

    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 :

    • Game patches and installers for Id Software games like Quake 3 for Linux or Return To Castle Wolfenstein ;
    • All game patches released by Loki Software for the Linux version of popular games ;
    • The nVidia drivers for Linux
    • The installer for the Linux version of Google Earth
    • The VirtualBox installers for Linux
    • The Makeself distribution itself ;-)
    • and countless others...

    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 decompressing 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]
    
    • args are optional options for Makeself. The available ones are :

      • --version : Prints the version number on stdout, then exits immediately

      • --gzip : Use gzip for compression (the default on platforms on which gzip is commonly available, like Linux)

      • --bzip2 : Use bzip2 instead of gzip for better compression. The bzip2 command must be available in the command path. It is recommended that the archive extension be set to something like '.bz2.run', so that potential users know that they'll need bzip2 to extract it.

      • --bzip3 : Use bzip3 instead of gzip for better compression.

      • --pbzip2 : Use pbzip2 instead of gzip for better and faster compression on machines having multiple CPUs. The pbzip2 command must be available in the command path. It is recommended that the archive extension be set to something like '.bz2.run', so that potential users know that they'll need bzip2 to extract it.

      • --xz : Use xz instead of gzip for better compression. The xz command must be available in the command path. It is recommended that the archive extension be set to something like '.xz.run' for the archive, so that potential users know that they'll need xz to extract it.

      • --lzo : Use lzop instead of gzip for better compression. The lzop command must be available in the command path. It is recommended that the archive extension be set to something like .lzo.run for the archive, so that potential users know that they'll need lzop to extract it.

      • --lz4 : Use lz4 instead of gzip for better compression. The lz4 command must be available in the command path. It is recommended that the archive extension be set to something like '.lz4.run' for the archive, so that potential users know that they'll need lz4 to extract it.

      • --zstd : Use zstd instead of gzip for better compression. The zstd command must be available in the command path. It is recommended that the archive extension be set to something like '.zstd.run' for the archive, so that potential users know that they'll need zstd to extract it.

      • --pigz : Use pigz for compression.

      • --base64 : Base64-encode the final compressed archive (base64 command required). This is applied after compression and can be combined with any compressor.

      • --gpg-encrypt : Encrypt the archive using gpg -ac -z $COMPRESS_LEVEL. This is applied after compression. Assumes that potential users have gpg installed.

      • --ssl-encrypt : Encrypt the archive using openssl aes-256-cbc -a -salt. This is applied after compression. Assumes that the potential users have the OpenSSL tools installed.

      • --compress : Use the UNIX compress command to compress the data. This should be the default on all platforms that don't have gzip available.

      • --nocomp : Do not use any compression for the archive, which will then be an uncompressed TAR.

      • --complevel : Specify the compression level for gzip, bzip2, pbzip2, zstd, xz, lzo or lz4. (defaults to 9)

      • --comp-extra : Append more options to the compressor's command line.

      • --threads : Specify the number of threads to be used by compressors that support parallelization. Omit to use compressor's default. Most useful (and required) for opting into xz's threading, usually with --threads=0 for all available cores. pbzip2 and pigz are parallel by default, and setting this value allows limiting the number of threads they use.

      • --notemp : The generated archive will not extract the files to a temporary directory, but in a new directory created in the current directory. This is better to distribute software packages that may extract and compile by themselves (i.e. launch the compilation through the embedded script).

      • --current : Files will be extracted to the current directory, instead of in a subdirectory. This option implies --notemp above.

      • --follow : Follow the symbolic links inside the archive directory, i.e. store the files that are being pointed to instead of the links themselves.

      • --append (new in 2.1.x): Append data to an existing archive, instead of creating a new one. In this mode, the settings from the original archive are reused (compression type, label, embedded script), and thus don't need to be specified again on the command line.

      • --header : Makeself uses a separate file to store the header stub, called makeself-header.sh. By default, it is assumed that it is stored in the same location as makeself.sh. This option can be used to specify its actual location if it is stored someplace else.

      • --preextract : Specify a pre-extraction script. The script is executed with the same environment and initial script_args as startup_script.

      • --cleanup : Specify a script that is run when execution is interrupted or finishes successfully. The script is executed with the same environment and initial script_args as startup_script.

      • --copy : Upon extraction, the archive will first extract itself to a temporary directory. The main application of this is to allow self-contained installers stored in a Makeself archive on a CD, when the installer program will later need to unmount the CD and allow a new one to be inserted. This prevents "Filesystem busy" errors for installers that span multiple CDs.

      • --nox11 : Disable the automatic spawning of a new terminal in X11.

      • --nowait : When executed from a new X11 terminal, disable the user prompt at the end of the script execution.

      • --nomd5 and --nocrc : Disable the creation of a MD5 / CRC checksum for the archive. This speeds up the extraction process if integrity checking is not necessary.

      • --sha256 : Adds a SHA256 checksum for the archive. This is in addition to the MD5 / CRC checksums unless --nomd5 is also used.

      • --lsm file : Provide a Linux Software Map (LSM) file to makeself, that will be embedded in the generated archive. LSM files are describing a software package in a way that is easily parseable. The LSM entry can then be later retrieved using the --lsm argument to the archive.

      • --tar-format opt : Specify the tar archive format (default is ustar); you may use any value accepted by your tar command (such as posix, v7, etc).

      • --tar-extra opt : Append more options to the tar command line.

        For instance, in order to exclude the .git directory from the packaged archive directory using the GNU tar, one can use makeself.sh --tar-extra "--exclude=.git" ...

      • --target dir : Specify the directory where the archive will be extracted.

      • --keep-umask : Keep the umask set to shell default, rather than overriding when executing the self-extracting archive.

      • --packaging-date date : Use provided string as the packaging date instead of the current date.

      • --license file : Append a license file.

      • --nooverwrite : Do not extract the archive if the specified target directory already exists.

      • --help-header file : Add a header to the archive's --help output.

    • archive_dir is the name of the directory that contains the files to be archived

    • file_name is the name of the archive to be created

    • label is an arbitrary text string describing the package. It will be displayed while extracting the files.

    • startup_script is the command to be executed from within the directory of extracted files. Thus, if you wish to execute a program contained in this directory, you must prefix your command with ./. For example, ./program will be fine. The script_args are additional arguments for this command. Note that startup_script and its arguments are not strictly required for archives that don't extract in a temporary directory (i.e. when using --notemp).

    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:

    • --keep : Prevent the files to be extracted in a temporary directory that will be removed after the embedded script's execution. The files will then be extracted in the current working directory and will stay here until you remove them.
    • --verbose : Will prompt the user before executing the embedded command
    • --target dir : Allows to extract the archive in an arbitrary place.
    • --nox11 : Do not spawn a X11 terminal.
    • --confirm : Prompt the user for confirmation before running the embedded command.
    • --info : Print out general information about the archive (does not extract).
    • --lsm : Print out the LSM entry, if it is present.
    • --list : List the files in the archive.
    • --check : Check the archive for integrity using the embedded checksums. Does not extract the archive.
    • --nochown : By default, a chown -R command is run on the target directory after extraction, so that all files belong to the current user. This is mostly needed if you are running as root, as tar will then try to recreate the initial user ownerships. You may disable this behavior with this flag.
    • --tar : Run the tar command on the contents of the archive, using the following arguments as parameter for the command.
    • --noexec : Do not run the embedded script after extraction.
    • --noexec-cleanup : Do not run the embedded cleanup script.
    • --nodiskspace : Do not check for available disk space before attempting to extract.
    • --cleanup-args : Specify arguments to be passed to the cleanup script. Wrap value in quotes to specify multiple 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.

    • To make a release: make
    • To run all tests: make test

    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:

    • One of the main purposes of Makeself is portability. Do not submit patches that will break supported platforms. The more platform-agnostic, the better.
    • Please explain clearly what the purpose of the patch is, and how you achieved it.

    Download

    Get the latest official distribution on Github here (version 2.7.1).

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

    Changelog

    The full release history has moved to CHANGELOG.md.

    Links

    • Check out the "Loki Setup" installer, used to install many Linux games and other applications, and of which I am the co-author. Since the demise of Loki, I am now the official maintainer of the project, and it is now being hosted here on GitHub.
    • Bjarni R. Einarsson also wrote the setup.sh installer script, inspired by Makeself. Check it out !

    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