Ubuntu包裝指南

文檔

與Debhelper包裝


[重要]

要求: “包裝從零開始”加上debhelper和dh-make的要求

作為一個打包者,你將很少像從前一節那樣從頭開始創建軟件包。 正如您可以想像的那樣,例如, 規則文件中的許多任務和信息對於包是常見的。 為了使包裝更容易和更高效,您可以使用debhelper來幫助完成這些任務。 Debhelper是一套Perl腳本(前綴為dh_ ),可以使包構建過程自動化。 通過這些腳本,構建Debian軟件包變得非常簡單。

在這個例子中,我們將再次構建GNU Hello包,但這次我們將把我們的工作與Ubuntu hello-debhelper包進行比較。 再次,創建一個你將要工作的目錄:

mkdir〜/ hello-debhelper cd〜/ hello-debhelper wget http://ftp.gnu.org/gnu/hello/hello-2.1.1.tar.gz mkdir ubuntu cd ubuntu

然後,獲取Ubuntu源碼包:

apt-get source hello-debhelper cd ..

像前面的例子一樣,我們需要做的第一件事是解壓原始(上游)壓縮包。

tar -xzvf hello-2.1.1.tar.gz

正如我們在前面的例子中那樣, 不是像上一個例子那樣將上游tarball複製到hello_2.1.1.orig.tar.gz ,而是讓dh_make為我們完成這項工作。 您必須做的唯一事情是重命名源文件夾,使其以<包名> - <版本>的形式存在,其中包名稱為小寫。 在這種情況下,只需解壓縮tarball就會生成一個正確命名的源目錄,這樣我們就可以進入它:

cd hello-2.1.1

要創建源代碼的初始“debianization”,我們將使用dh_make

dh_make -e your.maintainer@address -f ../hello-2.1.1.tar.gz

然後dh_make會問你一系列問題:

軟件包類型:單個二進製文件,多個二進製文件,庫文件,內核模塊或cdbs? [s / m / l / k / b] s
維護人員名稱:Captain Packager電子郵件地址:packager@coolness.com日期:2006年4月6日星期四10:07:19 -0700包名:hello版本:2.1.1授權方式:blank包裝類型:Single Hit to確認: 回車


[警告]

只運行一次dh_make -e 。 如果您在首次執行操作後再次運行它,則無法正常運行。 如果您想改變它或者犯了一個錯誤,請移除源代碼目錄並重新解壓上游tarball。 然後,您可以遷移到源目錄並重試。

運行dh_make -e做兩件事:

Hello程序不是很複雜,正如我們在“打包從零開始”一節中看到的那樣,打包它不需要比基本文件更多的東西。 因此,讓我們刪除.ex文件:

cd debian rm * .ex * .EX

對於你好 ,你也不會

* 許可證

* Ubuntu包裝指南索引

需要README.Debian (針對特定Debian問題的README文件,而不是程序的自述文件), dirs (由dh_installdirs用於創建所需目錄), docs (由dh_installdocs用於安裝程序文檔)或info (由dh_installinfo用於安裝信息文件)文件到debian目錄中。 有關這些文件的更多信息,請參閱“dh_make示例文件”一節。

此時,您應該只有debian目錄中的changelogcompat控制版權規則文件。 從“打包從零開始”一節中,唯一新增的文件是compat ,它是一個包含使用的debhelper版本(在本例中為4)的文件。

在這種情況下,您需要稍微調整changelog以反映此軟件包名稱為hello-debhelper,而不僅僅是hello

hello-debhelper(2.1.1-1)dapper; 緊急度=低*初始版本 - Captain Packager 2006年4月6日星期四10:07:19 -0700

通過使用debhelper ,我們需要在控件中更改的唯一東西是名稱(用hello-debhelper替代hello ),並向源包的Build-Depends字段添加debhelper(> = 4.0.0)hello-debhelper的Ubuntu包看起來像:

我們可以復制Ubuntu hello-debhelper軟件包中的版權文件以及postinstprerm腳本,因為它們自從“從頭開始打包”一節以來沒有更改過。 我們也將復制規則文件,以便我們可以檢查它。

cp ../../ubuntu/hello-debhelper-2.1.1/debian/copyright。 cp ../../ubuntu/hello-debhelper-2.1.1/debian/postinst。 cp ../../ubuntu/hello-debhelper-2.1.1/debian/prerm。 cp ../../ubuntu/hello-debhelper-2.1.1/debian/rules。

我們需要看的最後一個文件是規則 ,可以看到debhelper腳本的能力。 debhelper版本的規則有些小一些(54行,而在“規則”一節中的版本是72行)。

debhelper版本如下所示:

#!/ usr / bin / make -f package = hello-debhelper CC = gcc CFLAGS = -g -Wall ifeq(,$(findstring noopt,$(DEB_BUILD_OPTIONS)))CFLAGS + = -O2 endif #export DH_VERBOSE = 1 clean :dh_testdir dh_clean rm -f build - $(MAKE)-i distclean install:build dh_clean dh_installdirs $(MAKE)prefix = $(CURDIR)/ debian / $(package)/ usr \ mandir = $(CURDIR)/ debian / $ (package)/ usr / share / man \ infodir = $(CURDIR)/ debian / $(package)/ usr / share / info \ install build:./configure --prefix = / usr $(MAKE)CC =“$ (CC)“CFLAGS =”$(CFLAGS)“

touch build binary-indep:install#這個軟件包生成的沒有獨立於架構的文件需要上傳#。 如果有任何他們會在這裡製作#。 binary-arch:安裝dh_testdir -a dh_testroot -a dh_installdocs -a新聞dh_installchangelogs -a ChangeLog dh_strip -a dh_compress -a dh_fixperms -a dh_installdeb -a dh_shlibdeps -a dh_gencontrol -a dh_md5sums -a dh_builddeb -a二進制:binary-indep binary-拱形.PHONY:二進制二進制二進製文件binary-indep clean checkroot

請注意,如果您在正確的目錄( dh_testdir )中進行測試,確保您正在構建具有超級用戶權限( dh_testroot )的軟件包,安裝文檔( dh_installdocsdh_installchangelogs )以及在構建( dh_clean )之後進行清理。 許多比hello複雜得多的包規則文件不會更大,因為debhelper腳本處理大部分任務。 有關debhelper腳本的完整列表,請參閱“ Debhelper腳本列表”一節。 他們在各自的手冊中也有很好的文檔。 閱讀上述規則文件中使用的每個幫助程序腳本的手冊頁(它們寫得很好,而且冗長)是一種有用的練習。