Linux安裝包生成工具:checkinstall、makeself


關鍵詞:checkinstall、dpkg、deb/rpm、makeself等等。

 

checkinstall記錄make install安裝的文件,生成相應的(Slackware/RPM/Debian)安裝包;安裝后加入系統包數據庫中,方便從系統中移除以及發布。

checkinstall從源碼編譯,生成一個可發行的安裝包。

1. checkinstall

1.1 安裝checkinstall

Ubuntu下安裝checkinstall如下:

sudo apt install checkinstall

1.2 使用方法

checkinstall -h可以得到試用方法,對checkinstal生成安裝包行為進行配置,同時對安裝包信息進行設置。

最終生成Slackware/RPM/Debian安裝包。

checkinstall 1.6.2, Copyright 2009 Felipe Eduardo Sanchez Diaz Duran
           This software is released under the GNU GPL.

Usage: checkinstall [options] [command [command arguments]]
Options:

*Package type selection*

-t,--type=<slackware|rpm|debian> Choose packaging system
-S                               Build a Slackware package
-R                               Build a RPM package
-D                               Build a Debian package

*Install options*

--install=<yes|no>             Toggle created package installation------------------默認會將執行一次make install,會將這些安裝到系統中。no表示只生成安裝包,不進行安裝。 --fstrans=<yes|no>             Enable/disable the filesystem translation code

*Scripting options*

-y, --default                  Accept default answers to all questions--------------對選項默認采取y。 --pkgname=<name>               Set name---------------------------------------------安裝包名稱。 --pkgversion=<version>         Set version------------------------------------------安裝包版本號。 -A, --arch, --pkgarch=<arch>   Set architecture
--pkgrelease=<release>         Set release
--pkglicense=<license>         Set license
--pkggroup=<group>             Set software group
--pkgsource=<source>           Set source location
--pkgaltsource=<altsource>     Set alternate source location
--pakdir=<directory>           The new package will be saved here
--maintainer=<email addr>      The package maintainer (.deb)
--provides=<list>              Features provided by this package
--requires=<list>              Features required by this package
...

1.3 使用介紹

1.3.1 准備源碼

checkinstall依賴於當前Makefile,需要Makefile支持make install命令。

獲取hello-2.10.tar.gz然后解壓,執行./configure即可獲取checkinstall執行環境。

wget http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz

1.3.2 生成安裝包

通過下面的命令模擬一次make install命令,然后生成hello-x.x-xxxxxxx_amd64.deb安裝包。

sudo checkinstall -y  --backup=no --install=no --pkgname=hello --pkgversion=1.0 --pkgrelease=`date +"%Y%m%d%H"`  --pkggroup=XGroup --maintainer=lu.baoquan@intellif.com --provides=Intellif --pakdir .

1.3.3 使用安裝包(Debian)

通過dpkg進行安裝、刪除、查看信息等。

sudo dpkg -i hello_1.0-2019120614_amd64.deb
sudo dpkg -I hello_1.0-2019120614_amd64.deb
sudo dpkg -r hello

參考文檔:《How To Build Packages From Source Using CheckInstall》、《Checkinstall

2. makeself

makeself制作一個自解壓的可執行包,生成的包類似一個腳本程序;在開頭添加一些腳本,將一個目錄中文件壓縮,並指定一個執行腳本。

再運行可執行包的時候,首先將壓縮目錄解壓到臨時目錄,然后執行指定腳本進行處理。

makefile詳細介紹見https://makeself.io/

2.1 獲取makeself工具

git clone https://github.com/megastep/makeself.git

2.2 使用makeself

makeself的使用選項較多,但是使用./makeself.sh archive/ runtime_installer.sh "SDK Installer" ./install.sh即可創建runtime_installer.sh可執行自解壓包。

這個包的內容來自於archive目錄,執行runtime_installer.sh的時候,主要是行archive目錄中的install.sh腳本。

