linux/ubuntu中制作deb安装包
由于要制作一个在arm平台上运行的xorg-server-1.12.4版本的安装包,所以需要学习如何制作deb安装包。这里以一个非常小的工程为例,记录制作的过程。
首先需要一个deb包管理系统,如debian、ubuntu等,这里我使用的是ubuntu14.04LTS,这些系统默认安装了deb包制作所需的工具,没有的话后期也可以通过sudo apt-get install来安装。
1 创建一个简单的源码包
ls -l
total 24
-rw-rw-r– 1 mountzf mountzf 73 Jul 8 14:05 helloworld.c
-rw-rw-r– 1 mountzf mountzf 323 Jul 8 14:32 Makefile
#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}
C code的内容与deb包的制作关系不大,这里还是先主要看一下makefile的内容,在制作deb包的时候,makfile是需要修改的。
# Sample makefile.
PROG=helloworld
CC=gcc
BINDIR=/usr/bin
INSTALL=cp
# Compile commands.
$(PROG):helloworld.c
$(CC) -o $(PROG) helloworld.c
# make clean command.
clean:
rm -rf $(PROG)
# make install command.
install:
$(INSTALL) $(PROG) $(BINDIR)
# make uninstall command.
uninstall:
rm -rf $(BINDIR)/$(PROG)
2 创建GPG key
GPG key在build包的时候需要用到,ubuntu系统中默认已经安装gpg工具,可以gpg --help
查看使用方法。这里gpg --gen-key
,然后按照提示依次进行即可。由于我是在虚拟机中运行ubuntu,生成密钥时遇到如下问题:
Not enough random bytes available. Please do some other work to give
the OS a chance to collect more entropy! (Need 288 more bytes)
不要慌,翻阅论坛后发现很多