製作ubuntu的deb格式包,從helloworld做起
1、建立一個我們臨時的工作目錄mkdir deb2、建立我們程式的目錄mkdir hello3、編寫我們的程式我們以我們最熟悉的helloworld程式做起,hello.c代碼如下#include <stdio.h>int main(int argc, char* argv[]){ printf("Hello world!/n"); return 0;}Makefile檔案如下:OBJS=hello.oCC=gcc -gall:$(OBJS) $(CC) -o hello $(OBJS)clean:rm -f *.o hello.PHONY:all clean4、我們make一下,測試程式編譯是否有問題,然後在./hello檢查程式是否正確執行5、如果沒問題進行下一步,如果有問題我們檢查程式碼6、我們清理下剛才編譯器的垃圾,make clean一下7、輸入命令,切回上級目錄cd ..8、進行一次壓縮打包(為什麼做這一步,我也不太明白,查資料說,這一步是為了給產生的deb檔案進行對比,確保我們deb檔案沒有錯誤)改名:因為檔案名稱必須包含檔案名稱還有版本號碼mv hello hello-1.0說明:檔案名稱後必須用-,不能用_tar zcvf hello_1.0.orig.tar.gz hello-1.0說明:壓縮包的名字必須是包含檔案名稱及版本號碼9、進入我們的hello-1.0目錄cd hello-1.010、我們需要dh_make工具進行打包前的配置,如果是第一使用請先安裝dh-makedh-make安裝方法:sudo apt-get install dh-make安裝好後,我們就可以使用該命令了dh_make -e sunsea1026@gmail.com修改參數,也可以不修改,執行這一步,我們將會看到,郵箱是我們剛才輸入的如果不想改為自己的郵箱,可以執行下面命令dh_make上面任一命令後都會出現,一下內容:zsx@ubuntu:~/deb/hello-1.0$ dh_make -e sunsea1026@gmail.comType of package: single binary, indep binary, multiple binary, library, kernel module, kernel patch or cdbs? [s/i/m/l/k/n/b] 11、我們輸入sMaintainer name : zsxEmail-Address: sunsea1026@gmail.com Date: Sat, 18 Dec 2010 23:06:25 +0800Package Name: helloVersion: 1.0License: blankUsing dpatch: noType of Package : SingleHit <enter> to confirm: 12、輸入斷行符號,確認Skipping creating ../hello_1.0.orig.tar.gz because it already existsDone. Please edit the files in the debian/ subdirectory now. You should alsocheck that the hello Makefiles install into $DESTDIR and not in / .13、準備工作完成14、開始打包dpkg-buildpackagedpkg-buildpackage: export CFLAGS from dpkg-buildflags (origin: vendor): -g -O2dpkg-buildpackage: export CPPFLAGS from dpkg-buildflags (origin: vendor): dpkg-buildpackage: export CXXFLAGS from dpkg-buildflags (origin: vendor): -g -O2dpkg-buildpackage: export FFLAGS from dpkg-buildflags (origin: vendor): -g -O2dpkg-buildpackage: export LDFLAGS from dpkg-buildflags (origin: vendor): -Wl,-Bsymbolic-functionsdpkg-buildpackage: 源碼包 hellodpkg-buildpackage: 源碼版本 1.0-1dpkg-buildpackage: 源碼修改者 zsx <sunsea1026@gmail.com>dpkg-buildpackage: 主機架構 i386 dpkg-source --before-build hello-1.0 fakeroot debian/rules cleandh clean dh_testdir dh_auto_cleanmake[1]: 正在進入目錄 `/home/zsx/deb/hello-1.0'rm -f *.o hellomake[1]:正在離開目錄 `/home/zsx/deb/hello-1.0' dh_clean dpkg-source -b hello-1.0dpkg-source: info: using source format `3.0 (quilt)'dpkg-source: info: building hello using existing ./hello_1.0.orig.tar.gzdpkg-source: info: building hello in hello_1.0-1.debian.tar.gzdpkg-source: info: building hello in hello_1.0-1.dsc debian/rules builddh build dh_testdir dh_auto_configure dh_auto_buildmake[1]: 正在進入目錄 `/home/zsx/deb/hello-1.0'gcc -g -g -O2 -c -o hello.o hello.cgcc -g -o hello hello.omake[1]:正在離開目錄 `/home/zsx/deb/hello-1.0' dh_auto_test fakeroot debian/rules binarydh binary dh_testroot dh_prep dh_installdirs dh_auto_install dh_install dh_installdocs dh_installchangelogs dh_installexamples dh_installman dh_installcatalogs dh_installcron dh_installdebconf dh_installemacsen dh_installifupdown dh_installinfo dh_pysupport dh_installinit dh_installmenu dh_installmime dh_installmodules dh_installlogcheck dh_installlogrotate dh_installpam dh_installppp dh_installudev dh_installwm dh_installxfonts dh_bugfiles dh_lintian dh_gconf dh_icons dh_perl dh_usrlocal dh_link dh_compress dh_fixperms dh_strip dh_makeshlibs dh_shlibdeps dh_installdeb dh_gencontroldpkg-gencontrol: 警告: Depends field of package hello: 未知的替換變數 ${shlibs:Depends} dh_md5sums dh_builddebdpkg-deb:正在建立軟體包“hello”,包檔案為“../hello_1.0-1_i386.deb”。 dpkg-genchanges >../hello_1.0-1_i386.changesdpkg-genchanges: 上傳資料中包含完整的原始代碼 dpkg-source --after-build hello-1.0dpkg-buildpackage: 完整上傳(包含原始的代碼)15、打包成功,切回上級目錄就可看到我們的helloworld的deb包cd ..ls後就會看到hello_1.0-1_i386.deb