Usage: ./makeself.sh [params] archive_dir file_name label startup_script [args]
params can be one or more of the following :
    --version | -v     : Print out Makeself version number and exit
    --help | -h        : Print out this help message
    --tar-quietly      : Suppress verbose output from the tar command
    --quiet | -q       : Do not print any messages other than errors.
    --gzip             : Compress using gzip (default if detected)
    --pigz             : Compress with pigz
    --bzip2            : Compress using bzip2 instead of gzip
    --pbzip2           : Compress using pbzip2 instead of gzip
    --xz               : Compress using xz instead of gzip
    --lzo              : Compress using lzop instead of gzip
    --lz4              : Compress using lz4 instead of gzip
    --compress         : Compress using the UNIX 'compress' command
    --complevel lvl    : Compression level for gzip pigz xz lzo lz4 bzip2 and pbzip2 (default 9)
    --base64           : Instead of compressing, encode the data using base64
    --gpg-encrypt      : Instead of compressing, encrypt the data using GPG
    --gpg-asymmetric-encrypt-sign
                       : Instead of compressing, asymmetrically encrypt and sign the data using GPG
    --gpg-extra opt    : Append more options to the gpg command line
    --ssl-encrypt      : Instead of compressing, encrypt the data using OpenSSL
    --ssl-passwd pass  : Use the given password to encrypt the data using OpenSSL
    --ssl-pass-src src : Use the given src as the source of password to encrypt the data
                         using OpenSSL. See "PASS PHRASE ARGUMENTS" in man openssl.
                         If this option is not supplied, the user will be asked to enter
                         encryption password on the current terminal.
    --ssl-no-md        : Do not use "-md" option not supported by older OpenSSL.
    --nochown          : Do not give the target folder to the current user (default)
    --chown            : Give the target folder to the current user recursively
    --nocomp           : Do not compress the data
    --notemp           : The archive will create archive_dir in the
                         current directory and uncompress in ./archive_dir
    --needroot         : Check that the root user is extracting the archive before proceeding
    --copy             : Upon extraction, the archive will first copy itself to
                         a temporary directory
    --append           : Append more files to an existing Makeself archive
                         The label and startup scripts will then be ignored
    --target dir       : Extract directly to a target directory
                         directory path can be either absolute or relative
    --nooverwrite      : Do not extract the archive if the specified target directory exists
    --current          : Files will be extracted to the current directory
                         Both --current and --target imply --notemp
    --tar-extra opt    : Append more options to the tar command line
    --untar-extra opt  : Append more options to the during the extraction of the tar archive
    --nomd5            : Don't calculate an MD5 for archive
    --nocrc            : Don't calculate a CRC for archive
    --sha256           : Compute a SHA256 checksum for the archive
    --header file      : Specify location of the header script
    --follow           : Follow the symlinks in the archive
    --noprogress       : Do not show the progress during the decompression
    --nox11            : Disable automatic spawn of a xterm
    --nowait           : Do not wait for user input after executing embedded
                         program from an xterm
    --lsm file         : LSM file describing the package
    --license file     : Append a license file
    --help-header file : Add a header to the archive's --help output
    --packaging-date date
                       : Use provided string as the packaging date
                         instead of the current date.

    --keep-umask       : Keep the umask set to shell default, rather than overriding when executing self-extracting archive.
    --export-conf      : Export configuration variables to startup_script

2.3 使用自解壓包

安裝自解壓包,直接運行./runtime_installer.sh即可。

如果要查看更多信息輸入./runtime_installer.sh --help,可以查看自解壓包的信息、文件列表、傳遞參數等等。

Makeself version 2.4.0
 1) Getting help or info about ./runtime_installer.sh :
  ./runtime_installer.sh --help   Print this message
  ./runtime_installer.sh --info   Print embedded info : title, default target directory, embedded script ...
  ./runtime_installer.sh --lsm    Print embedded lsm entry (or no LSM)
  ./runtime_installer.sh --list   Print the list of files in the archive
  ./runtime_installer.sh --check  Checks integrity of the archive

 2) Running ./runtime_installer.sh :
  ./runtime_installer.sh [options] [--] [additional arguments to embedded script]
  with following options (in that order)
  --confirm             Ask before running embedded script
  --quiet               Do not print anything except error messages
  --accept              Accept the license
  --noexec              Do not run embedded script
  --keep                Do not erase target directory after running
                        the embedded script
  --noprogress          Do not show the progress during the decompression
  --nox11               Do not spawn an xterm
  --nochown             Do not give the target folder to the current user
  --chown               Give the target folder to the current user recursively
  --nodiskspace         Do not check for available disk space
  --target dir          Extract directly to a target directory (absolute or relative)
                        This directory may undergo recursive chown (see --nochown).
  --tar arg1 [arg2 ...] Access the contents of the archive through the tar command
  --ssl-pass-src src    Use the given src as the source of password to decrypt the data
                        using OpenSSL. See "PASS PHRASE ARGUMENTS" in man openssl.
                        Default is to prompt the user to enter decryption password
                        on the current terminal.
  --                    Following arguments will be passed to the embedded script

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM