Deb, rpm, run program installation package production

run package

Reprinted from: Making the .run installation package under linux

Introduction

The run program installation package is essentially an installation script plus the program to be installed, and the file suffix is ​​.run. Installation is simple, with xxx.runan example: Run a terminal or console sh xxx.run.
——————
| Installation script |
——————
| Program package |
——————
run Installation package is a good choice to make a smaller program package , but it also has disadvantages and the logic is more complicated. The installation package, the installation script written will be very troublesome, so it is better to use other installation packages at this time.

Make

  • Create a test executable file (pretend it is executable~~)
touch test
  • Compressed into tar.gzfile
tar -zcvf test.tar.gz test
  • Create shell scripttest.sh
#!/bin/bash
lines=8                                  #这个值是指这个脚本的行数加 1,这个脚本共有 7 行
tail -n +$lines $0 >/tmp/test.tar.gz  # $0 表示脚本本身,这个命令用来把从 $lines 开始的内容写入一个 /tmp 目录的 test.tar.gz 文件里。
tar -zxvf /tmp/test.tar.gz
cp test /usr/bin
rm test -f
exit 0 # 在脚本的最后一行后面不能有空行(这与参考的博客中不一样,博客中要求有一个空行)

The Linux tail command
tail -f filename will display the last content in the filename file on the screen and refresh it continuously. As long as the filename is
updated, you can see the latest file content.
Command format:
tail [parameter] [file]
parameter:
-f cyclic reading
-q does not display processing information
-v displays detailed processing information
-c<number> the number of bytes displayed
-n<number of lines> displays the end of the file The content of the n line
--pid=PID is used in combination with -f, which means that the process ID and PID die after the end
-q, --quiet, --silent Never output the first part of the given file name
-s, --sleep-interval= S is used in combination with -f, which means sleep for S seconds at the interval of each repetition

  • catConnect script and compressed package to generate test.runinstallation package
cat test.sh test.tar.gz > test.run
  • Run the test.runinstallation package and install the executable file to the /usr/bindirectory
sh ./test.run

deb package

Reprinted from: How to make deb package
dpkg make deb package

Introduction

deb is the format of ubuntu and debian. It is the software package of the debian release. ubuntu is based on debian so it can be used.
dpkg is the abbreviation of Debian Package. It is a package management system specially developed for Debian to facilitate the installation, update and removal of software. All Linux distributions from Debian use dpkg, such as Ubuntu, Knoppix, etc.

Package structure

Package structure
PS: In the above figure, helloworld is the program file or folder to be installed, which will be in the /opt directory .

Including the DEBIAN directory and the specific software installation directory (simulation installation directory) (such as etc, usr, opt, tmp, etc.).
There are at least control files in the DEBIAN directory, and there may also be postinst (postinstallation), postrm (postremove), preinst (preinstallation), prerm (preremove), copyright (copyright), changlog (revision record) and conffiles.

  • Postinst file: Contains the configuration work that the software needs to perform after the normal directory file is copied to the system.
  • prerm file: a script that needs to be executed before the software is uninstalled.
  • postrm file: a script that needs to be executed after the software is uninstalled.
  • Control file: This file is more important. It describes the package name (Package), version (Version), description (Description), etc. It is a descriptive file that must be scripted by the deb package to facilitate software installation management and indexing.

The control file may have the following fields:

  • Package: package name
  • Version: Version
  • Architecture: software package structure, such as i386, amd64, m68k, sparc, alpha, powerpc, etc.
  • Priority: State the importance of the software to the system, such as required, standard, optional, extra, etc.
  • Essential: Affirm whether it is the most basic software package of the system (the option is yes/no). If it is, it means that the software is a software package that maintains the system stability and normal operation. Uninstall)
  • Section: Declare the category of the software, common ones are utils, net, mail, text, devel, etc.
  • Depends: Other software packages and library files that the software depends on. If you rely on multiple software packages and library files, separate them with commas
  • Pre-Depends: The dependent software packages and library files must be installed and configured before software installation. It is often used for necessary pre-run script requirements
  • Recommends: This field indicates other packages and libraries recommended for installation
  • Suggests: Suggested installation of other packages and libraries
  • Description: the description of the package
  • Installed-Size: Installed package size
  • Maintainer: package maker, contact information, etc.

Make

After creating the corresponding package structure, run the following command

dpkg -b <包目录> <包名称>.deb

The execution dpkg -b mydeb mydeb.debwill generate the mydeb.debsoftware package.

other

  • installation
dpkg -i xxx.deb

After .debexecuting the installation command in the directory where the file is located sudo dpkg -i mydeb.deb, the program file will be /optinstalled in the directory helloworld.

  • Uninstall
dpkg -r <package_name>

Execute in any directory sudo dpkg -r helloworld(note that package_name is the name of the actual installed package, not the deb package name!), /optthe installation helloworldprogram file in the directory will be deleted

  • Unzip the package
dpkg -X xxx.deb [dirname]

After decompressing the .debfile, the specific installation directory of the software and the program files in the directory will be copied to the specified path.
Insert picture description here

  • Generate and delete log files

postinstWrite the following code in the file to generate a log file after the software is installed.

# !/bin/sh
echo "my deb" > ~/Desktop/mydeb.log

postrmWrite the following code in the file to delete the log file after the software is uninstalled.

# !/bin/sh
rm -rf ~/Desktop/mydeb.log

rpm package

RPM package production method

Introduction

rpm is the format of redhat, fedora, and suse. The full name is Redhat Package Manager, which is proposed by Redhat Company to manage software packages under Linux. When Linux is installed, except for a few core modules, almost all modules are installed through RPM.

Make

The principle is similar to that of .deb, and the package structure needs to be defined first, and then packaged.

Guess you like

Origin blog.csdn.net/XindaBlack/article/details/106850017