1. 程式人生 > >使用autotools自動生成Makefile並在此之上使用dh-make生成可釋出的deb程式包(詳解)

使用autotools自動生成Makefile並在此之上使用dh-make生成可釋出的deb程式包(詳解)

一、前言

       本文將介紹如何使用autotools生成一個Makefile檔案,並在此基礎上使用dh-make和debuild生成一個可釋出的deb程式包,這也是我們在Linux下開發應用程式以及想要釋出應用程式需要做的。

       無論是在Linux還是在Unix環境中,make都是一個非常重要的編譯命令。不管是自己進行專案開發還是安裝應用軟體,我們都經常要用到make或 make install。利用make工具,我們可以將大型的開發專案分解成為多個更易於管理的模組,對於一個包括幾百個原始檔的應用程式,使用make和 Makefile工具就可以輕而易舉的理順各個原始檔之間紛繁複雜的相互關係。其中 

Makefile 檔案是用於自動編譯和連結的,一個工程有很多檔案組成,每一個檔案的改變都會導致工程的重新連結,但是不是所有的檔案都需要重新編譯,Makefile中紀錄有檔案的資訊,在make時會決定在連結的時候需要重新編譯哪些檔案。


  Makefile的基本結構不是很複雜,但當一個程式開發人員開始寫Makefile時,經常會懷疑自己寫的是否符合慣例,而且自己寫的Makefile經常和自己的開發環境相關聯,當系統環境變數或路徑發生了變化後,Makefile可能還要跟著修改。所以手動編寫Makefile,對任何程式設計師都是一場挑戰。幸而有GNU 提供的Autoconf及Automake這兩套工具可以然我們自動生成Makefile。


  使用automake,程式開發人員只需要寫一些簡單的含有預定義巨集的檔案,由autoconf根據這個巨集檔案生成configure,由automake根據另一個巨集檔案生成Makefile.in,再使用configure依據Makefile.in來生成一個符合慣例的Makefile。本文將介紹如何利用 GNU Autotools工具來協助我們自動產生 Makefile檔案,生成Makefile檔案後,我們將接著介紹如何使用dh-make和debuild建立一個Debian的安裝包檔案(deb)。這個deb檔案可以拷貝到別的電腦上使用dpkg安裝使用(如果足夠好,可以釋出!)。

這是使用autotools生成Makefile檔案的大體步驟。



二、環境安裝

       我使用的是Ubuntu 13.04(32bit),使用apt-get 安裝以下工具: automake,dh-make ,devscripts。
使用apt-get install automake 將安裝 autoconf{a} automake autotools-dev{a} 三個包。
使用apt-get install dh-make 將安裝 debhelper dh-make html2text三個包。
使用apt-get install devscripts ,這個是使用debuild所需要的。




三、具體步驟

3.1、起步,建立hello.c

在當前目錄下建立一個名為hello的子目錄。進入資料夾並新建一個標準的Hello World的C程式碼hello.c
        #include <stdio.h>
        int main(int argc, char ** argv){
                printf("hello,world\n");
                return 0;
        }
此時,資料夾下只有一個hello.c檔案,


3.2、建立一個 Makefile.am 檔案

        automake根據configure.in中的巨集並在perl的幫助下把Makefile.am轉成Makefile.in檔案。Makefile.am 檔案定義所要產生的目標。我們要填寫的 Makefile.am 內容為以下兩句:
        bin_PROGRAMS=beep         // bin_PROGRAMS:定義要產生的可執行程式的檔名
        beep_SOURCES=hello.c      // beep_SOURCES:定義“beep”這個可執行程式所需要的原始檔案。如果“beep”這個程式是由多個原始檔案產生的,必須把它所用到的所有原始檔案都列出來,並以空白符隔開。假設“beep”還需要“hello.c”、“main.c”、“hello.h”3個檔案,則定義beep_SOURCES= hello.c main.c hello.h。如果定義多個可執行檔案,則對每個可執行程式都要定義相應的filename_SOURCES,其中filename為要生成的可執行程式的檔名。


所以,beep 可以替換為你想要生成的二進位制可執行檔名(後面生成deb檔案也是一樣的名稱),如果我最終我們生成的應用名為long.deb,上面兩句就寫成:
        bin_PROGRAMS=long
        long_SOURCES=hello.c
