制作 linux 安装包
1 制作 run 安装包
run 程序安装包实质上是一个安装脚本加要安装的程序,如下图所示:
|----------------|
| |
|安装脚本|
| |
|----------------|
| |
|程序|
| |
|----------------|
这样整个 run 安装包结构就一目了然了,实际上因为实际需要结构多少有点变动但这个无
关紧要,只需要明白原理就行了。
安装脚本:helloworld.sh 如下:
#!/bin/bash
lines=11
install_dir=/opt/helloworld
read -p "Please enter the installation directory:" install_dir
echo "The installation directory is:$install_dir"
mkdir -p $install_dir
tail +$lines $0 > /tmp/helloworld.tar.gz
tar -xzf /tmp/helloworld.tar.gz -C $install_dir
rm -rf /tmp/helloworld.tar.gz
exit 0
lines=11 #这个值是指这个脚本的行数加 1,这个脚本共有 10 行