Simple production of the. run file for Linux

Source: Internet
Author: User
Tags gz file

The Run program installation package is essentially an installation script plus the program to be installed, as shown in:

|-----------------|
| |
| installation Script |
| |
|-----------------|
| |
| program |
| |
|-----------------|
figure: The structure of the run installation package

so the entire run package structure is at a glance, in fact, because the actual need for the structure of a little change, but this does not matter, only need to understand the principle of the line.

Create a Run installation package here are some practical examples:

For the sake of simplicity, the program to be installed is the HelloWorld program, and the process of installing it is to copy it to the/bin directory.

ls install. SH  catinstall. SH #!/bin/bashcp HelloWorld/bin$

Now there is a setup script, named Install.sh, that has a program to install HelloWorld. Because the programs to be installed are generally made with. tar.bz2. We'll do it here too:

tar jcvf HelloWorld. tar. bz2 HelloWorld



Now modify an installation script install.sh

Switch

#!/bin/bashlines=7  #这个值是指这个脚本的行数加1, this script has a total of 6 lines tail + $lines $0 >/tmp/ HelloWorld. tar. GZ # $ represents the script itself, which is used to write content starting from $lines to A/tmp directory of HelloWorld. Tar . gz file.  tar jxvf/tmp/hellowrold. Tar . GZ CP HelloWorld/0



Then use the Cat command to connect the installation scripts install.sh and helloworld.tar.bz2.

Cat install. sh HelloWorld. tar. bz2 > Myinstall.run

This gives you the Myinstall.run file, which is structured as follows:

|------------------| line 1th
| |
| install.sh |
| | line 6th
|------------------|
| | line 7th
|helloworld.tar.bz2|
| |
|------------------| end
figure: Structure of the Myinstall.run installation package

When you run Myinstall.run, the exit 0 script that runs to line 6th exits, so you do not run the binary data (that is, the helloworld.tar.bz2 file) below line 7th. And we used tail to subtly regenerate a helloworld.tar.gz file with the data below line 7th. Perform the installation again.

The run installation package makes it a good choice to make a smaller package, but it also has drawbacks, and it can be cumbersome to make a more complex installation package and write an installation script. So it's better to use a different installation package at this point.

installation method: Take ***.run as example: Run sh ***.run

Source: http://www.linuxdiyf.com/viewarticle.php?id=84934

Related Article

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.