當前我們目錄下只有:hello.c  Makefile.am 兩個檔案
        [email protected]:/tmp/hello$ vim Makefile.am
        [email protected]:/tmp/hello$ ls
        hello.c  Makefile.am


3.3、執行autoscan命令

執行autoscan命令,會生成一個configure.scan檔案,將configure.scan改名為configure.in
         [email protected]:/tmp/hello$ autoscan
         [email protected]:/tmp/hello$ ls
         autoscan.log  configure.scan  hello.c  Makefile.am
         [email protected]:/tmp/hello$ mv configure.scan configure.in
         [email protected]:/tmp/hello$ ls

         autoscan.log  configure.in  hello.c  Makefile.am

configure.in 檔案的內容是一系列GNU m4 的巨集,這些巨集經autoconf處理後會變成檢查系統特性的Shell指令碼。configure.in檔案中巨集的順序並沒有特別的規定,但是每一個configure.in 檔案必須以巨集AC_INIT開頭,以巨集AC_OUTPUT結束。


3.4、開啟configure.in並修改

開啟configure.in檔案我們會看到自動生成的configure.in(scan)包括以下內容:
        #                                               -*- Autoconf -*-
        # Process this file with autoconf to produce a configure script.

        AC_PREREQ([2.69])      // 此行是描述需要的工具相容性,如我們使用的是autotools工具版本是2.69,這個自動生成不要修改
        AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])     // 此行是描述我們要生成的應用的資訊,包括:應用名,版本號以及維護人郵箱(直譯為反饋bug地址)。比如我們需要將此行修改成 AC_INIT([beep], [0.1], [[email protected]])
        //下面兩行形容的是軟體包的地址和名稱,以便autotools開始工作
        AC_CONFIG_SRCDIR([hello.c])

        AC_CONFIG_HEADERS([config.h])

        // 在這我們需要加入一行“ AM_INIT_AUTOMAKE ”,如果沒有此行,在部分系統生成Makefile時會報錯而且生成不了Makefile檔案。
        # Checks for programs.
        AC_PROG_CC//這句高速autotools使用預設的編譯器和binutils,當然你也可以傳入類似於“ AC_PROG_CC([gcc gcc-4.7]) ”的引數,我們不傳參,使用預設即可

        # Checks for libraries.

        # Checks for header files.

        # Checks for typedefs, structures, and compiler characteristics.

        # Checks for library functions.
        // 下面不變
        AC_CONFIG_FILES([Makefile])// 設定configure命令所要產生的檔案。我們最終期望產生Makefile

        AC_OUTPUT

所以,經過修改後,我們的configure.in檔案是:
        #                                               -*- Autoconf -*-
        # Process this file with autoconf to produce a configure script.
        
        AC_PREREQ([2.69])
        AC_INIT([beep], [0.1], [[email protected]])
        AC_CONFIG_SRCDIR([hello.c])
        AC_CONFIG_HEADERS([config.h])
        AM_INIT_AUTOMAKE
        # Checks for programs.
        AC_PROG_CC
        
        # Checks for libraries.
        
        # Checks for header files.
        
        # Checks for typedefs, structures, and compiler characteristics.
        
        # Checks for library functions.
        
        AC_CONFIG_FILES([Makefile])
        AC_OUTPUT



3.5、 執行autoheader和aclocal命令

        autoheader是用來對映標頭檔案,aclocal用來設定所有的巨集(執行aclocal會產生aclocal.m4檔案,如果沒有特別的要求,無需修改它。用 aclocal產生的巨集將會提示automake如何動作。)。
        [email protected]:/tmp/hello$ ls
        autoscan.log  configure.in  hello.c  Makefile.am
        [email protected]:/tmp/hello$ autoheader 
        [email protected]:/tmp/hello$ ls
        autom4te.cache  autoscan.log  config.h.in  configure.in  hello.c  Makefile.am
        [email protected]:/tmp/hello$ aclocal
        [email protected]:/tmp/hello$ ls
        aclocal.m4  autom4te.cache  autoscan.log  config.h.in  configure.in  hello.c  Makefile.am
        [email protected]:/tmp/hello$ 


