1.环境准备:安装 gcc, autoconf, automake, libtool, gettext, dh-make和debhelper等包;
2.在/home/workroom/test目录下写一个简单的测试程序test.c:
#include <stdio.h>
void main()
{
printf("Hello world!\r\n");
}
3.在/home/workroom/test目录下运行 autoscan产生基本的 configure.scan文件,打开该文件,并添加红色的几行,然后另存为configure.ac。
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.68])
AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
AC_CONFIG_SRCDIR([test.c])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_CONFIG_HEADERS([config.h])
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_CONFIG_FILES([
Makefile
])
AC_OUTPUT
|
4.手工生成一个autogen.sh文件,内容如下:
#! /bin/sh
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# Regenerate the files autoconf / automake
rm -f configure
rm -f config.cache
rm -f config.log
aclocal -I .
autoheader
autoconf
automake -a -c
|
5.手工生成Makefile.am
sbin_PROGRAMS=testapp
testapp_SOURCES= test.c
|
6.执行./autogen.sh生成configure文件
root@Ubuntu:/home/workroom/test#./autogen.sh
7.执行./configure生成Makefile文件
root@Ubuntu:/home/workroom/test#./configure
8.执行 make编译
root@Ubuntu:/home/workroom/test#make
至此,第一阶段程序的自动编译环境已经完成,可以看到在当前目录下已经生成了 testapp可执行程序。执行 ./testapp会输出“Hello world!”
下面继续完成将当前程序打成deb包。
9.在当前目录下新建一个 debian目录,并进入该目录创建 control, rules, changlog,copyright,compat等几个必要的文件:
root@Ubuntu:/home/workroom/test# mkdir debian
root@Ubuntu:/home/workroom/test# cd debian
root@Ubuntu:/home/workroom/test# touch control
输入内容:
Source: testapp
Section: unknown
Priority: extra
Maintainer: aaa
Build-Depends: debhelper (>= 8.0.0), autotools-dev
Standards-Version: 3.9.2
Homepage: http://www.test.com
Package: testapp
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: testapp
testapp
|
root@Ubuntu:/home/workroom/test# touch copyright
输入内容:
Format: http://dep.debian.net/deps/dep5
Upstream-Name: testapp
Source: <url://example.com>
Files: *
Copyright: <years> <put author's name and email here>
<years> <likewise for another author>
License: <special license>
<Put the license of the package here indented by 1 space>
<This follows the format of Description: lines in control file>
.
<Including paragraphs>
|
root@Ubuntu:/home/workroom/test# touch changelog
输入内容:
testapp (1.0.0-1) stable; urgency=low
* Initial release (Closes: #nnnn) <nnnn is the bug number of your ITP>
-- aaa <aaa@unknown> Thu, 28 Jun 2012 13:27:14 +0800
|
root@Ubuntu:/home/workroom/test# touch compat
输入内容:
root@Ubuntu:/home/workroom/test# touch rules
输入内容:
#!/usr/bin/make -f
# testApp debian/rules using debhelper
# Copyright (C) 2012 aaa <aaa@gmail.com>
CXXFLAGS += -g -O2
CFLAGS += -g -O2
build-arch: build
build-indep: build
build: build-stamp
build-stamp: build-test-stamp
touch build-stamp
build-test-stamp:
mkdir build_test
ls |grep -v debian|grep -v build_test|xargs -i cp -r {} build_test/
cd build_test && ./autogen.sh && ./configure
$(MAKE) -C build_test
touch build-test-stamp
clean: clean-patched
clean-patched:
dh_testdir
dh_testroot
[ ! -d $(CURDIR)/build_test ] || rm -rf $(CURDIR)/build_test
dh_clean
install: install-stamp
install-stamp: build-stamp
dh_testdir
dh_testroot
dh_prep
dh_installdirs
$(MAKE) -C $(CURDIR)/build_test install DESTDIR=$(CURDIR)/debian/tmp
dh_install --sourcedir=debian/tmp
touch install-stamp
binary-arch: build install
dh_testdir
dh_testroot
dh_install --list-missing
dh_installchangelogs
dh_installdocs
dh_installexamples
dh_installman
dh_python2 --no-guessing-versions
dh_link
dh_strip
dh_compress
dh_fixperms
dh_makeshlibs
dh_installdeb
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install
|
10.因为我们编译出来的程序名叫 testapp,为了把它做进deb包,还需要创建一个testapp.install文件:
root@Ubuntu:/home/workroom/test# touch testapp.install
至此,为制作deb包的所有环节已经准备好,在当前目录下执行:
root@Ubuntu:/home/workroom/test# ./debian/rules binary
11.成功之后,debian包生成在root@Ubuntu:/home/workroom/testapp_1.0.0-1.i386.deb
12.用dpkg -i命令安装这个deb:
root@Ubuntu:/home/workroom#dpkg –i testapp_1.0.0-1.i386.deb
安装完后执行 testapp:
root@Ubuntu:/home/workroom# testapp
Hello world!
以上从无到有,介绍了在linux Ubuntu下基本的编译环境和debian包生成的基本步骤和框架,当然如果工程复杂的话,需要在上述步骤中添加相应的依赖包等,但总体的框架和步骤是一样的,更详细的说明可以参考:http://www.debian.org/doc/manuals/maint-guide/index.en.html
分享到:
相关推荐
构建Docker Debian QT编译环境.docx
简介 ubuntu(debian)的软件包管理
本文详细介绍了Debian Linux系统下的内核编译方法。
nginx-autoinstall, 在Debian和Ubuntu上,使用定制模块从源代码编译 Nginx 自动安装通过optionnal模块编译和安装 Nginx 。 兼容性x86,x64,arm*Debian 8和更高版本Ubuntu 16.04和更高版本特性最新的主线或者稳定...
中英文两个版本,关于Debian deb包制作教程的官方文档。如果dpkg-buildpackage编译源码包细则等。中英文文档每份89页,读者可以对照看下。拿1积分好了,不知道之后会不会上调。
Debian打包参考手册。 Welcome to the Ubuntu Packaging Guide! This guide is primarily addressed to those who would like to make and maintain Ubuntu packages.
我从Ubntuu7.04开始到现在的8.04一直使用64位系统,一直都很稳定没遇到太大的问题。64位系统同样能使用32位的软件,只要在终端输入以下命令,安装相应的32位包: sudo apt-get install ia32-libs ia32-libs-gtk ...
最新的PPS的DEB包(UBUNTU DEBIAN可用)
ubuntu安装todesk
在快速ubuntu上安装cubeide你值得...这里提供了多个平台的安装包,Debian 和 Ubuntu应该选择STM32CubeIDE-DEB安装包,点击Get Software下载软件,耐心等待软件下载完毕。 2 找到软件 如果使用的是chrome浏览器进行下
# included in all copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF...
deb 安装包,适用于 Debian 9 - 11 / Ubuntu 18.x - 22.x 已注册,即装即用无限制。
对编译debian内核进行了详细的介绍,以及常见问题的处理方法。
前面的文件讲解了怎么制作debian系列的deb包,但是没有讲怎么制作apt-get私有源,其实debian也有类似的createrepo命令。下面我们看看制作私有apt源的过程 安装制作工具: apt-get install dpkg-dev 创建deb文件目录...
debian编译安装mysql5.7.35.txt 编译安装更稳定! 每一行复制执行即可完成安装!
debian编译安装php7.4.30.txt 编译安装更稳定! 每一行复制执行即可完成安装!
在ubuntu或者debian下面玩smartcard的必须品。知道的自然知道。
debian、ubuntu、凝思磐石系统oracle11g安装包,内含安装脚本支持自动安装数据库,并还原数据库dmp文件
QIHUA-X64 平台提供ubuntu、debian 等发行版linux 系统,在光盘 “QIHUA-X64 光盘/SDK 源码”目录下面,提供相关系统驱动源码和固件。 Ubuntu、Debian、Linux+QT 内核完全相同,编译配置方法相同。这儿以 ubuntu18 ...