分享

从源码构建二进制deb包的步骤(cmake install 命令和devhelper dh

 zhouADNjj 2014-03-12

安装debhelper 和dh_make 两个deb包。

man debhelper查看帮助

在线帮助文档:

Debian 新维护人员手册

http://www./doc/manuals/maint-guide/

下面以一个简单测试程序,试试制作deb包的流程

用cmake写的make

-----------------------------------

root@debian01:/home/bright/helloworld-1.0# ls

CMakeLists.txt hello_world.h  main.cpp

----------------------------------

root@debian01:/home/bright/helloworld-1.0# cat hello_world.h

#include <iostream>

class HelloWorld

{

public:

HelloWorld() {

std::cout << "hello world!\n" << std::endl;

}

};

------------------------------------

root@debian01:/home/bright/helloworld-1.0# cat main.cpp 

#include "hello_world.h"

int main()

{

HelloWorld a;

}

----------------------------------

root@debian01:/home/bright/helloworld-1.0# cat CMakeLists.txt 

cmake_minimum_required(VERSION 2.8)

project(hello_world)

add_executable(hello_world main.cpp)

#指定install命令

# 最后的目录是 <prefix>/<DESTINATION> 因为最后prefix一般都是/usr/ 所以最后组合

# 在一起就是/usr/bin/helloworld-1.0, 这个是debian的要求目录结构

install(TARGETS  hello_world

RUNTIME  DESTINATION bin/helloworld-1.0)

# 用PROGRAMS指定,好像复制的时候,直接在源码目录下复制。没有正确使用相对build目录。

# 可能用于实现编译好的第三方的程序比较合适。自己编译的程序还是用TARGETS指定比较好

#install(PROGRAMS hello_world

#     DESTINATION bin/helloworld-1.0)

参考 cmake install 命令的说明 http://www./cmake/help/v2.8.12/cmake.html#command:install

--------------------------------------

root@debian01:/home/brighthelloworld-1.0# cmake .

-- Configuring done

-- Generating done

-- Build files have been written to: /home/bright/helloworld

-----------------

cmake生成的install比较复杂,除了Makefile文件之外,还生成了一个cmake_install.cmake 文件。

上面的cmake的配置,默认是安装到下面这个路径。说是要指定CMAKE_INSTALL_PREFIX 这个变量才行。

root@debian01:/home/bright/helloworld-1.0# make install

[100%] Built target hello_world

Install the project...

-- Install configuration: ""

-- Installing: /usr/local/bin/helloworld-1.0/hello_world

这个要看dh_auto_install 能不能识别cmake的install,然后传CMAKE_INSTALL_PREFIX命令过去才行。下面试试看

下面开始制作deb包:

1.dh_make 

=========

root@debian01:/home/bright/helloworld-1.0# dh_make --native

Type of package: single binary, indep binary, multiple binary, library, kernel module, kernel patch?

 [s/i/m/l/k/n] s

Maintainer name  : root

Email-Address    : root@debian01.IN 

Date             : Mon, 02 Dec 2013 14:26:17 +0800

Package Name     : helloworld

Version          : 1.0

License          : gpl3

Type of Package  : Single

Hit <enter> to confirm: 

Done. Please edit the files in the debian/ subdirectory now. helloworld

uses a configure script, so you probably don't have to edit the Makefiles.

---------------------

当前的目录名字需要是<package name>-<version>这种格式,不然会有提示

看上去需要按照文档这样设置一下debian的变量。这里只是简单测试,就免去了。

-----------------------

$ cat >>~/.bashrc <<EOF

DEBEMAIL="your.email.address@example.org"

DEBFULLNAME="Firstname Lastname"

export DEBEMAIL DEBFULLNAME

EOF

$ . ~/.bashrc

----------------------

生成了很多文件

root@debian01:/home/bright/helloworld-1.0# ls -l debian/

总用量 116

-rw-r--r-- 1 root root   123 12月  2 14:28 changelog

-rw-r--r-- 1 root root     2 12月  2 14:28 compat

-rw-r--r-- 1 root root   522 12月  2 14:28 control

-rw-r--r-- 1 root root  1392 12月  2 14:28 copyright

-rw-r--r-- 1 root root     0 12月  2 14:28 docs

-rw-r--r-- 1 root root  1290 12月  2 14:28 emacsen-install.ex

-rw-r--r-- 1 root root   480 12月  2 14:28 emacsen-remove.ex

-rw-r--r-- 1 root root  1275 12月  2 14:28 emacsen-startup.ex

-rw-r--r-- 1 root root   140 12月  2 14:28 helloworld.cron.d.ex

-rw-r--r-- 1 root root   244 12月  2 14:28 helloworld.default.ex

-rw-r--r-- 1 root root   548 12月  2 14:28 helloworld.doc-base.EX

-rw-r--r-- 1 root root  4298 12月  2 14:28 init.d.ex

-rw-r--r-- 1 root root  1641 12月  2 14:28 manpage.1.ex

-rw-r--r-- 1 root root  4652 12月  2 14:28 manpage.sgml.ex

-rw-r--r-- 1 root root 11009 12月  2 14:28 manpage.xml.ex

-rw-r--r-- 1 root root   135 12月  2 14:28 menu.ex

-rw-r--r-- 1 root root   960 12月  2 14:28 postinst.ex

-rw-r--r-- 1 root root   933 12月  2 14:28 postrm.ex

-rw-r--r-- 1 root root   693 12月  2 14:28 preinst.ex

-rw-r--r-- 1 root root   880 12月  2 14:28 prerm.ex

-rw-r--r-- 1 root root   153 12月  2 14:28 README

-rw-r--r-- 1 root root   175 12月  2 14:28 README.Debian

-rw-r--r-- 1 root root   199 12月  2 14:28 README.source

-rwxr-xr-x 1 root root   442 12月  2 14:28 rules

drwxr-xr-x 2 root root  4096 12月  2 14:28 source

-rw-r--r-- 1 root root   799 12月  2 14:28 watch.ex

按照 http://www./doc/manuals/maint-guide/dother.zh-cn.html的说明删掉不需要的那些

Emacs 的配置文件,不需要

root@debian01:/home/bright/helloworld-1.0# rm -f debian/emacsen-*

这个是用来设置后台进程的,暂时不需要

root@debian01:/home/bright/helloworld-1.0# rm debian/helloworld.default.ex  debian/init.d.ex 

文档相关的不需要

manpage.1.ex     manpage.sgml.ex  manpage.xml.ex   menu.ex          

root@debian01:/home/bright/helloworld-1.0# rm debian/docs debian/helloworld.doc-base.EX debian/manpage.* 

图形界面菜单相关,不需要

root@debian01:/home/bright/helloworld-1.0# rm debian/menu.ex 

很多post pre 脚本相关的,这个简单的例子里面也不需要

root@debian01:/home/bright/helloworld-1.0# ls -l debian/*.ex

-rw-r--r-- 1 root root 140 12月  2 14:28 debian/helloworld.cron.d.ex

-rw-r--r-- 1 root root 960 12月  2 14:28 debian/postinst.ex

-rw-r--r-- 1 root root 933 12月  2 14:28 debian/postrm.ex

-rw-r--r-- 1 root root 693 12月  2 14:28 debian/preinst.ex

-rw-r--r-- 1 root root 880 12月  2 14:28 debian/prerm.ex

-rw-r--r-- 1 root root 799 12月  2 14:28 debian/watch.ex

root@debian01:/home/bright/helloworld-1.0# rm  debian/*.ex

最后剩下的文件如下

root@debian01:/home/bright/helloworld-1.0# ls -l  debian/

总用量 36

-rw-r--r-- 1 root root  123 12月  2 14:28 changelog

-rw-r--r-- 1 root root    2 12月  2 14:28 compat

-rw-r--r-- 1 root root  522 12月  2 14:28 control

-rw-r--r-- 1 root root 1392 12月  2 14:28 copyright

-rw-r--r-- 1 root root  153 12月  2 14:28 README

-rw-r--r-- 1 root root  175 12月  2 14:28 README.Debian

-rw-r--r-- 1 root root  199 12月  2 14:28 README.source

-rwxr-xr-x 1 root root  442 12月  2 14:28 rules

drwxr-xr-x 2 root root 4096 12月  2 14:47 source

接下来比较重要的是修改Makefile文件里面 make install部分,把文件复制到 /usr/local/bin/这种绝对路径的,全部改成

 $(DESTDIR)/usr/local/bin 这种相对路径。就是支持  $(DESTDIR)这个make程序变量。

这样deb的工具编译的时候,通过类似 “make DESTDIR=/tmp/stage install”这样的命令来调用make,才会把程序都安装到debian打包工具指定的临时目录去,才能正确打包到deb包里面去。

参考说明: http://www./doc/manuals/maint-guide/modify.zh-cn.html#destdir

但我这里是使用的是cmake,不是原始Makefile 的install target。他采用的cmake的CMAKE_INSTALL_PREFIX参数指定安装目录。后面看看debian的

包制作工具能比能识别这个cmake,然后正确的传参数过去了。

文档给的参考例子,install命令那里使用了 $(DESTDIR)这个变量,  

-----------------

BIN     = $(DESTDIR)/usr/bin

install: gentoo-target

        install -d $(BIN) $(ICONS) $(DESTDIR)/etc

        install ./gentoo $(BIN)

install -d $(DESTDIR)/usr/share/doc/gentoo/html

-----------------

2.  debian/control

===================

这个文件指定Packag name ,  Depends 库依赖等信息。

root@debian01:/home/bright/helloworld-1.0# cat  debian/control 

Source: helloworld

Section: unknown

Priority: extra

Maintainer: root <root@debian01.IN>

Build-Depends: debhelper (>= 8.0.0), cmake

Standards-Version: 3.9.3

Homepage: <insert the upstream URL, if relevant>

#Vcs-Git: git://git./collab-maint/helloworld.git

#Vcs-Browser: http://git./?p=collab-maint/helloworld.git;a=summary

Package: helloworld

Architecture: any

Depends: ${shlibs:Depends}, ${misc:Depends}

Description: <insert up to 60 chars description>

 <insert long description, indented with spaces>

参考说明:  http://www./doc/manuals/maint-guide/dreq.zh-cn.html#control  

做一下简单的修改,像下面这样

--------------------------------

root@debian01:/home/bright/helloworld-1.0# cat  debian/control 

Source: helloworld

Section: unknown

Priority: extra

Maintainer: bright <bright@hello_world.com>

Build-Depends: debhelper (>= 8.0.0), cmake

Standards-Version: 3.9.3

Homepage: <http://hi.baidu.com/widebright>

#Vcs-Git: git://git./collab-maint/helloworld.git

#Vcs-Browser: http://git./?p=collab-maint/helloworld.git;a=summary

Package: helloworld

Architecture: any

Depends: ${shlibs:Depends}, ${misc:Depends}

Description: <widebright test>

 <随便写的测试玩玩>

Package: helloworld-dev

Architecture: any

Depends: libstdc++6-4.7-dev

Description: <hello-world develop package>

 <随便写个例子玩玩>

-------------------------------------------

这里注意Depends的的设置

要找出编译你的软件所需的软件包可以使用这个命令:

$ dpkg-depcheck -d ./configure

To manually find exact build dependencies for /usr/bin/foo, execute

$ objdump -p /usr/bin/foo | grep NEEDED

对于列出的每个库,例如 libfoo.so.6,运行:

$ dpkg -S libfoo.so.6

Then just take the -dev version of every package as a Build-Depends entry. If you use ldd for this purpose, it will report indirect lib dependencies as well, resulting in the problem of excessive build dependencies.

3.  debian/rules

================

这个其实就是一个makefile文件,可以自己添加 自定义的build install clean 等选项。

-------------------------------

#!/usr/bin/make -f

# -*- makefile -*-

# Sample debian/rules that uses debhelper.

# This file was originally written by Joey Hess and Craig Small.

# As a special exception, when this file is copied by dh-make into a

# dh-make output file, you may use that output file without restriction.

# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.

#export DH_VERBOSE=1

%:

dh $@

------------------------------

默认内容就是  %: 匹配所有的makefile目标,然后转换成执行dh的命令

比如debian/rules clean对应 dh clean,其实最后就执行

dh_testdir

dh_auto_clean

dh_clean

debian/rules build 运行了 dh build,实际执行的命令为:

dh_testdir

dh_auto_configure         //这种auto开头的命令就自动去调用cmake ./configure之类的命令来做实际的工作。

dh_auto_build             //调用make

dh_auto_test

参考说明: http://www./doc/manuals/maint-guide/dreq.zh-cn.html#rules

利用override_dh_auto_configure 改写默认的参数,给cmake传一个参数。

其他的类似dh_auto_XXXX 命令行为应该也很多可以自这里修改的比如

的override_dh_auto_build:

        dh_auto_build -- build

------------

root@debian01:/home/bright/helloworld-1.0# cat debian/rules 

#!/usr/bin/make -f

# -*- makefile -*-

# Sample debian/rules that uses debhelper.

# This file was originally written by Joey Hess and Craig Small.

# As a special exception, when this file is copied by dh-make into a

# dh-make output file, you may use that output file without restriction.

# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.

#export DH_VERBOSE=1

%:

dh $@ 

override_dh_auto_configure:

dh_auto_configure -- -DCMAKE_BUILD_TYPE:STRING=Release

------------------------------

4. dh_auto_configure

====================

这个默认会执行./configure ,Makefile.PL 或者cmake等各种命令。

比如像这里事先执行cmake生成makefile,一些cmake的参数可以在这里传给cmake

5. dh_install

=============

这个可以指定把那些文件放到最后的deb包里面去,安装的时候安装到那个目录去。

默认的Makefile里面就有install命令,如果make install 时候就已经把文件的目录到 $(DESTDIR)的了话。

这一步就可以不用配置了。 因为dh_auto_install会自动吧 debian/<your package name> 这样的名字当作参数传给make

make install \

  DESTDIR=/path/to/package_version-revision/debian/package

make install 的时候就会把文件复制到 debian的目录去,它就可以自动处理了。

这个dh_install是针对 make install里面没有处理的文件的情况。

可以man查看一下帮助

man dh_install

还有 dh_install* 系列命令来做其他事情的, dh_installmodules   dh_installdirs   dh_installdocs 等等,可以自己man看一下帮助

配置文件

debian/<your package name>.install

如果在debian/control文件里面只指定一个 package,那么 dh_auto_install 命令是会把这个debian/<package name>这样的目录作为临时目录的

,然后把make install安装在这个临时目录的文件全部放到最终的deb文件里面去的。但如果debian/control文件里面指定多个package,那么dh_auto_install就使用 debian/tmp作为

临时目录,然后由你在5步的时候,自己使用dh_install 来决定把那些文件从debian/tmp目录下复制到  debian/<package-1> and debian/<package-2>目录去。最后的

package-1_*.deb和package-2_*.deb才包含改文件。

http://www./doc/manuals/maint-guide/modify.zh-cn.html#destdir

注意相对路径的指定,前面是相对 debian/tmp 这样的编译目录,后面是相对 debian/helloword-dev这样package目录。

前面可以是文件或者目录名,后面的如果省略dh_install 就自动根据前面部分的值推测后面部分的目录名。参见dh_install的帮助说明。

-------------

root@debian01:/home/bright/helloworld-1.0/debian# cat helloworld.install 

../../helloworld.conf etc/helloworld

usr/bin/helloworld-1.0/hello_world

root@debian01:/home/bright/helloworld-1.0/debian# cat helloworld-dev.install 

../../*.h usr/include/helloworld-1.0

6. 最后使用dpkg-buildpackage构建软件包

=====================================

http://www./doc/manuals/maint-guide/build.zh-cn.html

检查依赖包是否都已经安装上去了

dpkg-checkbuilddeps

打包源码,会把当前目录打包一个helloworld_1.0.tar.gz文件

dpkg-buildpackage -S

构建deb包

dpkg-buildpackage

--------

Install the project...

/usr/bin/cmake -P cmake_install.cmake

-- Install configuration: "Release"

-- Installing: /home/bright/helloworld-1.0/debian/tmp/usr/bin/helloworld-1.0/hello_world

可以看到上面面这样输出, cmake已经把文件安装到debian/tmp目录下面去,说明dh_auto_install是能够兼容cmake的,已经把正确的路径传过去了。

或者是cmake本身兼容 标准make的  $(DESTDIR)变量的。可以正确吧CMakeList.txt文件里面install命令指定的文件,放到debian/tmp目录里面去。

7.测试debian包

==============

dpkg-buildpackage 生成的deb包放在父目录里面。

root@debian01:/home/bright/helloworld-1.0# ls -l  ../*.deb

-rw-r--r-- 1 root root    1986 12月  2 16:17 ../helloworld_1.0_i386.deb

-rw-r--r-- 1 root root    1874 12月  2 16:17 ../helloworld-dev_1.0_i386.deb

查看deb包的文件列表

root@debian01:/home/bright/helloworld-1.0# dpkg-deb -c ../helloworld_1.0_i386.deb

drwxr-xr-x root/root         0 2013-12-02 16:17 ./

drwxr-xr-x root/root         0 2013-12-02 16:17 ./usr/

drwxr-xr-x root/root         0 2013-12-02 16:17 ./usr/share/

drwxr-xr-x root/root         0 2013-12-02 16:17 ./usr/share/doc/

drwxr-xr-x root/root         0 2013-12-02 16:17 ./usr/share/doc/helloworld/

-rw-r--r-- root/root       175 2013-12-02 14:28 ./usr/share/doc/helloworld/README.Debian

-rw-r--r-- root/root       135 2013-12-02 14:28 ./usr/share/doc/helloworld/changelog.gz

-rw-r--r-- root/root      1392 2013-12-02 14:28 ./usr/share/doc/helloworld/copyright



root@debian01:/home/bright/helloworld-1.0# dpkg-deb -c  ../helloworld-dev_1.0_i386.deb

drwxr-xr-x root/root         0 2013-12-02 16:17 ./

drwxr-xr-x root/root         0 2013-12-02 16:17 ./usr/

drwxr-xr-x root/root         0 2013-12-02 16:17 ./usr/share/

drwxr-xr-x root/root         0 2013-12-02 16:17 ./usr/share/doc/

drwxr-xr-x root/root         0 2013-12-02 16:17 ./usr/share/doc/helloworld-dev/

-rw-r--r-- root/root       135 2013-12-02 14:28 ./usr/share/doc/helloworld-dev/changelog.gz

-rw-r--r-- root/root      1392 2013-12-02 14:28 ./usr/share/doc/helloworld-dev/copyright

可以看到没有把可执行文件加进去deb包里面。

原因是前面我在debian/control文件里面指定了两个package。 如果只指定一个 package,那么 dh_auto_install 命令是会把这个debian/<package name>这样的目录作为临时目录的

,然后把make install安装在这个临时目录的文件全部放到最终的deb文件里面去的。但如果control文件里面指定多个package,那么dh_auto_install就使用 debian/tmp作为

临时目录,然后由你在5步的时候,自己使用dh_install 来决定把那些文件从debian/tmp目录下复制到  debian/<package-1> and debian/<package-2>目录去。最后的

package-1_*.deb和package-2_*.deb才包含改文件。

http://www./doc/manuals/maint-guide/modify.zh-cn.html#destdir

因为我前面第5步没有指定 <package name 1>.install   package name 2>.install  文件,所以最终的包里面就没有把可执行文件放进去了。

现在先试一下一个package的情况

==========================

修改debian/control 把 helloworld-dev 注释掉 

----------------

root@debian01:/home/bright/helloworld-1.0# cat  debian/control 

Source: helloworld

Section: unknown

Priority: extra

Maintainer: bright <bright@hello_world.com>

Build-Depends: debhelper (>= 8.0.0), cmake

Standards-Version: 3.9.3

Homepage: <http://hi.baidu.com/widebright>

#Vcs-Git: git://git./collab-maint/helloworld.git

#Vcs-Browser: http://git./?p=collab-maint/helloworld.git;a=summary

Package: helloworld

Architecture: any

Depends: ${shlibs:Depends}, ${misc:Depends}

Description: <widebright test>

 <随便写的测试玩玩>

#Package: helloworld-dev

#Architecture: any

#Depends: libstdc++6-4.7-dev

#Description: <hello-world develop package>

# <随便写个例子玩玩>

---------------------------------

root@debian01:/home/bright/helloworld-1.0# dpkg-buildpackage

dpkg-buildpackage: source package helloworld

dpkg-buildpackage: source version 1.0

dpkg-buildpackage: source changed by root <root@debian01.IN>

dpkg-buildpackage: host architecture i386

 dpkg-source --before-build helloworld-1.0

 debian/rules clean

dh clean 

   dh_testdir

   dh_auto_clean

   dh_clean

 dpkg-source -b helloworld-1.0

dpkg-source: info: using source format `3.0 (native)'

dpkg-source: info: building helloworld in helloworld_1.0.tar.gz

dpkg-source: info: building helloworld in helloworld_1.0.dsc

 debian/rules build

dh build 

   dh_testdir

   debian/rules override_dh_auto_configure

make[1]: Entering directory `/home/bright/helloworld-1.0'

dh_auto_configure -- -DCMAKE_BUILD_TYPE:STRING=Release

-- The C compiler identification is GNU 4.7.2

-- The CXX compiler identification is GNU 4.7.2

-- Check for working C compiler: /usr/bin/gcc

-- Check for working C compiler: /usr/bin/gcc -- works

-- Detecting C compiler ABI info

-- Detecting C compiler ABI info - done

-- Check for working CXX compiler: /usr/bin/c++

-- Check for working CXX compiler: /usr/bin/c++ -- works

-- Detecting CXX compiler ABI info

-- Detecting CXX compiler ABI info - done

-- Configuring done

-- Generating done

-- Build files have been written to: /home/bright/helloworld-1.0/obj-i486-linux-gnu

make[1]: Leaving directory `/home/bright/helloworld-1.0'

   dh_auto_build

make[1]: Entering directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

/usr/bin/cmake -H/home/bright/helloworld-1.0 -B/home/bright/helloworld-1.0/obj-i486-linux-gnu --check-build-system CMakeFiles/Makefile.cmake 0

/usr/bin/cmake -E cmake_progress_start /home/bright/helloworld-1.0/obj-i486-linux-gnu/CMakeFiles /home/bright/helloworld-1.0/obj-i486-linux-gnu/CMakeFiles/progress.marks

make -f CMakeFiles/Makefile2 all

make[2]: Entering directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

make -f CMakeFiles/hello_world.dir/build.make CMakeFiles/hello_world.dir/depend

make[3]: Entering directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

cd /home/bright/helloworld-1.0/obj-i486-linux-gnu && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/bright/helloworld-1.0 /home/bright/helloworld-1.0 /home/bright/helloworld-1.0/obj-i486-linux-gnu /home/bright/helloworld-1.0/obj-i486-linux-gnu /home/bright/helloworld-1.0/obj-i486-linux-gnu/CMakeFiles/hello_world.dir/DependInfo.cmake --color=

Scanning dependencies of target hello_world

make[3]: Leaving directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

make -f CMakeFiles/hello_world.dir/build.make CMakeFiles/hello_world.dir/build

make[3]: Entering directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

/usr/bin/cmake -E cmake_progress_report /home/bright/helloworld-1.0/obj-i486-linux-gnu/CMakeFiles 1

[100%] Building CXX object CMakeFiles/hello_world.dir/main.cpp.o

/usr/bin/c++    -O3 -DNDEBUG   -o CMakeFiles/hello_world.dir/main.cpp.o -c /home/bright/helloworld-1.0/main.cpp

Linking CXX executable hello_world

/usr/bin/cmake -E cmake_link_script CMakeFiles/hello_world.dir/link.txt --verbose=1

/usr/bin/c++   -O3 -DNDEBUG    CMakeFiles/hello_world.dir/main.cpp.o  -o hello_world -rdynamic 

make[3]: Leaving directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

/usr/bin/cmake -E cmake_progress_report /home/bright/helloworld-1.0/obj-i486-linux-gnu/CMakeFiles  1

[100%] Built target hello_world

make[2]: Leaving directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

/usr/bin/cmake -E cmake_progress_start /home/bright/helloworld-1.0/obj-i486-linux-gnu/CMakeFiles 0

make[1]: Leaving directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

   dh_auto_test

 debian/rules binary

dh binary 

   dh_testroot

   dh_prep

   dh_installdirs

   dh_auto_install

make[1]: Entering directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

/usr/bin/cmake -H/home/bright/helloworld-1.0 -B/home/bright/helloworld-1.0/obj-i486-linux-gnu --check-build-system CMakeFiles/Makefile.cmake 0

/usr/bin/cmake -E cmake_progress_start /home/bright/helloworld-1.0/obj-i486-linux-gnu/CMakeFiles /home/bright/helloworld-1.0/obj-i486-linux-gnu/CMakeFiles/progress.marks

make -f CMakeFiles/Makefile2 all

make[2]: Entering directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

make -f CMakeFiles/hello_world.dir/build.make CMakeFiles/hello_world.dir/depend

make[3]: Entering directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

cd /home/bright/helloworld-1.0/obj-i486-linux-gnu && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/bright/helloworld-1.0 /home/bright/helloworld-1.0 /home/bright/helloworld-1.0/obj-i486-linux-gnu /home/bright/helloworld-1.0/obj-i486-linux-gnu /home/bright/helloworld-1.0/obj-i486-linux-gnu/CMakeFiles/hello_world.dir/DependInfo.cmake --color=

make[3]: Leaving directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

make -f CMakeFiles/hello_world.dir/build.make CMakeFiles/hello_world.dir/build

make[3]: Entering directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

make[3]: Nothing to be done for `CMakeFiles/hello_world.dir/build'.

make[3]: Leaving directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

/usr/bin/cmake -E cmake_progress_report /home/bright/helloworld-1.0/obj-i486-linux-gnu/CMakeFiles  1

[100%] Built target hello_world

make[2]: Leaving directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

/usr/bin/cmake -E cmake_progress_start /home/bright/helloworld-1.0/obj-i486-linux-gnu/CMakeFiles 0

make -f CMakeFiles/Makefile2 preinstall

make[2]: Entering directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

make[2]: Nothing to be done for `preinstall'.

make[2]: Leaving directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

Install the project...

/usr/bin/cmake -P cmake_install.cmake

-- Install configuration: "Release"

-- Installing: /home/bright/helloworld-1.0/debian/helloworld/usr/bin/helloworld-1.0/hello_world              ///////这里不再是debian/tmp目录了

make[1]: Leaving directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

   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_pysupport: This program is deprecated, you should use dh_python2 instead. Migration guide: http:///dhs2p

   dh_installinit

   dh_installmenu

   dh_installmime

   dh_installmodules

   dh_installlogcheck

   dh_installlogrotate

   dh_installpam

   dh_installppp

   dh_installudev

   dh_installwm

   dh_installxfonts

   dh_installgsettings

   dh_bugfiles

   dh_ucf

   dh_lintian

   dh_gconf

   dh_icons

   dh_perl

   dh_usrlocal

   dh_link

   dh_compress

   dh_fixperms

   dh_strip

   dh_makeshlibs

   dh_shlibdeps

dpkg-shlibdeps: warning: package could avoid a useless dependency if debian/helloworld/usr/bin/helloworld-1.0/hello_world was not linked against libgcc_s.so.1 (it uses none of the library's symbols)

   dh_installdeb

   dh_gencontrol

   dh_md5sums

   dh_builddeb

dpkg-deb:正在新建软件包 helloworld,包文件为 ../helloworld_1.0_i386.deb。

 dpkg-genchanges  >../helloworld_1.0_i386.changes

dpkg-genchanges: including full source code in upload

 dpkg-source --after-build helloworld-1.0

dpkg-buildpackage: full upload; Debian-native package (full source is included)

root@debian01:/home/bright/helloworld-1.0# dpkg-deb -c ../helloworld_1.0_i386.deb

drwxr-xr-x root/root         0 2013-12-02 17:21 ./

drwxr-xr-x root/root         0 2013-12-02 17:21 ./usr/

drwxr-xr-x root/root         0 2013-12-02 17:21 ./usr/bin/

drwxr-xr-x root/root         0 2013-12-02 17:21 ./usr/bin/helloworld-1.0/

-rwxr-xr-x root/root      4328 2013-12-02 17:21 ./usr/bin/helloworld-1.0/hello_world

drwxr-xr-x root/root         0 2013-12-02 17:21 ./usr/share/doc/

drwxr-xr-x root/root         0 2013-12-02 17:21 ./usr/share/doc/helloworld/

-rw-r--r-- root/root       175 2013-12-02 14:28 ./usr/share/doc/helloworld/README.Debian

-rw-r--r-- root/root       135 2013-12-02 14:28 ./usr/share/doc/helloworld/changelog.gz

-rw-r--r-- root/root      1392 2013-12-02 14:28 ./usr/share/doc/helloworld/copyright

可以看到./usr/bin/helloworld-1.0/hello_world 这个可执行文件已经打包进去了。正确的deb包

---------------------------------------

下面来测试两个package的情况

=======================

root@debian01:/home/bright/helloworld-1.0# cat debian/control 

Source: helloworld

Section: unknown

Priority: extra

Maintainer: bright <bright@hello_world.com>

Build-Depends: debhelper (>= 8.0.0), cmake

Standards-Version: 3.9.3

Homepage: <http://hi.baidu.com/widebright>

#Vcs-Git: git://git./collab-maint/helloworld.git

#Vcs-Browser: http://git./?p=collab-maint/helloworld.git;a=summary

Package: helloworld

Architecture: any

Depends: ${shlibs:Depends}, ${misc:Depends}

Description: <widebright test>

 <随便写的测试玩玩>

Package: helloworld-dev

Architecture: any

Depends: libstdc++6-4.7-dev

Description: <hello-world develop package>

 <随便写个例子玩玩>

退回第5步,补上两个package 对应的install文件。

root@debian01:/home/bright/helloworld-1.0/debian# cat helloworld.install 

../../helloworld.conf etc/helloworld

usr/bin/helloworld-1.0/hello_world

root@debian01:/home/bright/helloworld-1.0/debian# cat helloworld-dev.install 

../../*.h usr/include/helloworld-1.0

------------------------------

root@debian01:/home/bright/helloworld-1.0#  dpkg-buildpackage

dpkg-buildpackage: source package helloworld

dpkg-buildpackage: source version 1.0

dpkg-buildpackage: source changed by root <root@debian01.IN>

dpkg-buildpackage: host architecture i386

 dpkg-source --before-build helloworld-1.0

 debian/rules clean

dh clean 

   dh_testdir

   dh_auto_clean

   dh_clean

 dpkg-source -b helloworld-1.0

dpkg-source: info: using source format `3.0 (native)'

dpkg-source: info: building helloworld in helloworld_1.0.tar.gz

dpkg-source: info: building helloworld in helloworld_1.0.dsc

 debian/rules build

dh build 

   dh_testdir

   debian/rules override_dh_auto_configure

make[1]: Entering directory `/home/bright/helloworld-1.0'

dh_auto_configure -- -DCMAKE_BUILD_TYPE:STRING=Release

-- The C compiler identification is GNU 4.7.2

-- The CXX compiler identification is GNU 4.7.2

-- Check for working C compiler: /usr/bin/gcc

-- Check for working C compiler: /usr/bin/gcc -- works

-- Detecting C compiler ABI info

-- Detecting C compiler ABI info - done

-- Check for working CXX compiler: /usr/bin/c++

-- Check for working CXX compiler: /usr/bin/c++ -- works

-- Detecting CXX compiler ABI info

-- Detecting CXX compiler ABI info - done

-- Configuring done

-- Generating done

-- Build files have been written to: /home/bright/helloworld-1.0/obj-i486-linux-gnu

make[1]: Leaving directory `/home/bright/helloworld-1.0'

   dh_auto_build

make[1]: Entering directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

/usr/bin/cmake -H/home/bright/helloworld-1.0 -B/home/bright/helloworld-1.0/obj-i486-linux-gnu --check-build-system CMakeFiles/Makefile.cmake 0

/usr/bin/cmake -E cmake_progress_start /home/bright/helloworld-1.0/obj-i486-linux-gnu/CMakeFiles /home/bright/helloworld-1.0/obj-i486-linux-gnu/CMakeFiles/progress.marks

make -f CMakeFiles/Makefile2 all

make[2]: Entering directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

make -f CMakeFiles/hello_world.dir/build.make CMakeFiles/hello_world.dir/depend

make[3]: Entering directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

cd /home/bright/helloworld-1.0/obj-i486-linux-gnu && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/bright/helloworld-1.0 /home/bright/helloworld-1.0 /home/bright/helloworld-1.0/obj-i486-linux-gnu /home/bright/helloworld-1.0/obj-i486-linux-gnu /home/bright/helloworld-1.0/obj-i486-linux-gnu/CMakeFiles/hello_world.dir/DependInfo.cmake --color=

Scanning dependencies of target hello_world

make[3]: Leaving directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

make -f CMakeFiles/hello_world.dir/build.make CMakeFiles/hello_world.dir/build

make[3]: Entering directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

/usr/bin/cmake -E cmake_progress_report /home/bright/helloworld-1.0/obj-i486-linux-gnu/CMakeFiles 1

[100%] Building CXX object CMakeFiles/hello_world.dir/main.cpp.o

/usr/bin/c++    -O3 -DNDEBUG   -o CMakeFiles/hello_world.dir/main.cpp.o -c /home/bright/helloworld-1.0/main.cpp

Linking CXX executable hello_world

/usr/bin/cmake -E cmake_link_script CMakeFiles/hello_world.dir/link.txt --verbose=1

/usr/bin/c++   -O3 -DNDEBUG    CMakeFiles/hello_world.dir/main.cpp.o  -o hello_world -rdynamic 

make[3]: Leaving directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

/usr/bin/cmake -E cmake_progress_report /home/bright/helloworld-1.0/obj-i486-linux-gnu/CMakeFiles  1

[100%] Built target hello_world

make[2]: Leaving directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

/usr/bin/cmake -E cmake_progress_start /home/bright/helloworld-1.0/obj-i486-linux-gnu/CMakeFiles 0

make[1]: Leaving directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

   dh_auto_test

 debian/rules binary

dh binary 

   dh_testroot

   dh_prep

   dh_installdirs

   dh_auto_install

make[1]: Entering directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

/usr/bin/cmake -H/home/bright/helloworld-1.0 -B/home/bright/helloworld-1.0/obj-i486-linux-gnu --check-build-system CMakeFiles/Makefile.cmake 0

/usr/bin/cmake -E cmake_progress_start /home/bright/helloworld-1.0/obj-i486-linux-gnu/CMakeFiles /home/bright/helloworld-1.0/obj-i486-linux-gnu/CMakeFiles/progress.marks

make -f CMakeFiles/Makefile2 all

make[2]: Entering directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

make -f CMakeFiles/hello_world.dir/build.make CMakeFiles/hello_world.dir/depend

make[3]: Entering directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

cd /home/bright/helloworld-1.0/obj-i486-linux-gnu && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/bright/helloworld-1.0 /home/bright/helloworld-1.0 /home/bright/helloworld-1.0/obj-i486-linux-gnu /home/bright/helloworld-1.0/obj-i486-linux-gnu /home/bright/helloworld-1.0/obj-i486-linux-gnu/CMakeFiles/hello_world.dir/DependInfo.cmake --color=

make[3]: Leaving directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

make -f CMakeFiles/hello_world.dir/build.make CMakeFiles/hello_world.dir/build

make[3]: Entering directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

make[3]: Nothing to be done for `CMakeFiles/hello_world.dir/build'.

make[3]: Leaving directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

/usr/bin/cmake -E cmake_progress_report /home/bright/helloworld-1.0/obj-i486-linux-gnu/CMakeFiles  1

[100%] Built target hello_world

make[2]: Leaving directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

/usr/bin/cmake -E cmake_progress_start /home/bright/helloworld-1.0/obj-i486-linux-gnu/CMakeFiles 0

make -f CMakeFiles/Makefile2 preinstall

make[2]: Entering directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

make[2]: Nothing to be done for `preinstall'.

make[2]: Leaving directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

Install the project...

/usr/bin/cmake -P cmake_install.cmake

-- Install configuration: "Release"

-- Installing: /home/bright/helloworld-1.0/debian/tmp/usr/bin/helloworld-1.0/hello_world

make[1]: Leaving directory `/home/bright/helloworld-1.0/obj-i486-linux-gnu'

   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_pysupport: This program is deprecated, you should use dh_python2 instead. Migration guide: http:///dhs2p

   dh_installinit

   dh_installmenu

   dh_installmime

   dh_installmodules

   dh_installlogcheck

   dh_installlogrotate

   dh_installpam

   dh_installppp

   dh_installudev

   dh_installwm

   dh_installxfonts

   dh_installgsettings

   dh_bugfiles

   dh_ucf

   dh_lintian

   dh_gconf

   dh_icons

   dh_perl

   dh_usrlocal

   dh_link

   dh_compress

   dh_fixperms

   dh_strip

   dh_makeshlibs

   dh_shlibdeps

dpkg-shlibdeps: warning: package could avoid a useless dependency if debian/helloworld/usr/bin/helloworld-1.0/hello_world was not linked against libgcc_s.so.1 (it uses none of the library's symbols)

   dh_installdeb

   dh_gencontrol

   dh_md5sums

   dh_builddeb

dpkg-deb:正在新建软件包 helloworld,包文件为 ../helloworld_1.0_i386.deb。

dpkg-deb:正在新建软件包 helloworld-dev,包文件为 ../helloworld-dev_1.0_i386.deb。

 dpkg-genchanges  >../helloworld_1.0_i386.changes

dpkg-genchanges: including full source code in upload

 dpkg-source --after-build helloworld-1.0

dpkg-buildpackage: full upload; Debian-native package (full source is included)

---------------------------------------

root@debian01:/home/bright/helloworld-1.0# dpkg-deb -c ../helloworld_1.0_i386.deb

drwxr-xr-x root/root         0 2013-12-02 21:28 ./

drwxr-xr-x root/root         0 2013-12-02 21:28 ./etc/

drwxr-xr-x root/root         0 2013-12-02 21:28 ./etc/helloworld/

-rw-r--r-- root/root         0 2013-12-02 21:04 ./etc/helloworld/helloworld.conf

drwxr-xr-x root/root         0 2013-12-02 21:28 ./usr/

drwxr-xr-x root/root         0 2013-12-02 21:28 ./usr/bin/

drwxr-xr-x root/root         0 2013-12-02 21:28 ./usr/bin/helloworld-1.0/

-rwxr-xr-x root/root      4328 2013-12-02 21:28 ./usr/bin/helloworld-1.0/hello_world

drwxr-xr-x root/root         0 2013-12-02 21:28 ./usr/share/doc/

drwxr-xr-x root/root         0 2013-12-02 21:28 ./usr/share/doc/helloworld/

-rw-r--r-- root/root       175 2013-12-02 14:28 ./usr/share/doc/helloworld/README.Debian

-rw-r--r-- root/root       135 2013-12-02 14:28 ./usr/share/doc/helloworld/changelog.gz

-rw-r--r-- root/root      1392 2013-12-02 14:28 ./usr/share/doc/helloworld/copyright

root@debian01:/home/bright/helloworld-1.0# dpkg-deb -c ../helloworld-dev_1.0_i386.deb

drwxr-xr-x root/root         0 2013-12-02 21:28 ./

drwxr-xr-x root/root         0 2013-12-02 21:28 ./usr/

drwxr-xr-x root/root         0 2013-12-02 21:28 ./usr/include/

drwxr-xr-x root/root         0 2013-12-02 21:28 ./usr/include/helloworld-1.0/

-rw-r--r-- root/root       120 2013-12-02 13:17 ./usr/include/helloworld-1.0/hello_world.h

drwxr-xr-x root/root         0 2013-12-02 21:28 ./usr/share/

drwxr-xr-x root/root         0 2013-12-02 21:28 ./usr/share/doc/

drwxr-xr-x root/root         0 2013-12-02 21:28 ./usr/share/doc/helloworld-dev/

-rw-r--r-- root/root       135 2013-12-02 14:28 ./usr/share/doc/helloworld-dev/changelog.gz

-rw-r--r-- root/root      1392 2013-12-02 14:28 ./usr/share/doc/helloworld-dev/copyright

基本符合预期。


    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多