3.6、使用automake命令了:

        [email protected]:/tmp/hello$ automake
        configure.in:8: required file `./install-sh' not found
        configure.in:8:   `automake --add-missing' can install `install-sh'
        configure.in:8: required file `./missing' not found
        configure.in:8:   `automake --add-missing' can install `missing'
        Makefile.am: required file `./INSTALL' not found
        Makefile.am:   `automake --add-missing' can install `INSTALL'
        Makefile.am: required file `./NEWS' not found
        Makefile.am: required file `./README' not found
        Makefile.am: required file `./AUTHORS' not found
        Makefile.am: required file `./ChangeLog' not found
        Makefile.am: required file `./COPYING' not found
        Makefile.am:   `automake --add-missing' can install `COPYING'
       所以,根據提示,我們缺少 NEWS、README、AUTHORS、ChangeLog和COPYING,而使用automake --add-missing會生成COPYING,所以在此之前我們需要手動新增這幾個檔案:
        [email protected]:/tmp/hello$ touch NEWS README AUTHORS ChangeLog
        [email protected]:/tmp/hello$ ls
        aclocal.m4  autom4te.cache  ChangeLog    configure.in  Makefile.am  README
        AUTHORS     autoscan.log    config.h.in  hello.c       NEWS

注:這是我在演示如何使用autotools,如果是你真得要釋出軟體,請仔細填寫這幾個檔案,而不是使用touch生成一個空檔案。

現在我們可以使用automake --add-missing:
        [email protected]:/tmp/hello$ automake --add-missing 
        configure.in:8: installing `./install-sh'
        configure.in:8: installing `./missing'
        Makefile.am: installing `./INSTALL'
        Makefile.am: installing `./COPYING' using GNU General Public License v3 file
        Makefile.am:     Consider adding the COPYING file to the version control system
        Makefile.am:     for your code, to avoid questions about which license your project uses.
        [email protected]:/tmp/hello$ ls
        aclocal.m4  autom4te.cache  ChangeLog    configure.in  hello.c  install-sh   Makefile.in  NEWS
        AUTHORS     autoscan.log    config.h.in  COPYING       INSTALL  Makefile.am  missing      README
會發現,現在使用automake很順利,而且生成了INSTALL、COPYING等檔案。


3.7、使用autoconf

        [email protected]:/tmp/hello$ ls
        aclocal.m4  autom4te.cache  ChangeLog    configure.in  hello.c  install-sh   Makefile.in  NEWS
        AUTHORS     autoscan.log    config.h.in  COPYING       INSTALL  Makefile.am  missing      README
        [email protected]:/tmp/hello$ autoconf 
        [email protected]:/tmp/hello$ ls
        aclocal.m4  autom4te.cache  ChangeLog    configure     COPYING  INSTALL     Makefile.am  missing  README
        AUTHORS     autoscan.log    config.h.in  configure.in  hello.c  install-sh  Makefile.in  NEWS
所以,我們可以看到,使用autoconf命令生成了configure。


3.8、./configure , make

接下來的工作無非就是使用configure,生成make檔案:
        [email protected]:/tmp/hello$ ./configure 
        checking for a BSD-compatible install... /usr/bin/install -c
        checking whether build environment is sane... yes
        ……(a lot of cheaking)
        configure: creating ./config.status
        config.status: creating Makefile
        config.status: creating config.h
        config.status: executing depfiles commands
        [email protected]:/tmp/hello$ls
        aclocal.m4      autoscan.log  config.h.in    configure     depcomp  install-sh   Makefile.in  README
        AUTHORS         ChangeLog     config.log     configure.in  hello.c  Makefile     missing      stamp-h1
        autom4te.cache  config.h      config.status  COPYING       INSTALL  Makefile.am  NEWS


所以,使用./configure生成了Makefile、config.h和其他一些檔案。

