[linux] ubuntu12.04 制作 deb包

 源码目录

hello-3.0/
         src/
            main.c
         lib/
            hello.c
            hello.h

src/main.c

1 int main(void) {
2     print_hello();
3     return 0;
4 }

lib/hello.h

1 #ifndef _HELLO_H
2 #define _HELLO_H
3 
4 void print_hello();
5 
6 #endif

lib/hello.c

1 #include "hello.h"
2 #include <stdio.h>
3 
4 void print_hello() {
5     printf("hello world\n");
6 }

automake

autoscan  
mv configure.scan configure.in

编辑 configure.in 文件

#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.68])
AC_INIT([hello], [3.0], [bluefrog.wu@gmail.com])
AC_CONFIG_SRCDIR([src/main.c])
#AC_CONFIG_HEADERS([config.h])

AM_INIT_AUTOMAKE(hello,3.0)

# Checks for programs.
AC_PROG_CC

AC_PROG_RANLIB

# Checks for libraries.

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_OUTPUT(Makefile lib/Makefile src/Makefile)
aclocal
autoconf

创建 Makefile.am 文件

AUTOMAKE_OPTIONS=foreign
SUBDIRS=lib src

创建 lib/Makefile.am 文件

UTOMAKE_OPTIONS=foreign
noinst_LIBRARIES=libhello.a
libhello_a_SOURCES=hello.h hello.c

创建 src/Makefile.am 文件

AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=hello
hello_SOURCES=main.c
hello_LDADD=../lib/libhello.a
automake --add-missing

./configure
make

make dist
mv hello-3.0.tar.gz ../

现在才开始包的制作

dh_make -e bluefrog.wu@gmail.com -f ../hello-3.0.tar.gz


Type of package: single binary, indep binary, multiple binary, library, kernel module, kernel patch?
 [s/i/m/l/k/n] s


#生成debian/ 文件夹 自己玩的话可以不用修改,如果要真正发布的话 还是google一下认真完成
rm debain/*ex

dpkg-buildpackage -rfakeroot

# 安装看看
sudo dpkg --install ../hello_3.0-1_i386.deb
# 看看安装好的包信息
dpkg -s hello

出现的一些问题和解决方案

dpkg-source: 错误: cannot represent change to hello-3.0/missing:
dpkg-source: 错误:   new version is 符号链接到 /usr/share/automake-1.11/missing
dpkg-source: 错误:   old version is 文本文件
dpkg-source: 错误: cannot represent change to hello-3.0/depcomp:
dpkg-source: 错误:   new version is 符号链接到 /usr/share/automake-1.11/depcomp
dpkg-source: 错误:   old version is 文本文件
dpkg-source: 错误: cannot represent change to hello-3.0/install-sh:
dpkg-source: 错误:   new version is 符号链接到 /usr/share/automake-1.11/install-sh
dpkg-source: 错误:   old version is 文本文件
dpkg-source: 警告: 新建的空文档 'autoscan.log' 不会被显示在差别文件中.
dpkg-source: 错误: unrepresentable changes to source
dpkg-buildpackage: 错误: dpkg-source -b hello-3.0 提供错误退出状态 2

解决 把hello_3.0.orig.tar.gz 解压就ok 

相关参考

automake 
http://www.cnblogs.com/ericdream/archive/2011/12/09/2282359.html make deb
http://www.linuxsir.org/bbs/thread322285.html http://www.debian.org/doc/manuals/maint-guide/ https://www.deleak.com/blog/2010/11/21/make-deb-pkg/ http://developer.ubuntu.com/packaging/html/packaging-new-software.html

 

 

posted on 2012-12-13 18:11  bluefrog  阅读(2049)  评论(0编辑  收藏  举报