How do Linux binary installers (.bin, .sh) work?

前端 未结 5 1681
故里飘歌
故里飘歌 2020-11-29 15:47

Some software (for ex. the NetBeans IDE) ship the Linux installers in .sh files. Curious about how exactly they \'package\' a whole IDE into a \'shell script\', I opened the

5条回答
  •  野性不改
    2020-11-29 16:36

    You might want to check out makeself.sh

    From the authors' notes.

    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).

    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 [that is execute the script]

    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.

    Finally, the makeself package itself comes as a self-extracting script called makeself.run.

提交回复
热议问题