因為此時Makefile檔案已經生成,所以我們可以使用make命令了:
        [email protected]:/tmp/hello$ make
        (CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/bash /tmp/hello/missing --run autoheader)
        rm -f stamp-h1
        touch config.h.in
        cd . && /bin/bash ./config.status config.h
        config.status: creating config.h
        make  all-am
        make[1]: 正在進入目錄 `/tmp/hello'
        gcc -DHAVE_CONFIG_H -I.     -g -O2 -MT hello.o -MD -MP -MF .deps/hello.Tpo -c -o hello.o hello.c
        mv -f .deps/hello.Tpo .deps/hello.Po
        gcc  -g -O2   -o beep hello.o  
        make[1]:正在離開目錄 `/tmp/hello'
        [email protected]:/tmp/hello$ ls             // 使用make命令後,生成了二進位制可執行檔案,因為我們在上面已經指定,所以生成的可執行檔名不是hello而是beep
        aclocal.m4      autoscan.log  config.h      config.log     configure.in  hello.c  install-sh   Makefile.in  README
        AUTHORS         beep          config.h.in   config.status  COPYING       hello.o  Makefile     missing      stamp-h1
        autom4te.cache  ChangeLog     config.h.in~  configure      depcomp       INSTALL  Makefile.am  NEWS
        [email protected]:/tmp/hello$ ./beep // 執行二進位制可執行檔案,得正確的執行結果
        hello,world


分析一下可以發現,我們這一步的步驟大致是這樣的:
         Makefile.in -----+                        +-> Makefile    -----+-> make -> binary
         src/Makefile.in -+-> ./configure -+-> src/Makefile   -+

         config.h.in -----+                         +-> config.h     -----+

其實此時,在當前目錄下有Makefile檔案,我們可以做的工作有:
*    make all:產生設定的目標,即生成所有的可執行檔案。使用make也可以達到此目的。
*    make clean:刪除之前編譯時生成的可執行檔案及目標檔案(形如*.o的中間檔案)。
*    make distclean:除了刪除可執行檔案和目標檔案以外,把configure所產生的 Makefile檔案也清除掉。通常在釋出軟體前執行該命令。
*    make install:將使用make all或make命令產生的可執行檔案以軟體的形式安裝到系統中。若使用bin_PROGRAMS巨集,程式將會被安裝到 /usr/local/bin下,否則安裝到預定義的目錄下。
*    make dist:將程式和相關的文件包裝為一個壓縮文件以供釋出。執行完該命令,在當前目錄下會產生一個名為PACKAGE-VERSION.tar.gz的檔案。PACKAGE 和 VERSION 這兩個引數是來自configure.in檔案中的AM_INIT_AUTOMAKE(PACKAGE,
VERSION)。如在上個例子中執行make dist命令,會產生名為“hello-1.0.tar.gz”的檔案。
*   make distcheck:與make dist類似,但是加入了檢查包裝以後的壓縮檔案是否正常。

======================= 下面步驟是生成deb程式包,Debian系專屬 ==================================

3.9、make dist 提取源程式包

      下面,我們做的可是高階大氣上檔次的工作 -- 生成可釋出的Debian應用包 -- deb檔案。(Debian系Linux專屬哦)
首先,我們使用“ make dist ”命令,make dist將程式和相關的文件包裝為一個壓縮文件以供釋出。從此,你將再也不想手動寫Makefile!!
        [email protected]:/tmp/hello$ make dist
        if test -d "beep-0.1"; then find "beep-0.1" -type d ! -perm -200 -exec chmod u+w {} ';' && rm -rf "beep-0.1" || { sleep 5 && rm -rf "beep-0.1"; }; else :; fi
        test -d "beep-0.1" || mkdir "beep-0.1"
        test -n "" \
        || find "beep-0.1" -type d ! -perm -755 \
        -exec chmod u+rwx,go+rx {} \; -o \
         ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
         ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
         ! -type d ! -perm -444 -exec /bin/bash /tmp/hello/install-sh -c -m a+r {} {} \; \
        || chmod -R a+r "beep-0.1"
        tardir=beep-0.1 && ${TAR-tar} chof - "$tardir" | GZIP=--best gzip -c >beep-0.1.tar.gz
        if test -d "beep-0.1"; then find "beep-0.1" -type d ! -perm -200 -exec chmod u+w {} ';' && rm -rf "beep-0.1" || { sleep 5 && rm -rf "beep-0.1"; }; else :; fi
        [email protected]:/tmp/hello$ ls
        aclocal.m4      autoscan.log     config.h     config.status  COPYING  install-sh   Makefile.in  README
        AUTHORS         beep-0.1.tar.gz  config.h.in  configure      hello.c  Makefile     missing      stamp-h1
        autom4te.cache  ChangeLog        config.log   configure.in   INSTALL  Makefile.am  NEWS
