[置顶] 制作deb包


   由于需要自己手动制作deb包,上网搜索了不少的资料,总结一下,方便日后温习!


deb包的制作方法有:

    1. 使用checkinstall方法创建deb包:

checkinstall不仅可以生成deb包,还可以生成rpm包,使用简单,但是不灵活,功能粗糙,只做介绍,不推荐使用。

$ tar xvjf pcre-8.32.tar.bz2 // 解包
$ cd pcre-8.32
$ ./configure & make // 编译
$ checkinstall  // 制作deb包 (后面的一些参数可以自己根据需要添加,这里不作介绍)

此时当前目录下生成了deb包


    2. 使用dpkg方法创建deb包:

dpkg是最基本的制作deb包的方法,推荐使用。

a)首先要安装制作deb包所必需的软件包:

sudo apt-get install build-essential autoconf automake autotools-dev dh-make debhelper devscripts fakeroot xutils lintian pbuilder


b)解压:

$ tar xvjf pcre-8.32.tar.bz2 // 解包
$ cd pcre-8.32


c)使用dh_make生成必需的信息以及deb的模板:

dh_make -s -c gpl -n -e [email protected]


d)修改./pcre-8.32/debian/目录下的control信息:

Source: pcre
Section: devel
Priority: optional
Maintainer: Joe <[email protected]>
Build-Depends: debhelper (>= 7), autotools-dev
Standards-Version: 3.7.3
Homepage: http://sourceforge.net/projects/pcre/files/pcre/

Package: pcre
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: The PCRE library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as Perl 5.
 The PCRE library is a set of functions that implement regular expression
 pattern matching using the same syntax and semantics as Perl 5. PCRE has
 its own native API, as well as a set of wrapper functions that correspond to
 the POSIX regular expression API. The PCRE library is free, even for building proprietary software.


e)修改 ./pcre-8.32/debian/目录下的rules信息:

比如需要使pcre支持jit功能,那就要在rules中的编译选项中添加 --enable-jit 。

./configure $(CROSS) --prefix=/usr --enable-jit --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,def


f)使用$ dpkg-buildpackage -rfakeroot命令生成deb包:

$ dpkg-buildpackage -rfakeroot

此时,在./pcre-8.32/目录的上一级目录就会生成deb包等。



餐后甜点:
这里介绍一下control文件中各字段的含义。
  Source:表示源码包的名称。
  Section:列出了你的软件属于的类别,可能的值包括admin(管理),games(游戏),gnome,kde,mail(电子邮件),misc(杂项)<译者注:misc是miscellaneous的简称>,net(网络),sound(声音),text(文本),utils(实用工具)和web(万维网)。
  Priority:声明这个包的优先级(大部分的时候使用optional(可选的))。
  Maintainer:就是你(写上你的名字,后面的方括号"[ ]"里留下你的电子邮件地址)。
  Build-Depends:这行是编译依赖关系,也就是说要安装哪些软件包才可以编译这个程序。举个例子:Build-Depends: debhelper (>= 7)。debhelper是必须安装的软件。( 依赖需要自己分析)
  Standards-Version: 3.8.3,这行是使用的Debian Policy版本,目前最新的是 3.9.1。所以我们写成:Standards-Version: 3.9.1;
  Homepage:<insert the upstream URL, if relevant> ,这行是软件包的的首页地址。我们是从http://sourceforge.net/projects/pcre/files/pcre/ 下载的,所以写:Homepage: http://sourceforge.net/projects/pcre/files/pcre/。


下面是一个空行,表示Source 部分结束;


  Package:指该软件包的名字。如果你的软件包名称有两个词,用一个连字符(-)把它们连起来。软件包的名称只能有小写的英文字母,数字(不管你相信不相信)以及"+"和"-"。
  Architecture:是该程序可运行的CPU架构(可能的值为i386,amd64和powerpc)<译者注:此处虽然是专有名词,但是由于linux是大小写敏感的,所以文件内还是应该小写>。
  Depends:意味着要使用这个程序必须拥有的程序,如:Depends: ${shlibs:Depends}, ${misc:Depends}表示debhelper自动检测依赖,当然也可以自己添加。
  Description:<insert up to 60 chars description>,这行是简单的描述,要在60个字符以内,要用英语。从语言学来讲,这应该是一个名词性的成分,如:Description: The PCRE library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as Perl 5.。
  <insert long description, indented with spaces> ,这里写的是长描述。也是用英语,应该是完整的句子,每行大概写70个字符,不要太多,没写完可以换行,每行的开头都要有一个空格,示例:
  The PCRE library is a set of functions that implement regular expression
  pattern matching using the same syntax and semantics as Perl 5. PCRE has
  its own native API, as well as a set of wrapper functions that correspond to
  the POSIX regular expression API. The PCRE library is free, even for building proprietary software.
 每行开头都有一个半角空格。


  有些可能还包含以下内容:  
  Version:显然是程序的版本。确保这里的值不包括连字符。
  Eseential:指该软件包是否是必须的(大部分的时候不是)。
  Recommends:指除了极特殊情况下的安装之外,大多数时候都需要的依赖关系。
  Suggests:意味可能给这个软件带来更多功能的,但是没有完全没有问题的依赖关系<译者注:同Recommands>。
      你可以用英文的半角逗号分开不同的依赖关系(,)。如果两个软件中的任何一个可以工作,用竖线"|"分开它们。你也可以指定特定的版本,用在括号里用<<(小于),<=(小于或等于),=(等于),>=(大于或等于),或>>(大于)来表示。Install-Size是程序安装后的大小,按KB算。
  Conflicts:表示跟这个程序冲突的软件。
  Replaces:表明哪些软件包将被这个程序取代。


注:记住在control文件的最后一行留一空行,否则deb包无法运行。


参考:
http://os.51cto.com/art/201001/176881.htm
http://happycasts.net/episodes/14?autoplay=true
http://blog.longwin.com.tw/2009/03/debian-linux-package-build-deb-2009/
http://www.webupd8.org/2010/01/how-to-create-deb-package-ubuntu-debian.html
http://blog.chinaunix.net/uid-26488891-id-3204832.html
https://www.deleak.com/blog/2010/11/21/make-deb-pkg/
http://users.telenet.be/mydotcom/howto/linux/package.htm

http://www.debian.org/doc/manuals/maint-guide/dreq.zh-tw.html







   

你可能感兴趣的:([置顶] 制作deb包)