我們可以看到,目錄裡多了個beep-0.1.tar.gz檔案。這就是我們後續工作的核心


3.10、切換新的工作目錄:

        [email protected]:/tmp/hello$ mkdir ../hello_deb
        [email protected]:/tmp/hello$ cd ../hello_deb/
        [email protected]:/tmp/hello_deb$ cp ../hello/beep-0.1.tar.gz ./
        [email protected]:/tmp/hello_deb$ ls
        beep-0.1.tar.gz
        [email protected]:/tmp/hello_deb$ tar -xzf beep-0.1.tar.gz 
        [email protected]:/tmp/hello_deb$ ls
        beep-0.1  beep-0.1.tar.gz
        [email protected]:/tmp/hello_deb$ cd beep-0.1/
        [email protected]:/tmp/hello_deb/beep-0.1$ ls
        aclocal.m4  ChangeLog    configure     COPYING  install-sh   Makefile.in  NEWS
        AUTHORS     config.h.in  configure.in  INSTALL  Makefile.am  missing      README


3.11、使用dh_make建立debian檔案目錄:

       為了建立一個Debian包,我們首先要建立一個Debian控制檔案,所以我們需要先配置dh_make,最基本的我們需要先配置如下兩個選項(當然,還有其他更多的選項,現在我們就配置最簡單的):
        export DEBFULLNAME="your name"
        export DEBEMAIL="[email protected]"
在此我們需要配置Debian包的維護人名稱和郵箱,比如我就可以寫:
        export DEBFULLNAME="Zhouyl"

        export DEBEMAIL="[email protected]"

做好上述步驟後,我們可以使用“ dh_make --single -copyright=gpl3 -f ../beep-0.1.tar.gz ” ,會提示一些確認資訊,其中需要選擇"single" (s)型包。
        [email protected]:/tmp/hello_deb/beep-0.1$ export DEBFULLNAME="Zhouyl"
        [email protected]:/tmp/hello_deb/beep-0.1$ export DEBEMAIL="[email protected]"
        [email protected]:/tmp/hello_deb/beep-0.1$ dh_make --single -copyright=gpl3 -f ../beep-0.1.tar.gz 
        Maintainer name  : Zhouyl
        Email-Address    : [email protected] 
        Date             : Mon, 14 Oct 2013 10:03:41 +0800
        Package Name     : beep
        Version          : 0.1
        License          : gpl3
        Type of Package  : Single
        Hit <enter> to confirm: 
        Done. Please edit the files in the debian/ subdirectory now. beep
        uses a configure script, so you probably don't have to edit the Makefiles.


3.12、編輯debian/control檔案

現在我們ls下當前目錄,會發現當前目錄下多了一個debian目錄,我們cd進debian目錄,開啟control檔案:
[email protected]:/tmp/hello_deb/beep-0.1$ cd debian/
[email protected]:/tmp/hello_deb/beep-0.1/debian$ vim control
----- 下面是control內容
Source: beep// 程式包名
Section: unknown// 使用 unknown 或者misc 都可以,建議使用 misc
Priority: extra
Maintainer: Zhouyl <[email protected]>
Build-Depends: debhelper (>= 8.0.0), autotools-dev
Standards-Version: 3.9.4
Homepage: <insert the upstream URL, if relevant> // 如果你的程式有官方網站,在此編輯上網站地址
#Vcs-Git: git://git.debian.org/collab-maint/beep.git
#Vcs-Browser: http://git.debian.org/?p=collab-maint/beep.git;a=summary


Package: beep
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: <insert up to 60 chars description>
 <insert long description, indented with spaces>





3.13、使用debuild生成deb應用包

cd ..進入beep-0.1目錄,使用debuild命令
[email protected]:/tmp/hello_deb/beep-0.1/debian$ cd ..
[email protected]:/tmp/hello_deb/beep-0.1$ debuild
 dpkg-buildpackage -rfakeroot -D -us -uc
dpkg-buildpackage: 原始碼包 beep
dpkg-buildpackage: 原始碼版本 0.1-1
dpkg-buildpackage: 原始碼修改者 Zhouyl <[email protected]>
 dpkg-source --before-build beep-0.1
dpkg-buildpackage: 主機架構 i386
……
gpg: “Zhouyl <[email protected]>”已跳過:私鑰不可用
gpg: /tmp/debsign.rFNS3UeK/beep_0.1-1.dsc: clearsign failed: 私鑰不可用
debsign: gpg error occurred!  Aborting....
debuild: fatal error at line 1278:
running debsign failed
所以,此時因為需要gpg金鑰,而當前還沒設定(為不可用的),所以遇到錯誤並退出,我們使用 gpg --gen-key 命令:
        [email protected]:/tmp/hello_deb/beep-0.1$ gpg --gen-key
        gpg (GnuPG) 1.4.12; Copyright (C) 2012 Free Software Foundation, Inc.
        This is free software: you are free to change and redistribute it.
        There is NO WARRANTY, to the extent permitted by law.
        
        請選擇您要使用的金鑰種類:
           (1) RSA and RSA (default)
           (2) DSA and Elgamal
           (3) DSA (僅用於簽名)
           (4) RSA (僅用於簽名)
        您的選擇? 
        RSA 金鑰長度應在 1024 位與 4096 位之間。
        您想要用多大的金鑰尺寸?(2048) 
        您所要求的金鑰尺寸是 2048 位
        請設定這把金鑰的有效期限。
                 0 = 金鑰永不過期
              <n>  = 金鑰在 n 天后過期
              <n>w = 金鑰在 n 周後過期
              <n>m = 金鑰在 n 月後過期
              <n>y = 金鑰在 n 年後過期
        金鑰的有效期限是?(0) 
        金鑰永遠不會過期
        以上正確嗎?(y/n) y
        
        您需要一個使用者標識來辨識您的金鑰;本軟體會用真實姓名、註釋和電子郵件地址組合
        成使用者標識,如下所示:
            “Heinrich Heine (Der Dichter) <[email protected]>”
        
        真實姓名: Zhouyl
        電子郵件地址: [email protected]
        註釋: hello for test
        您選定了這個使用者標識:
            “Zhouyl (hello for test) <[email protected]>”
        
        更改姓名(N)、註釋(C)、電子郵件地址(E)或確定(O)/退出(Q)? O
        您需要一個密碼來保護您的私鑰。
        
        我們需要生成大量的隨機位元組。這個時候您可以多做些瑣事(像是敲打鍵盤、移動
        滑鼠、讀寫硬碟之類的),這會讓隨機數字發生器有更好的機會獲得足夠的熵數。
        
        隨機位元組不夠多。請再做一些其他的瑣事,以使作業系統能蒐集到更多的熵!
        (還需要278位元組)
        
        
        
        
        ^[[A^[[A^[[B+++++
        ...+++++
        我們需要生成大量的隨機位元組。這個時候您可以多做些瑣事(像是敲打鍵盤、移動
        滑鼠、讀寫硬碟之類的),這會讓隨機數字發生器有更好的機會獲得足夠的熵數。
        ........+++++
        ...+++++
        gpg: /home/dslab/.gnupg/trustdb.gpg:建立了信任度資料庫
        gpg: 金鑰 A5318445 被標記為絕對信任
        公鑰和私鑰已經生成並經簽名。
        
        gpg: 正在檢查信任度資料庫
        gpg: 需要 3 份勉強信任和 1 份完全信任,PGP 信任模型
        gpg: 深度:0 有效性:  1 已簽名:  0 信任度:0-,0q,0n,0m,0f,1u
        pub   2048R/A5318445 2013-10-14
              金鑰指紋 = CD58 76C8 BE9C 242E ADEA  F277 FE5D 11BB A531 8445
        uid                  Zhouyl (hello for test) <[email protected]>
        sub   2048R/0FCA8EE0 2013-10-14
        

        [email protected]:/tmp/hello_deb/beep-0.1$ 

       在使用gpg --gen-key建立金鑰時,使用預設即可,在需要傳入姓名郵箱時你輸入自己的資訊即可,如果在下面執行時遇到我上述錯誤時“ 我們需要生成大量的隨機位元組。這個時候您可以多做些瑣事(像是敲打鍵盤、移動滑鼠、讀寫硬碟之類的),這會讓隨機數字發生器有更好的機會獲得足夠的熵數。 ”(英文系統為:Not enough random bytes available. Please do some other work to give the OS a chance to collect more entropy! (Need 284 more bytes)),不要驚慌,因為建立金鑰時為了提高安全等級,會需要從系統中的隨機數熵池中選擇隨機數熵從而生成足夠好的金鑰,從而達到更好的加密效果(我們的Linux中使用所有的操作作為隨機數熵的源,比如說鍵盤輸入、滑鼠移動以及網絡卡收包等,這些都是很隨機的,所以當前報錯隨機熵不夠,我們只需要手動新增隨機熵即可,比如說多移動滑鼠,多敲打鍵盤,最有效的方法是:開啟另一個終端,使用“ find / ” 命令(多開幾個會更快),這些會很快的新增隨機數熵池,上面建立金鑰會很快就繼續進行)。


此時,我們繼續使用debuild建立deb程式包即可。
        [email protected]:/tmp/hello_deb/$ ls
        beep-0.1                  beep_0.1-1.dsc         beep_0.1-1_i386.changes  beep_0.1.orig.tar.gz

        beep_0.1-1.debian.tar.gz  beep_0.1-1_i386.build  beep_0.1-1_i386.deb      beep-0.1.tar.gz 

=====================
部分引用自:
【1】http://www.cnblogs.com/phinecos/archive/2008/11/27/1342381.html
【2】http://www.ibm.com/developerworks/cn/linux/l-makefile/
【3】http://www.yesky.com/120/1865620.shtml

相關推薦

使用autotools自動生成Makefile之上使用dh-make生成釋出deb程式

一、前言        本文將介紹如何使用autotools生成一個Makefile檔案,並在此基礎上使用dh-make和debuild生成一個可釋出的deb程式包,這也是我們在Linux下開發應用程式以及想要釋出應用程式需要做的。        無論是在Linux還是在U

使用autotools自動生成Makefile以上使用dh-make生成釋出deb程式

一、前言        本文將介紹如何使用autotools生成一個Makefile檔案,並在此基礎上使用dh-make和debuild生成一個可釋出的deb程式包,這也是我們在Linux下開發應用程式以及想要釋出應用程式需要做的。        無論是在Lin

Mybatis Generator反向生成配置

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN

利用Lucene測試索引生成的.fnm 和 .fdx 和 .fdt 和 .tii 和 .tis檔案所包含的內容

wechat:812716131 ------------------------------------------------------ 技術交流群請聯絡上面wechat ----------------------------------------------

建立keil工程點亮STM32板子的LED燈

開啟之前建立的工程,如下圖所示(keil工程的建立在之前的文章中有,不瞭解的同學可以翻一下上一篇文章。) (上圖是已經建立完成的工程) 然後,再次開啟我們之前下載的對應開發板版本的例程包中的點亮LED燈的例程 (路徑為:en.stsw-stm32077 \STM32L1x

python介面自動化三十三-python自動發郵件總結及例項說明番外篇——下

簡介   發郵件前我們需要了解的是郵件是怎麼一個形式去傳送到對方手上的,通俗點來說就是你寫好一封信,然後裝進信封,寫上地址,貼上郵票,然後就近找個郵局,把信仍進去,其他的就不關心了,只是關心時間,而電子郵件不像日常傳送郵件的按天算,時間都是按 秒算的。 電子郵件的傳送流程: 1、你使用某款電子

idea創建.gitignore從遠程git中刪除要忽略的目錄如.idea

git1、將.idea目錄加入ignore清單.gitignore內容: /.idea//part00-common/target//part01-lambda/target/ 2、從git中刪除idea git rm --cached -r .idea 3、將.gitignore文件加入git g

IDEA裏如何實現自動導入和導入優化的設置?適合各種語言圖文

pic add 分享 str sca 詳解 個人博客 optimize html   不多說,直接上幹貨! 前言   為什麽需要自動導入包?為什麽需要導入包優化呢?   答: IDEA裏如何實現自動導

CentOS7下如何正確安裝啟動Docker圖文

main transacti linux. 機制 cee HA 管理 docke project   我使用了CentOS 7操作系統,可以非常容易地安裝Docker環境。假設,下面我們都是用root用戶進行操作,執行如下命令進行準備工作: yum install

全網最詳細的zkfc啟動以後,幾秒鐘以後自動關閉問題的解決辦法圖文

qq群 spa 同時 CA 研究 圖文 ogg bigdata 火墻   不多說,直接上幹貨! 問題詳情   情況描述如題所示,zkfc啟動以後,幾秒鐘以後自動關閉。 解決辦法:   1、檢查下每臺機

全網最詳細的HBase啟動以後,HMaster進程啟動了,幾秒鐘以後自動關閉問題的解決辦法圖文

圖片 png 刪除 sunny lan 技術 領域 regions pre     不多說,直接上幹貨!  問題詳情   情況描述如題所示,hbase啟動以後,HMaster進程啟動了,幾秒鐘以後自動關閉,但是HRegionServer進程正常運

搜索系統中所有以.repo結尾的文件刪除find命令及xargs命令

搜索系統 輸入 最大的 tin fin pro 多個 term 傳遞參數 find / -name *.repo | xargs rm –rf //搜索以.repo結尾的文件並刪除 find命令詳解 精細查找文件或目錄d find [ 查找範圍 ]

Redis資料庫如何快速瞭解使用)(第一篇)(共五篇

Redis是什麼 Redis是一個開源的資料庫。底層由C語言編寫、開源、支援網路、 基於記憶體也可持久化的日誌型,高效能的key-Value資料庫。 通常被稱為資料結構伺服器, 因為值Value的型別可以為字串(String)、雜湊(Map)、列表(list)、集合(sets)、有序集合(s

docker如何快速瞭解使用)(第一篇)(共五篇)

Docker docker的出現 Docker是誕生於2013年,是dotCloud的一個開源專案,基於Google推出的GO語言實現。遵從Apache2.0協議。 docker的介紹 Docker的目標是實現輕量級的作業系統虛擬化的解決方案。 Docker的基礎是Linu

Linux下auto工具製作Makefile原始碼製作篇

收藏於 2012-03-25 遷移自個人的百度空間 -------------------------------- 一、 概述 為了更好的製作configure與Makefile,我先把製作流程給寫在這裡,好讓大夥都有個心理準備。這裡只說流程,不做解釋。(附圖供參考) 1

eclipse自動提示設定以及問題:去除變數自動提示圖文

原文:https://blog.csdn.net/qq_34114951/article/details/76946320   第一件事 eclipse設定為自動提示 配置步驟: 1 Window > Preferences > Java > Editor &

Delphi 製作自定義資料感知控制元件裝入dpk檔案與DBText類似的資料感知控制元件

一、基礎知識簡介: 1、包的命名介紹:                 包的命名沒有規則,但是建議遵守包的命名約定:包的命名與包的版本相關,包的名稱前面幾個

ViewPager輪播圖:自動無限輪播,手指長按停止,實現點選事件實用版

此Demo是自定義的viewpager,實現功能如下:無限自動輪播,pager點選事件處理,手指長按停止自動輪播,手指擡起恢復自動輪播; 幾乎可以滿足目前專案中的要求;大家可以直接使用; 整個Demo分兩大類,一個是自定義的ViewPager,一個是MainActivi

iOS開發之在scrollview上新增點選解決其子控制元件的點選無響應如tableView

- (void)addTap{ UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:s

使用 openssl 生成證書含openssl

原文 一、openssl 簡介 openssl 是目前最流行的 SSL 密碼庫工具,其提供了一個通用、健壯、功能完備的工具套件,用以支援SSL/TLS 協議的實現。 官網:https://www.openssl.org/source/ 構成部分 密碼演算法庫金鑰和證